Bug 1520966 - Update test_xml_load to use modal state properties and remove now unused checkModalPrompt code. r=MattN
☠☠ backed out by a2e4f48c810b ☠ ☠
authorJared Wein <jwein@mozilla.com>
Fri, 01 Feb 2019 18:49:58 +0000
changeset 456487 f66aef24ffe6b0fd914d9f5f5a78aa848c63bba9
parent 456486 060f52cbeaf26bcf951f190132fb7ad220967234
child 456488 1da2f61f8c538eff6202ddac84ce9988e90ddafa
push id111656
push userdvarga@mozilla.com
push dateSat, 02 Feb 2019 09:51:54 +0000
treeherdermozilla-inbound@d8cebb3b46cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1520966
milestone67.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 1520966 - Update test_xml_load to use modal state properties and remove now unused checkModalPrompt code. r=MattN Differential Revision: https://phabricator.services.mozilla.com/D18268
toolkit/components/passwordmgr/test/mochitest/test_xml_load.html
toolkit/components/prompts/test/chromeScript.js
toolkit/components/prompts/test/prompt_common.js
--- a/toolkit/components/passwordmgr/test/mochitest/test_xml_load.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_xml_load.html
@@ -109,24 +109,27 @@ add_task(async function test_backgroundT
     titleHidden: true,
     textHidden: false,
     passHidden: false,
     checkHidden: true,
     checkMsg: "",
     checked: false,
     focused: "textField",
     defButton: "button0",
+    chrome: true,
+    dialog: true,
+    chromeDependent: true,
+    isWindowModal: true,
   };
 
   let action = {
     buttonClick: "none",
   };
 
   await handlePrompt(state, action);
-  await checkPromptModal();
 
   await new Promise(resolve => {
     let focusScript = runInParent(checkWindowFocus);
     focusScript.addMessageListener("focusResult", (msg) => {
       focusScript.removeMessageListener("focusResult");
       ok(msg, "Dialog appears on the right tab");
       resolve(true);
     });
--- a/toolkit/components/prompts/test/chromeScript.js
+++ b/toolkit/components/prompts/test/chromeScript.js
@@ -20,40 +20,16 @@ addMessageListener("handlePrompt", msg =
 function handlePromptWhenItAppears(action, isTabModal, isSelect) {
   let interval = setInterval(() => {
     if (handlePrompt(action, isTabModal, isSelect)) {
       clearInterval(interval);
     }
   }, 100);
 }
 
-addMessageListener("checkPromptModal", () => {
-  checkPromptIsModal();
-});
-
-function checkPromptIsModal() {
-  // Check that the dialog is modal, chrome and dependent;
-  // We can't just check window.opener because that'll be
-  // a content window, which therefore isn't exposed (it'll lie and
-  // be null).
-  let result = {};
-  let doc = getDialogDoc();
-  let win = doc.defaultView;
-  let treeOwner = win.docShell.treeOwner;
-  treeOwner.QueryInterface(Ci.nsIInterfaceRequestor);
-  let flags = treeOwner.getInterface(Ci.nsIXULWindow).chromeFlags;
-  let wbc = treeOwner.getInterface(Ci.nsIWebBrowserChrome);
-  result.chrome = (flags & Ci.nsIWebBrowserChrome.CHROME_OPENAS_CHROME) != 0;
-  result.dialog = (flags & Ci.nsIWebBrowserChrome.CHROME_OPENAS_DIALOG) != 0;
-  result.chromeDependent = (flags & Ci.nsIWebBrowserChrome.CHROME_DEPENDENT) != 0;
-  result.isWindowModal = wbc.isWindowModal();
-
-  sendAsyncMessage("checkPromptModalResult", result);
-}
-
 function handlePrompt(action, isTabModal, isSelect) {
   let ui;
 
   if (isTabModal) {
     let browserWin = Services.wm.getMostRecentWindow("navigator:browser");
     let gBrowser = browserWin.gBrowser;
     let promptManager = gBrowser.getTabModalPromptBox(gBrowser.selectedBrowser);
     let prompts = promptManager.listPrompts();
@@ -151,16 +127,20 @@ function getPromptState(ui) {
   } else {
     state.focused = "ERROR: unexpected element focused: " + (e ? e.localName : "<null>");
   }
 
   let treeOwner = ui.prompt &&
                   ui.prompt.docShell &&
                   ui.prompt.docShell.treeOwner;
   if (treeOwner && treeOwner.QueryInterface(Ci.nsIInterfaceRequestor)) {
+    // Check that the dialog is modal, chrome and dependent;
+    // We can't just check window.opener because that'll be
+    // a content window, which therefore isn't exposed (it'll lie and
+    // be null).
     let flags = treeOwner.getInterface(Ci.nsIXULWindow).chromeFlags;
     state.chrome = (flags & Ci.nsIWebBrowserChrome.CHROME_OPENAS_CHROME) != 0;
     state.dialog = (flags & Ci.nsIWebBrowserChrome.CHROME_OPENAS_DIALOG) != 0;
     state.chromeDependent = (flags & Ci.nsIWebBrowserChrome.CHROME_DEPENDENT) != 0;
     let wbc = treeOwner.getInterface(Ci.nsIWebBrowserChrome);
     state.isWindowModal = wbc.isWindowModal();
   }
 
--- a/toolkit/components/prompts/test/prompt_common.js
+++ b/toolkit/components/prompts/test/prompt_common.js
@@ -30,30 +30,16 @@ function handlePrompt(state, action) {
       gChromeScript.removeMessageListener("promptHandled", handled);
       checkPromptState(msg.promptState, state);
       resolve(true);
     });
     gChromeScript.sendAsyncMessage("handlePrompt", { action, isTabModal});
   });
 }
 
-function checkPromptModal() {
-  return new Promise(resolve => {
-    gChromeScript.addMessageListener("checkPromptModalResult", function handled(result) {
-      gChromeScript.removeMessageListener("checkPromptModalResult", handled);
-      ok(result.chrome, "Dialog should be opened as chrome");
-      ok(result.dialog, "Dialog should be a dialog");
-      ok(result.chromeDependent, "Dialog should be chrome dependent");
-      ok(result.isWindowModal, "Dialog should be a window modal");
-      resolve(true);
-    });
-    gChromeScript.sendAsyncMessage("checkPromptModal");
-  });
-}
-
 function checkPromptState(promptState, expectedState) {
     info(`checkPromptState: ${expectedState.msg}`);
     // XXX check title? OS X has title in content
     is(promptState.msg, expectedState.msg, "Checking expected message");
     if (isOSX && !isTabModal)
       ok(!promptState.titleHidden, "Checking title always visible on OS X");
     else
       is(promptState.titleHidden, expectedState.titleHidden, "Checking title visibility");