Bug 981796 - Make tests that use showModalDialog pass. r=smaug
authorBlake Kaplan <mrbkap@gmail.com>
Fri, 16 Jun 2017 12:41:01 -0700
changeset 365218 bae6691021e3f7882d8bdd26349d49f9b25b6907
parent 365217 bd0ffaac1d66f69c97c6695f54806b833b1a4c16
child 365219 cf345d031b958d9e9e477aaac620abbae7c9c162
push id32066
push userkwierso@gmail.com
push dateWed, 21 Jun 2017 23:54:49 +0000
treeherdermozilla-central@95c9259724a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs981796
milestone56.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 981796 - Make tests that use showModalDialog pass. r=smaug Annoyingly, setting the pref doesn't magically make the function appear on the current window, so we create an iframe and retrieve it from there. MozReview-Commit-ID: 9fOr4YJOzXh
dom/base/test/test_dialogArguments.html
dom/base/test/test_mutationobservers.html
dom/html/test/test_bug391777.html
dom/html/test/test_iframe_sandbox_modal.html
dom/tests/mochitest/bugs/mochitest.ini
dom/tests/mochitest/bugs/test_bug291653.html
dom/tests/mochitest/bugs/test_bug406375.html
dom/tests/mochitest/bugs/test_bug414291.html
dom/tests/mochitest/bugs/test_bug437361.html
dom/tests/mochitest/bugs/test_bug479143.html
dom/tests/mochitest/bugs/test_bug504862.html
dom/tests/mochitest/bugs/test_bug61098.html
dom/tests/mochitest/general/mochitest.ini
dom/tests/mochitest/general/test_showModalDialog.html
dom/tests/mochitest/general/test_showModalDialog_e10s.html
dom/tests/mochitest/general/test_showModalDialog_removed.html
--- a/dom/base/test/test_dialogArguments.html
+++ b/dom/base/test/test_dialogArguments.html
@@ -11,18 +11,26 @@
 <script type="application/javascript">
 
 /*
 	Tests whether Firefox crashes when accessing the dialogArguments property
 	of a modal window that has been closed.
 */
 SimpleTest.waitForExplicitFinish();
 
