diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
index 950820b82f70..fe6c250b2d69 100644
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -10119,12 +10119,8 @@ nsGlobalWindow::ShowModalDialog(JSContext* aCx, const nsAString& aUrl,
JS::Rooted result(aCx);
if (retVal) {
- JS::Rooted global(aCx, JS::CurrentGlobalOrNull(aCx));
- if (!global) {
- global = FastGetGlobalJSObject();
- }
aError = nsContentUtils::XPConnect()->VariantToJS(aCx,
- global,
+ FastGetGlobalJSObject(),
retVal, aRetval);
} else {
aRetval.setNull();
diff --git a/dom/base/test/test_dialogArguments.html b/dom/base/test/test_dialogArguments.html
index 682f61e0b294..70a091d0005e 100644
--- a/dom/base/test/test_dialogArguments.html
+++ b/dom/base/test/test_dialogArguments.html
@@ -16,16 +16,8 @@
*/
SimpleTest.waitForExplicitFinish();
-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; \
+function openModal() {
+ showModalDialog("javascript:opener.winRef = window; \
window.opener.setTimeout(\'winRef.dialogArguments;\', 0);\
window.close();");
diff --git a/dom/base/test/test_mutationobservers.html b/dom/base/test/test_mutationobservers.html
index 6a5b43861075..f26de3728a63 100644
--- a/dom/base/test/test_mutationobservers.html
+++ b/dom/base/test/test_mutationobservers.html
@@ -487,14 +487,7 @@ function testSyncXHR2() {
then(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;
+function testModalDialog() {
var didHandleCallback = false;
div.innerHTML = "12";
m = new M(function(records, observer) {
diff --git a/dom/html/test/test_bug391777.html b/dom/html/test/test_bug391777.html
index 10f230684736..aa01a45de73f 100644
--- a/dom/html/test/test_bug391777.html
+++ b/dom/html/test/test_bug391777.html
@@ -14,23 +14,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=391777
diff --git a/dom/tests/mochitest/bugs/mochitest.ini b/dom/tests/mochitest/bugs/mochitest.ini
index d8256968e887..544376d7bec9 100644
--- a/dom/tests/mochitest/bugs/mochitest.ini
+++ b/dom/tests/mochitest/bugs/mochitest.ini
@@ -59,7 +59,7 @@ skip-if = toolkit == 'android'
[test_bug265203.html]
[test_bug291377.html]
[test_bug291653.html]
-skip-if = e10s || toolkit == 'android' #TIMED_OUT
+skip-if = toolkit == 'android' #TIMED_OUT
[test_bug304459.html]
[test_bug308856.html]
[test_bug327891.html]
@@ -82,7 +82,7 @@ skip-if = toolkit == 'android' #TIMED_OUT
[test_bug400204.html]
[test_bug404748.html]
[test_bug406375.html]
-skip-if = e10s || toolkit == 'android'
+skip-if = toolkit == 'android'
[test_bug414291.html]
tags = openwindow
[test_bug427744.html]
@@ -90,20 +90,20 @@ skip-if = toolkit == 'android'
[test_bug42976.html]
[test_bug430276.html]
[test_bug437361.html]
-skip-if = e10s || toolkit == 'android'
+skip-if = toolkit == 'android'
[test_bug440572.html]
[test_bug456151.html]
[test_bug458091.html]
[test_bug459848.html]
[test_bug465263.html]
[test_bug479143.html]
-skip-if = e10s || toolkit == 'android'
+skip-if = toolkit == 'android'
[test_bug484775.html]
[test_bug492925.html]
[test_bug49312.html]
[test_bug495219.html]
[test_bug504862.html]
-skip-if = e10s || toolkit == 'android' #RANDOM
+skip-if = toolkit == 'android' #RANDOM
[test_bug529328.html]
[test_bug531176.html]
[test_bug531542.html]
diff --git a/dom/tests/mochitest/bugs/test_bug291653.html b/dom/tests/mochitest/bugs/test_bug291653.html
index 0237c6bff4a8..541ceab93a67 100644
--- a/dom/tests/mochitest/bugs/test_bug291653.html
+++ b/dom/tests/mochitest/bugs/test_bug291653.html
@@ -25,7 +25,13 @@ var secondListenerDidRun = false;
var w;
function start() {
- w = window.open("file_bug291653.html", "foo", "width=300,height=300");
+ 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();
+ }
}
function closeTest() {
@@ -42,7 +48,7 @@ function end() {
setTimeout("closeTest()", 500);
}
-SpecialPowers.pushPrefEnv({ set: [[ "dom.disable_window_showModalDialog", false ]] }, start);
+start();
diff --git a/dom/tests/mochitest/bugs/test_bug406375.html b/dom/tests/mochitest/bugs/test_bug406375.html
index a2e41f368603..2cd459ffa497 100644
--- a/dom/tests/mochitest/bugs/test_bug406375.html
+++ b/dom/tests/mochitest/bugs/test_bug406375.html
@@ -22,16 +22,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=406375
SimpleTest.waitForExplicitFinish();
-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");
+function runTest() {
+ if ("showModalDialog" in window) {
+ window.showModalDialog("file_bug406375.html");
+ }
ok(true, "This test should not hang");
SimpleTest.finish();
diff --git a/dom/tests/mochitest/bugs/test_bug414291.html b/dom/tests/mochitest/bugs/test_bug414291.html
index e50038216a95..119c1d086bec 100644
--- a/dom/tests/mochitest/bugs/test_bug414291.html
+++ b/dom/tests/mochitest/bugs/test_bug414291.html
@@ -13,7 +13,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=414291
diff --git a/dom/tests/mochitest/bugs/test_bug437361.html b/dom/tests/mochitest/bugs/test_bug437361.html
index c1ed6135562e..1277f0ff4695 100644
--- a/dom/tests/mochitest/bugs/test_bug437361.html
+++ b/dom/tests/mochitest/bugs/test_bug437361.html
@@ -32,41 +32,32 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=437361
}
function test(disableOpen, exceptionExpected, testFn, errorMsg) {
- 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);
+ 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");
}
}
- SimpleTest.waitForExplicitFinish();
+ 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.");
- 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();
- }
diff --git a/dom/tests/mochitest/bugs/test_bug479143.html b/dom/tests/mochitest/bugs/test_bug479143.html
index 6227259ed09a..03db4ddea4a3 100644
--- a/dom/tests/mochitest/bugs/test_bug479143.html
+++ b/dom/tests/mochitest/bugs/test_bug479143.html
@@ -18,32 +18,25 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479143
SimpleTest.waitForExplicitFinish();
- 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;
+ setTimeout(function() {
+ if ("showModalDialog" in window) {
+ var interval = setInterval(function() { var i = 0; i++; }, 10);
- var interval = setInterval(function() { var i = 0; i++; }, 10);
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "test_bug479143.html", false);
+ xhr.send(null);
- 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);
diff --git a/dom/tests/mochitest/bugs/test_bug504862.html b/dom/tests/mochitest/bugs/test_bug504862.html
index 009c80ae3928..947d18171fcf 100644
--- a/dom/tests/mochitest/bugs/test_bug504862.html
+++ b/dom/tests/mochitest/bugs/test_bug504862.html
@@ -19,26 +19,22 @@ function onMsgRcv(event)
is(event.data, "args: undefined", "Unexpected cross origin dialog arguments.");
}
-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;
+function runTest() {
+ if ("showModalDialog" in window) {
+ window.addEventListener("message", onMsgRcv);
- window.addEventListener("message", onMsgRcv);
+ 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.");
- 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.");
+ result = window.showModalDialog("http://test1.example.com/tests/dom/tests/mochitest/bugs/file_bug504862.html", "my args");
- 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.");
+ is(result, undefined, "Able to see return value from cross origin dialog.");
+ } else {
+ ok(true, "nothing to do in e10s mode");
+ }
SimpleTest.finish();
}
diff --git a/dom/tests/mochitest/bugs/test_bug61098.html b/dom/tests/mochitest/bugs/test_bug61098.html
index f28b5fe2c462..6543f59c36fe 100644
--- a/dom/tests/mochitest/bugs/test_bug61098.html
+++ b/dom/tests/mochitest/bugs/test_bug61098.html
@@ -220,12 +220,11 @@ var expectedState;
function runtests()
{
- SpecialPowers.pushPrefEnv({'set': [["dom.successive_dialog_time_limit", 3],
- ["dom.disable_window_showModalDialog", false]]},
+ SpecialPowers.pushPrefEnv({'set': [["dom.successive_dialog_time_limit", 3]]},
runtestsInner);
}
-async function runtestsInner()
+function runtestsInner()
{
registerMockPromptService();
@@ -306,13 +305,6 @@ async function runtestsInner()
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) {
diff --git a/dom/tests/mochitest/general/mochitest.ini b/dom/tests/mochitest/general/mochitest.ini
index a0bec29bc8af..4e5f6bf6c1b8 100644
--- a/dom/tests/mochitest/general/mochitest.ini
+++ b/dom/tests/mochitest/general/mochitest.ini
@@ -124,7 +124,8 @@ support-files = test_offsets.js
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_removed.html]
+[test_showModalDialog_e10s.html]
+run-if = e10s
[test_storagePermissionsAccept.html]
[test_storagePermissionsLimitForeign.html]
[test_storagePermissionsReject.html]
diff --git a/dom/tests/mochitest/general/test_showModalDialog.html b/dom/tests/mochitest/general/test_showModalDialog.html
index 46126af5ab31..511c79e639de 100644
--- a/dom/tests/mochitest/general/test_showModalDialog.html
+++ b/dom/tests/mochitest/general/test_showModalDialog.html
@@ -24,40 +24,27 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=862918
win.wrappedJSObject.go();
};
- SimpleTest.waitForExplicitFinish();
+ 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);
- 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);
-
- // 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();
- }
+ // This test used to assert after gc. Make sure it doesn't.
+ SpecialPowers.gc();
diff --git a/dom/tests/mochitest/general/test_showModalDialog_removed.html b/dom/tests/mochitest/general/test_showModalDialog_e10s.html
similarity index 94%
rename from dom/tests/mochitest/general/test_showModalDialog_removed.html
rename to dom/tests/mochitest/general/test_showModalDialog_e10s.html
index 6222f5eadfb4..5a6f3d7f33f6 100644
--- a/dom/tests/mochitest/general/test_showModalDialog_removed.html
+++ b/dom/tests/mochitest/general/test_showModalDialog_e10s.html
@@ -20,7 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1077002