Bug 1557237. Stop using [array] in nsIPrompt and nsIPromptService. r=Gijs
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 06 Jun 2019 08:03:56 +0000
changeset 540417 ee9309aacb9e484e128bf55a2fe6c9e6cb63a316
parent 540416 b5df2e6d8478cb4aea88d109259714ca2772b6cd
child 540418 70af85b90c1d4a3f4c75f0fe82ed4a7fd69ce67a
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1557237
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1557237. Stop using [array] in nsIPrompt and nsIPromptService. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D33909
dom/browser-element/BrowserElementPromptService.jsm
mobile/android/components/PromptService.js
mobile/android/components/geckoview/GeckoViewPrompt.js
netwerk/base/nsIPrompt.idl
toolkit/components/passwordmgr/LoginManagerPrompter.jsm
toolkit/components/prompts/src/Prompter.jsm
toolkit/components/prompts/test/test_modal_select.html
toolkit/components/viewconfig/content/config.js
toolkit/components/windowwatcher/nsIPromptService.idl
--- a/dom/browser-element/BrowserElementPromptService.jsm
+++ b/dom/browser-element/BrowserElementPromptService.jsm
@@ -110,17 +110,17 @@ BrowserElementPrompt.prototype = {
   promptUsernameAndPassword(title, text, username, password, checkMsg, checkState) {
     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
   },
 
   promptPassword(title, text, password, checkMsg, checkState) {
     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
   },
 
-  select(title, text, aCount, aSelectList, aOutSelection) {
+  select(title, text, aSelectList, aOutSelection) {
     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
   },
 
   _buildConfirmExButtonProperties(buttonFlags, button0Title,
                                             button1Title, button2Title) {
     let r = {
       defaultButton: -1,
       buttons: [],
--- a/mobile/android/components/PromptService.js
+++ b/mobile/android/components/PromptService.js
@@ -324,17 +324,17 @@ InternalPrompt.prototype = {
 
     if (ok) {
       aUsername.value = data.textbox0;
       aPassword.value = data.password0;
     }
     return ok;
   },
 
-  select: function select(aTitle, aText, aCount, aSelectList, aOutSelection) {
+  select: function select(aTitle, aText, aSelectList, aOutSelection) {
     let p = this._getPrompt(aTitle, aText, [ PromptUtils.getLocaleString("OK") ]);
     p.addMenulist({ values: aSelectList });
     let data = this.showPrompt(p);
 
     let ok = data.button == 0;
     if (ok)
       aOutSelection.value = data.menulist0;
 
--- a/mobile/android/components/geckoview/GeckoViewPrompt.js
+++ b/mobile/android/components/geckoview/GeckoViewPrompt.js
@@ -606,17 +606,17 @@ PromptDelegate.prototype = {
     }
     if (aUsername) {
       aUsername.value = result.username || "";
     }
     aPassword.value = result.password || "";
     return true;
   },
 
-  select: function(aTitle, aText, aCount, aSelectList, aOutSelection) {
+  select: function(aTitle, aText, aSelectList, aOutSelection) {
     let choices = Array.prototype.map.call(aSelectList, (item, index) => ({
       id: String(index),
       label: item,
       disabled: false,
       selected: false,
     }));
     let result = this._showPrompt(this._addText(aTitle, aText, {
                                     type: "choice",
--- a/netwerk/base/nsIPrompt.idl
+++ b/netwerk/base/nsIPrompt.idl
@@ -86,12 +86,11 @@ interface nsIPrompt : nsISupports
                                        in wstring text,
                                        inout wstring username,
                                        inout wstring password,
                                        in wstring checkMsg,
                                        inout boolean checkValue);
 
     boolean select(in wstring dialogTitle,
                    in wstring text,
-                   in  uint32_t count,
-                   [array, size_is(count)] in wstring selectList,
+                   in Array<AString> selectList,
                    out long outSelection);
 };
--- a/toolkit/components/passwordmgr/LoginManagerPrompter.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerPrompter.jsm
@@ -1267,18 +1267,17 @@ LoginManagerPrompter.prototype = {
     var dialogText  = this._getLocalizedString("userSelectText2");
     var dialogTitle = this._getLocalizedString("passwordChangeTitle");
     var selectedIndex = { value: null };
 
     // If user selects ok, outparam.value is set to the index
     // of the selected username.
     var ok = Services.prompt.select(this._chromeWindow,
                                     dialogTitle, dialogText,
-                                    usernames.length, usernames,
-                                    selectedIndex);
+                                    usernames, selectedIndex);
     if (ok) {
       // Now that we know which login to use, modify its password.
       var selectedLogin = logins[selectedIndex.value];
       this.log("Updating password for user " + selectedLogin.username);
       var newLoginWithUsername = Cc["@mozilla.org/login-manager/loginInfo;1"].
                      createInstance(Ci.nsILoginInfo);
       newLoginWithUsername.init(aNewLogin.origin,
                                 aNewLogin.formActionOrigin, aNewLogin.httpRealm,
--- a/toolkit/components/prompts/src/Prompter.jsm
+++ b/toolkit/components/prompts/src/Prompter.jsm
@@ -85,19 +85,19 @@ Prompter.prototype = {
         return p.nsIPrompt_promptUsernameAndPassword(title, text, user, pass, checkLabel, checkValue);
     },
 
     promptPassword(domWin, title, text, pass, checkLabel, checkValue) {
         let p = this.pickPrompter(domWin);
         return p.nsIPrompt_promptPassword(title, text, pass, checkLabel, checkValue);
     },
 
-    select(domWin, title, text, count, list, selected) {
+    select(domWin, title, text, list, selected) {
         let p = this.pickPrompter(domWin);
-        return p.select(title, text, count, list, selected);
+        return p.select(title, text, list, selected);
     },
 
 
     promptAuth(domWin, channel, level, authInfo, checkLabel, checkValue) {
         let p = this.pickPrompter(domWin);
         return p.promptAuth(channel, level, authInfo, checkLabel, checkValue);
     },
 
@@ -787,17 +787,17 @@ ModalPrompter.prototype = {
         if (ok) {
             checkValue.value = args.checked;
             pass.value       = args.pass;
         }
 
         return ok;
     },
 
-    select(title, text, count, list, selected) {
+    select(title, text, list, selected) {
         if (!title)
             title = PromptUtils.getLocalizedString("Select");
 
         let args = {
             promptType: "select",
             title,
             text,
             list,
--- a/toolkit/components/prompts/test/test_modal_select.html
+++ b/toolkit/components/prompts/test/test_modal_select.html
@@ -60,17 +60,17 @@ add_task(async function test_select_empt
         items: [],
     };
     let action = {
         buttonClick: "ok",
     };
     let promptDone = handlePrompt(state, action);
     let items = [];
     selectVal.value = null; // outparam, just making sure.
-    isOK = Services.prompt.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
+    isOK = Services.prompt.select(window, "TestTitle", "This is the select text.", items, selectVal);
     is(isOK, true, "checked expected retval");
     is(selectVal.value, -1, "checking selected index");
 
     await promptDone;
 });
 
 // =====
 add_task(async function test_select_ok() {
@@ -81,17 +81,17 @@ add_task(async function test_select_ok()
         items: ["one", "two", "three"],
     };
     let action = {
         buttonClick: "ok",
     };
     let promptDone = handlePrompt(state, action);
     let items = ["one", "two", "three"];
     selectVal.value = null; // outparam, just making sure.
-    isOK = Services.prompt.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
+    isOK = Services.prompt.select(window, "TestTitle", "This is the select text.", items, selectVal);
     is(isOK, true, "checked expected retval");
     is(selectVal.value, 0, "checking selected index");
 
     await promptDone;
 });
 
 // =====
 add_task(async function test_select_item() {
@@ -103,17 +103,17 @@ add_task(async function test_select_item
     };
     let action = {
         buttonClick: "ok",
         selectItem: 1,
     };
     let promptDone = handlePrompt(state, action);
     let items = ["one", "two", "three"];
     selectVal.value = null; // outparam, just making sure.
-    isOK = Services.prompt.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
+    isOK = Services.prompt.select(window, "TestTitle", "This is the select text.", items, selectVal);
     is(isOK, true, "checked expected retval");
     is(selectVal.value, 1, "checking selected index");
 
     await promptDone;
 });
 
 // =====
 add_task(async function test_cancel_prompt() {
@@ -124,17 +124,17 @@ add_task(async function test_cancel_prom
         items: ["one", "two", "three"],
     };
     let action = {
         buttonClick: "cancel",
     };
     let promptDone = handlePrompt(state, action);
     let items = ["one", "two", "three"];
     selectVal.value = null; // outparam, just making sure.
-    isOK = Services.prompt.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
+    isOK = Services.prompt.select(window, "TestTitle", "This is the select text.", items, selectVal);
     is(isOK, false, "checked expected retval");
     is(selectVal.value, 0, "checking selected index");
 
     await promptDone;
 });
 
 </script>
 </pre>
--- a/toolkit/components/viewconfig/content/config.js
+++ b/toolkit/components/viewconfig/content/config.js
@@ -593,17 +593,17 @@ function gotoPref(pref) {
 async function ModifyPref(entry) {
   if (entry.lockCol == PREF_IS_LOCKED)
     return false;
 
   let [title] = await document.l10n.formatValues([{id: "config-modify-title", args: { type: gTypeStrs[entry.typeCol] }}]);
 
   if (entry.typeCol == nsIPrefBranch.PREF_BOOL) {
     var check = { value: entry.valueCol == "false" };
-    if (!entry.valueCol && !Services.prompt.select(window, title, entry.prefCol, 2, [false, true], check))
+    if (!entry.valueCol && !Services.prompt.select(window, title, entry.prefCol, [false, true], check))
       return false;
     gPrefBranch.setBoolPref(entry.prefCol, check.value);
   } else {
     var result = { value: entry.valueCol };
     var dummy = { value: 0 };
     if (!Services.prompt.prompt(window, title, entry.prefCol, result, null, dummy))
       return false;
     if (entry.typeCol == nsIPrefBranch.PREF_INT) {
--- a/toolkit/components/windowwatcher/nsIPromptService.idl
+++ b/toolkit/components/windowwatcher/nsIPromptService.idl
@@ -326,31 +326,28 @@ interface nsIPromptService : nsISupports
    * may make a single selection.
    *
    * @param aParent
    *        The parent window or null.
    * @param aDialogTitle
    *        Text to appear in the title of the dialog.
    * @param aText
    *        Text to appear in the body of the dialog.
-   * @param aCount
-   *        The length of the aSelectList array parameter.
    * @param aSelectList
    *        The list of strings to display.
    * @param aOutSelection
    *        Contains the index of the selected item in the list when this
    *        method returns true.
    *
    * @return true for OK, false for Cancel.
    */
   boolean select(in mozIDOMWindowProxy aParent,
                  in wstring aDialogTitle,
                  in wstring aText,
-                 in  uint32_t aCount,
-                 [array, size_is(aCount)] in wstring aSelectList,
+                 in Array<AString> aSelectList,
                  out long aOutSelection);
 
   // NOTE: These functions differ from their nsIAuthPrompt counterparts by
   // having additional checkbox parameters
   // checkValue can be null meaning to show no checkbox
   // checkboxLabel is a wstring so that it can be null from both JS and C++ in
   // a convenient way
   //