Bug 307081 - Fix buggy Android implementation of nsIClientAuthDialogs::ChooseCertificate(). r=kats draft
authorCykesiopka <cykesiopka.bmo@gmail.com>
Fri, 24 Jun 2016 00:12:01 -0700
changeset 381111 11b25444f5c384bdc17b3b1e6deccaca75e53d71
parent 381110 6fcf253b671231482a64fa46d2c9ca0342894e66
child 381112 1c09b2b5f4c4281ab2e5cf73758bb6578e6c9c6e
push id21395
push usercykesiopka.bmo@gmail.com
push dateFri, 24 Jun 2016 07:13:10 +0000
reviewerskats
bugs307081
milestone50.0a1
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
mobile/android/components/NSSDialogService.js
--- 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;
       }