Bug 307081 - Fix buggy Android implementation of nsIClientAuthDialogs::ChooseCertificate(). r=kats
This fixes two issues:
1. Passing a literal 1 as the |length| argument to formatStringFromName(). This
is obviously incorrect and should instead be the length of the given arg
list.
2. Directly setting the |selectedIndex| outparam to a number. XPIDL outparams
on the JS side are actually objects that wrap the true outparam value, which
must be accessed via |.value|.
MozReview-Commit-ID: BJObQfcV5G7
--- a/mobile/android/components/NSSDialogService.js
+++ b/mobile/android/components/NSSDialogService.js
@@ -32,17 +32,17 @@ NSSDialogs.prototype = {
}
return this.bundle.GetStringFromName(aName);
},
formatString: function(aName, argList) {
if (!this.bundle) {
this.bundle = Services.strings.createBundle("chrome://browser/locale/pippki.properties");
}
- return this.bundle.formatStringFromName(aName, argList, 1);
+ return this.bundle.formatStringFromName(aName, argList, argList.length);
},
getPrompt: function(aTitle, aText, aButtons) {
return new Prompt({
title: aTitle,
text: aText,
buttons: aButtons,
});
@@ -165,38 +165,39 @@ NSSDialogs.prototype = {
}
let organizationString = this.formatString("clientAuthAsk.organization",
[organization]);
let issuerString = this.formatString("clientAuthAsk.issuer",
[issuer]);
let serverRequestedDetails = cn + '<br/>' + organizationString + '<br/>' + issuerString;
- selectedIndex = 0;
+ selectedIndex.value = 0;
while (true) {
let prompt = this.getPrompt(this.getString("clientAuthAsk.title"),
this.getString("clientAuthAsk.message1"),
[ this.getString("nssdialogs.ok.label"),
this.getString("clientAuthAsk.viewCert.label"),
this.getString("nssdialogs.cancel.label")
])
.addLabel({ id: "requestedDetails", label: serverRequestedDetails } )
.addMenulist({
id: "nicknames",
label: this.getString("clientAuthAsk.message2"),
- values: certNickList, selected: selectedIndex
+ values: certNickList,
+ selected: selectedIndex.value,
}).addCheckbox({
id: "rememberBox",
label: this.getString("clientAuthAsk.remember.label"),
checked: rememberSetting
});
let response = this.showPrompt(prompt);
- selectedIndex = response.nicknames;
+ selectedIndex.value = response.nicknames;
if (response.button == 1) {
- this.viewCertDetails(certDetailsList[selectedIndex]);
+ this.viewCertDetails(certDetailsList[selectedIndex.value]);
continue;
} else if (response.button == 0) {
canceled.value = false;
if (response.rememberBox == true) {
aCtx.QueryInterface(Ci.nsIClientAuthUserDecision).rememberClientAuthCertificate = true;
}
return true;
}