-function openModal() {
-	showModalDialog("javascript:opener.winRef = window; \
+async function openModal() {
+	await SpecialPowers.pushPrefEnv({ set: [[
+		"dom.disable_window_showModalDialog", false ]] });
+
+	let iframe = document.createElement("iframe");
+	document.body.appendChild(iframe);
+	await new Promise(resolve => {
+		iframe.addEventListener("load", resolve);
+	});
+	iframe.contentWindow.showModalDialog("javascript:opener.winRef = window; \
 		window.opener.setTimeout(\'winRef.dialogArguments;\', 0);\
 		window.close();");
 
 	ok(true, "dialogArguments did not cause a crash.");
 	SimpleTest.finish();
 }
 
 window.onload = openModal;
--- a/dom/base/test/test_mutationobservers.html
+++ b/dom/base/test/test_mutationobservers.html
@@ -482,17 +482,24 @@ function testSyncXHR() {
   setTimeout(testSyncXHR2, 0);
 }
 
 function testSyncXHR2() {
   ok(callbackHandled, "Should have called the mutation callback!");
   then(testModalDialog);
 }
 
-function testModalDialog() {
+async function testModalDialog() {
+  await SpecialPowers.pushPrefEnv({ set: [[ "dom.disable_window_showModalDialog", false ]] });
+  let iframe = document.createElement("iframe");
+  document.body.appendChild(iframe);
+  await new Promise(resolve => {
+    iframe.addEventListener("load", resolve);
+  });
+  window.showModalDialog = iframe.contentWindow.showModalDialog;
   var didHandleCallback = false;
   div.innerHTML = "<span>1</span><span>2</span>";
   m = new M(function(records, observer) {
       is(records[0].type, "childList", "Should have got childList");
       is(records[0].removedNodes.length, 2, "Should have got removedNodes");
       is(records[0].addedNodes.length, 1, "Should have got addedNodes");
       observer.disconnect();
       m = null;
--- a/dom/html/test/test_bug391777.html
+++ b/dom/html/test/test_bug391777.html
@@ -9,17 +9,29 @@ https://bugzilla.mozilla.org/show_bug.cg
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=391777">Mozilla Bug 391777</a>
 <p id="display"></p>
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 391777 **/
-var arg = {};
-arg.testVal = "foo";
-var result = window.showModalDialog("javascript:window.returnValue = window.dialogArguments.testVal; window.close(); 'This window should close on its own.';", arg);
-ok(true, "We should get here without user interaction");
-is(result, "foo", "Unexpected result from showModalDialog");
+SimpleTest.waitForExplicitFinish();
+
+SpecialPowers.pushPrefEnv({ set: [[ "dom.disable_window_showModalDialog", false ]] }, doTest);
+async function doTest() {
+  let iframe = document.createElement("iframe");
+  document.body.appendChild(iframe);
+  await new Promise(resolve => {
+    iframe.addEventListener("load", resolve);
+  });
+  window.showModalDialog = iframe.contentWindow.showModalDialog;
+  var arg = {};
+  arg.testVal = "foo";
+  var result = window.showModalDialog("javascript:window.returnValue = window.dialogArguments.testVal; window.close(); 'This window should close on its own.';", arg);
+  ok(true, "We should get here without user interaction");
+  is(result, "foo", "Unexpected result from showModalDialog");
+  SimpleTest.finish();
+}
 
 </script>
 </body>
 </html>
--- a/dom/html/test/test_iframe_sandbox_modal.html
+++ b/dom/html/test/test_iframe_sandbox_modal.html
@@ -104,17 +104,19 @@ function doTest() {
 
   // passes if good
   // 5) Test that a sandboxed iframe with "allow-popups" can open a new window using window.ShowModalDialog.
   // This is done via file_iframe_sandbox_j_if3.html which is sandboxed with "allow-popups allow-scripts
   // allow-same-origin". The window it attempts to open calls window.opener.ok(true, ...) and
   // file_iframe_j_if3.html has an ok() function that calls window.parent.ok_wrapper.
 }
 
-addLoadEvent(doTest);
+let loaded = new Promise(resolve => { addLoadEvent(resolve) });
+let prefSet = SpecialPowers.pushPrefEnv({ set: [[ "dom.disable_window_showModalDialog", false ]] });
+Promise.all([ loaded, prefSet ]).then(doTest);
 </script>
 
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=766282">Mozilla Bug 766282</a> - implement allow-popups directive for iframe sandbox
 <p id="display"></p>
 <div id="content">
 <iframe sandbox="allow-scripts allow-popups allow-modals allow-same-origin allow-forms allow-top-navigation" id="if_1" src="file_iframe_sandbox_j_if1.html" height="10" width="10"></iframe>
 <iframe sandbox="allow-scripts allow-popups allow-modals allow-same-origin" id="if_2" src="file_iframe_sandbox_j_if2.html" height="10" width="10"></iframe>
--- a/dom/tests/mochitest/bugs/mochitest.ini
+++ b/dom/tests/mochitest/bugs/mochitest.ini
@@ -54,17 +54,17 @@ support-files =
 [test_bug159849.html]
 [test_bug289714.html]
 [test_bug260264.html]
 skip-if = toolkit == 'android'
 [test_bug260264_nested.html]
 [test_bug265203.html]
 [test_bug291377.html]
 [test_bug291653.html]
-skip-if = toolkit == 'android' #TIMED_OUT
+skip-if = e10s || toolkit == 'android' #TIMED_OUT
 [test_bug304459.html]
 [test_bug308856.html]
 [test_bug327891.html]
 [test_bug333983.html]
 [test_bug335976.xhtml]
 [test_bug342448.html]
 [test_bug345521.html]
 [test_bug346659.html]
@@ -77,38 +77,38 @@ skip-if = toolkit == 'android' #TIMED_OU
 [test_bug389366.html]
 [test_bug38959.html]
 [test_bug393974.html]
 [test_bug394769.html]
 [test_bug396843.html]
 [test_bug400204.html]
 [test_bug404748.html]
 [test_bug406375.html]
-skip-if = toolkit == 'android'
+skip-if = e10s || toolkit == 'android'
 [test_bug414291.html]
 tags = openwindow
 [test_bug427744.html]
 skip-if = toolkit == 'android'
 [test_bug42976.html]
 [test_bug430276.html]
 [test_bug437361.html]
-skip-if = toolkit == 'android'
+skip-if = e10s || toolkit == 'android'
 [test_bug440572.html]
 [test_bug456151.html]
 [test_bug458091.html]
 [test_bug459848.html]
 [test_bug465263.html]
 [test_bug479143.html]
-skip-if = toolkit == 'android'
+skip-if = e10s || toolkit == 'android'
 [test_bug484775.html]
 [test_bug492925.html]
 [test_bug49312.html]
 [test_bug495219.html]
 [test_bug504862.html]
-skip-if = toolkit == 'android' #RANDOM
+skip-if = e10s || toolkit == 'android' #RANDOM
 [test_bug529328.html]
 [test_bug531176.html]
 [test_bug531542.html]
 [test_bug534149.html]
 [test_bug541530.html]
 [test_bug545314.html]
 [test_bug548828.html]
 [test_bug558973.html]
--- a/dom/tests/mochitest/bugs/test_bug291653.html
+++ b/dom/tests/mochitest/bugs/test_bug291653.html
@@ -20,37 +20,31 @@ https://bugzilla.mozilla.org/show_bug.cg
 /** Test for Bug 291653 **/
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("untriaged");
 
 var secondListenerDidRun = false;
 
 var w;
 function start() {
-  if ("showModalDialog" in window) {
-    w = window.open("file_bug291653.html", "foo", "width=300,height=300");
-  } else {
-    // window.showModalDialog doesn't exist in e10s mode, nothing to do in this test.
-    ok(true, "nothing to do in e10s mode");
-    SimpleTest.finish();
-  }
+  w = window.open("file_bug291653.html", "foo", "width=300,height=300");
 }
 
 function closeTest() {
   w.close();
   setTimeout("finish()", 500);
 }
 
 function finish() {
   ok(!secondListenerDidRun, "Shouldn't have run second listener!");
   SimpleTest.finish();
 }
 
 function end() {
   setTimeout("closeTest()", 500);
 }
 
-start();
+SpecialPowers.pushPrefEnv({ set: [[ "dom.disable_window_showModalDialog", false ]] }, start);
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/bugs/test_bug406375.html
+++ b/dom/tests/mochitest/bugs/test_bug406375.html
@@ -17,20 +17,26 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 406375 **/
 
 
 SimpleTest.waitForExplicitFinish();
 
-function runTest() {
-  if ("showModalDialog" in window) {
-    window.showModalDialog("file_bug406375.html");
-  }
+async function runTest() {
+  await SpecialPowers.pushPrefEnv({ set: [[ "dom.disable_window_showModalDialog", false ]] });
+  let iframe = document.createElement("iframe");
+  document.body.appendChild(iframe);
+  await new Promise(resolve => {
+    iframe.addEventListener("load", resolve);
+  });
+  window.showModalDialog = iframe.contentWindow.showModalDialog;
+
+  window.showModalDialog("file_bug406375.html");
   ok(true, "This test should not hang");
 
   SimpleTest.finish();
 }
 
 </script>
 </pre>
 </body>
--- a/dom/tests/mochitest/bugs/test_bug414291.html
+++ b/dom/tests/mochitest/bugs/test_bug414291.html
@@ -8,28 +8,40 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=414291">Mozilla Bug 414291</a>
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 414291 **/
+SimpleTest.waitForExplicitFinish();
 
 var result1 = 0;
 var result2 = 0;
 var result3 = 0;
 
 window.open("file1_bug414291.html", "w1");
 is(result1, 0, "window should not be opened either as modal or loaded synchronously.");
 
 window.open("file2_bug414291.html", "w2", "modal=yes");
 is(result2, 0, "window should not be opened either as modal or data loaded synchronously.");
 
-if (window.showModalDialog) {
-  result3 = window.showModalDialog("file3_bug414291.html");
-  is(result3, 3, "window should be opened as modal.");
+SpecialPowers.pushPrefEnv({ set: [[ "dom.disable_window_showModalDialog", false ]] }, runModalTest);
+async function runModalTest() {
+  let iframe = document.createElement("iframe");
+  document.body.appendChild(iframe);
+  await new Promise(resolve => {
+    iframe.addEventListener("load", resolve);
+  });
+  window.showModalDialog = iframe.contentWindow.showModalDialog;
+
+  if (window.showModalDialog) {
+    result3 = window.showModalDialog("file3_bug414291.html");
+    is(result3, 3, "window should be opened as modal.");
+  }
+  SimpleTest.finish();
 }
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/bugs/test_bug437361.html
+++ b/dom/tests/mochitest/bugs/test_bug437361.html
@@ -27,42 +27,51 @@ https://bugzilla.mozilla.org/show_bug.cg
   }
 
   function testOtherExceptionsNotTrapped() {
     is(false, SpecialPowers.getBoolPref("dom.disable_open_during_load"), "mozprefs sanity check");
     window.showModalDialog('about:config'); // forbidden by SecurityCheckURL
   }
 
   function test(disableOpen, exceptionExpected, testFn, errorMsg) {
-    if ("showModalDialog" in window) {
-      var oldPrefVal = SpecialPowers.getBoolPref("dom.disable_open_during_load");
-      try {
-        SpecialPowers.setBoolPref("dom.disable_open_during_load", disableOpen);
-        testFn();
-        ok(!exceptionExpected, errorMsg);
-      } catch (_) {
-        ok(exceptionExpected, errorMsg);
-      }
-      finally {
-        SpecialPowers.setBoolPref("dom.disable_open_during_load", oldPrefVal);
-      }
-    } else {
-      ok(true, "nothing to do in e10s mode");
+    var oldPrefVal = SpecialPowers.getBoolPref("dom.disable_open_during_load");
+    try {
+      SpecialPowers.setBoolPref("dom.disable_open_during_load", disableOpen);
+      testFn();
+      ok(!exceptionExpected, errorMsg);
+    } catch (_) {
+      ok(exceptionExpected, errorMsg);
+    }
+    finally {
+      SpecialPowers.setBoolPref("dom.disable_open_during_load", oldPrefVal);
     }
   }
 
-  test(true, false, testModalDialogBlockedCleanly,
-       "Blocked showModalDialog caused an exception.");
-       
-  test(false, false, testModalDialogAllowed,
-       "showModalDialog was blocked even though dom.disable_open_during_load was false.");
+  SimpleTest.waitForExplicitFinish();
+
+  SpecialPowers.pushPrefEnv({ set: [[ "dom.disable_window_showModalDialog", false ]] }, doTest);
+  async function doTest() {
+    let iframe = document.createElement("iframe");
+    document.body.appendChild(iframe);
+    await new Promise(resolve => {
+      iframe.addEventListener("load", resolve);
+    });
+    window.showModalDialog = iframe.contentWindow.showModalDialog;
 
-  test(false, true, testOtherExceptionsNotTrapped,
-       "Incorrectly suppressed insecure showModalDialog exception.");
+    test(true, false, testModalDialogBlockedCleanly,
+         "Blocked showModalDialog caused an exception.");
+
+    test(false, false, testModalDialogAllowed,
+         "showModalDialog was blocked even though dom.disable_open_during_load was false.");
 
+    test(false, true, testOtherExceptionsNotTrapped,
+         "Incorrectly suppressed insecure showModalDialog exception.");
+
+    SimpleTest.finish();
+  }
   </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=437361">Mozilla Bug 437361</a>
 <p id="display"></p>
 <div id="content" style="display: none"> 
 </div>
 <pre id="test">
--- a/dom/tests/mochitest/bugs/test_bug479143.html
+++ b/dom/tests/mochitest/bugs/test_bug479143.html
@@ -13,32 +13,39 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content" style="display: none"></div>
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
   SimpleTest.waitForExplicitFinish();
 
-  setTimeout(function() {
-    if ("showModalDialog" in window) {
-      var interval = setInterval(function() { var i = 0; i++; }, 10);
+  SpecialPowers.pushPrefEnv({ set: [[ "dom.disable_window_showModalDialog", false ]] }, doTest);
+  async function doTest() {
+    await SpecialPowers.pushPrefEnv({ set: [[ "dom.disable_window_showModalDialog", false ]] });
+    let iframe = document.createElement("iframe");
+    document.body.appendChild(iframe);
+    await new Promise(resolve => {
+      iframe.addEventListener("load", resolve);
+    });
+    window.showModalDialog = iframe.contentWindow.showModalDialog;
 
-      var xhr = new XMLHttpRequest();
-      xhr.open("GET", "test_bug479143.html", false);
-      xhr.send(null);
+    var interval = setInterval(function() { var i = 0; i++; }, 10);
+
+    var xhr = new XMLHttpRequest();
+    xhr.open("GET", "test_bug479143.html", false);
+    xhr.send(null);
 
-      window.showModalDialog("javascript:" +
-                             "setTimeout(function() { window.close(); }, 1000);",
-                             null);
+    window.showModalDialog("javascript:" +
+                           "setTimeout(function() { window.close(); }, 1000);",
+                           null);
 
-      clearInterval(interval);
-    }
+    clearInterval(interval);
 
     ok(true, "did not crash");
 
     SimpleTest.finish();
-  }, 0);
+  }
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/bugs/test_bug504862.html
+++ b/dom/tests/mochitest/bugs/test_bug504862.html
@@ -14,32 +14,36 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 /** Test for Bug 504862 **/
 SimpleTest.waitForExplicitFinish();
 function onMsgRcv(event)
 {
   is(event.data, "args: undefined", "Unexpected cross origin dialog arguments.");
 }
 
-function runTest() {
-  if ("showModalDialog" in window) {
-    window.addEventListener("message", onMsgRcv);
+async function runTest() {
+  await SpecialPowers.pushPrefEnv({ set: [[ "dom.disable_window_showModalDialog", false ]] });
+  let iframe = document.createElement("iframe");
+  document.body.appendChild(iframe);
+  await new Promise(resolve => {
+    iframe.addEventListener("load", resolve);
+  });
+  window.showModalDialog = iframe.contentWindow.showModalDialog;
 
-    var result = window.showModalDialog("file_bug504862.html", "my args");
-    // NB: We used to clear returnValue on each navigation, but now we do a
-    // security check on access, so we can safely make returnValue live on
-    // the browsing context, per spec.
-    is(result, 3, "window sees previous dialog documents return value.");
+  window.addEventListener("message", onMsgRcv);
 
-    result = window.showModalDialog("http://test1.example.com/tests/dom/tests/mochitest/bugs/file_bug504862.html", "my args");
+  var result = window.showModalDialog("file_bug504862.html", "my args");
+  // NB: We used to clear returnValue on each navigation, but now we do a
+  // security check on access, so we can safely make returnValue live on
+  // the browsing context, per spec.
+  is(result, 3, "window sees previous dialog documents return value.");
 
-    is(result, undefined, "Able to see return value from cross origin dialog.");
-  } else {
-    ok(true, "nothing to do in e10s mode");
-  }
+  result = window.showModalDialog("http://test1.example.com/tests/dom/tests/mochitest/bugs/file_bug504862.html", "my args");
+
+  is(result, undefined, "Able to see return value from cross origin dialog.");
 
   SimpleTest.finish();
 }
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/bugs/test_bug61098.html
+++ b/dom/tests/mochitest/bugs/test_bug61098.html
@@ -215,21 +215,22 @@ function registerMockPromptService()
   mockPromptServiceRegisterer.register();
   mockPromptFactoryRegisterer.register();
 };
 
 var expectedState;
 
 function runtests()
 {
-  SpecialPowers.pushPrefEnv({'set': [["dom.successive_dialog_time_limit", 3]]},
+  SpecialPowers.pushPrefEnv({'set': [["dom.successive_dialog_time_limit", 3],
+                                     ["dom.disable_window_showModalDialog", false]]},
                             runtestsInner);
 }
 
-function runtestsInner()
+async function runtestsInner()
 {
   registerMockPromptService();
 
   // Test that alert() works normally and then gets blocked on the
   // second call.
   w = window.open();
   w.alert("alert message 1");
   is (promptState.method, "alert", "Wrong prompt method called");
@@ -300,16 +301,23 @@ function runtestsInner()
   } catch(e) {
     is(e.name, "NS_ERROR_NOT_AVAILABLE", "Wrong exception");
   }
 
   is (promptState, void(0), "Wrong prompt state after blocked prompt()");
 
   w.close();
 
+  let iframe = document.createElement("iframe");
+  document.body.appendChild(iframe);
+  await new Promise(resolve => {
+    iframe.addEventListener("load", resolve);
+  });
+  window.showModalDialog = iframe.contentWindow.showModalDialog;
+
   // Test that showModalDialog() works normally and then gets blocked
   // on the second call.
   if (window.showModalDialog) {
     w = window.open();
     w.showModalDialog("data:text/html,%3Cscript>window.close();%3C/script>")
     is (promptState, void(0), "Wrong prompt state");
 
     try {
--- a/dom/tests/mochitest/general/mochitest.ini
+++ b/dom/tests/mochitest/general/mochitest.ini
@@ -119,18 +119,17 @@ support-files = test_offsets.js
 [test_pointerPreserves3DClip.html]
 [test_resource_timing.html]
 [test_resource_timing_cross_origin.html]
 [test_resource_timing_frameset.html]
 [test_selectevents.html]
 skip-if = toolkit == 'android' # bug 1230232 - Mouse doesn't select in the same way
 [test_showModalDialog.html]
 skip-if = e10s || toolkit == 'android' #Don't run modal tests on Android
-[test_showModalDialog_e10s.html]
-run-if = e10s
+[test_showModalDialog_removed.html]
 [test_storagePermissionsAccept.html]
 [test_storagePermissionsLimitForeign.html]
 [test_storagePermissionsReject.html]
 [test_storagePermissionsRejectForeign.html]
 [test_stylesheetPI.html]
 [test_vibrator.html]
 [test_WebKitCSSMatrix.html]
 [test_windowedhistoryframes.html]
--- a/dom/tests/mochitest/general/test_showModalDialog.html
+++ b/dom/tests/mochitest/general/test_showModalDialog.html
@@ -19,37 +19,50 @@ https://bugzilla.mozilla.org/show_bug.cg
     is(evt.data, 'dosetup', "message from modal window is correct");
     var win = SpecialPowers.wrap(evt.source);
     win.wrappedJSObject.SpecialPowers = SpecialPowers;
     SpecialPowers.setWrapped(win.wrappedJSObject, 'is', SpecialPowers.wrap(is));
     SpecialPowers.setWrapped(win.wrappedJSObject, 'ok', SpecialPowers.wrap(ok));
     win.wrappedJSObject.go();
   };
 
-  var someObj = { foo: 42, bar: "hi"};
-  var xurl = location.toString()
-                     .replace('mochi.test:8888', 'example.org')
-                     .replace('test_showModal', 'file_showModal');
-  if (xurl.indexOf('?') != -1)
-    xurl = xurl.substring(0, xurl.indexOf('?'));
-  is(showModalDialog('file_showModalDialog.html'), "rv: undefined");
-  is(showModalDialog(xurl), undefined);
-  is(showModalDialog('file_showModalDialog.html', 3), "rv: 3");
-  is(showModalDialog(xurl, 3), undefined);
-  is(showModalDialog('file_showModalDialog.html', someObj), "rv: " + someObj);
-  is(showModalDialog(xurl, someObj), undefined);
+  SimpleTest.waitForExplicitFinish();
+
+  SpecialPowers.pushPrefEnv({ set: [[ "dom.disable_window_showModalDialog", false ]] }, doTest);
+  async function doTest() {
+    let iframe = document.createElement("iframe");
+    document.body.appendChild(iframe);
+    await new Promise(resolve => {
+      iframe.addEventListener("load", resolve);
+    });
+    window.showModalDialog = iframe.contentWindow.showModalDialog;
 
-  // Test sequential navigations.
-  is(showModalDialog('file_showModalDialog.html?http://mochi.test:8888', 4),
-                     'rv: 4');
-  is(showModalDialog('file_showModalDialog.html?http://example.com', 4), undefined);
-  is(showModalDialog('file_showModalDialog.html?http://example.com,http://mochi.test:8888', 4), 'rv: 4');
+    var someObj = { foo: 42, bar: "hi"};
+    var xurl = location.toString()
+                       .replace('mochi.test:8888', 'example.org')
+                       .replace('test_showModal', 'file_showModal');
+    if (xurl.indexOf('?') != -1)
+      xurl = xurl.substring(0, xurl.indexOf('?'));
+    is(window.showModalDialog('file_showModalDialog.html'), "rv: undefined");
+    is(window.showModalDialog(xurl), undefined);
+    is(window.showModalDialog('file_showModalDialog.html', 3), "rv: 3");
+    is(window.showModalDialog(xurl, 3), undefined);
+    is(window.showModalDialog('file_showModalDialog.html', someObj), "rv: " + someObj);
+    is(window.showModalDialog(xurl, someObj), undefined);
 
-  // This test used to assert after gc. Make sure it doesn't.
-  SpecialPowers.gc();
+    // Test sequential navigations.
+    is(window.showModalDialog('file_showModalDialog.html?http://mochi.test:8888', 4),
+                       'rv: 4');
+    is(window.showModalDialog('file_showModalDialog.html?http://example.com', 4), undefined);
+    is(window.showModalDialog('file_showModalDialog.html?http://example.com,http://mochi.test:8888', 4), 'rv: 4');
+
+    // This test used to assert after gc. Make sure it doesn't.
+    SpecialPowers.gc();
+    SimpleTest.finish();
+  }
 
   </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=862918">Mozilla Bug 862918</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 
deleted file mode 100644
--- a/dom/tests/mochitest/general/test_showModalDialog_e10s.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1077002
--->
-<head>
-  <title>Test for showModalDialog unavailability in e10s</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank"
-    href="https://bugzilla.mozilla.org/show_bug.cgi?id=1077002">Mozilla Bug 1077002</a>
-<p id="display"></p>
-<div id="content">
-  <iframe id="frame" style="height:100px; width:100px; border:0"></iframe>
-  <div id="status" style="display: none"></div>
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-/** Test for showModalDialog unavailability in e10s **/
-
-// NB: This test runs in e10s only. In e10s showModalDialog should not
-// exist.
-ok(!window.showModalDialog, "showModalDialog should not exist");
-
-</script>
-</pre>
-</body>
-</html>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/general/test_showModalDialog_removed.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1077002
+-->
+<head>
+  <title>Test for showModalDialog unavailability in e10s</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank"
+    href="https://bugzilla.mozilla.org/show_bug.cgi?id=1077002">Mozilla Bug 1077002</a>
+<p id="display"></p>
+<div id="content">
+  <iframe id="frame" style="height:100px; width:100px; border:0"></iframe>
+  <div id="status" style="display: none"></div>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for showModalDialog unavailability in Firefox **/
+
+// NB: This test runs in e10s only. In e10s showModalDialog should not
+// exist.
+ok(!window.showModalDialog, "showModalDialog should not exist");
+
+</script>
+</pre>
+</body>
+</html>