Issue #1366 - Completely remove showModalDialog

This commit is contained in:
Gaming4JC 2020-01-21 20:00:48 -05:00 committed by Roy Tam
commit 8d600c51ed
38 changed files with 14 additions and 1313 deletions

View file

@ -1,28 +0,0 @@
<html>
<head>
<script>
<!--
function listener1() {
window.showModalDialog("data:text/html,<script>var maintest = opener.opener; opener.location = 'data:text/html,test'; maintest.end(); window.close();</script>");
}
function listener2() {
opener.secondListenerDidRun = true;
}
window.addEventListener("foo", listener1);
window.addEventListener("foo", listener2);
function fireFoo() {
var e = document.createEvent("Events");
e.initEvent("foo", true, true);
window.dispatchEvent(e);
}
//-->
</script>
</head>
<body onload="setTimeout(fireFoo, 0)">
Test for bug 291653
</body>
</html>

View file

@ -1,22 +0,0 @@
<html>
<body>
<script>
window.returnValue = 3;
if (location.toString().match(/^http:\/\/mochi.test:8888/)) {
// Test that we got the right arguments.
opener.is(window.dialogArguments, "my args",
"dialog did not get the right arguments.");
// Load a different url, and test that it sees the arguments (since it's same origin).
window.location="data:text/html,<html><body onload=\"opener.is(window.dialogArguments, 'my args', 'subsequent dialog document did not get the right arguments.'); close();\">';";
} else {
// Post a message containing our arguments to the opener to test
// that this cross origing dialog does *not* see the passed in
// arguments.
opener.postMessage("args: " + window.dialogArguments,
"http://mochi.test:8888");
close();
}
</script>

View file

@ -10,9 +10,6 @@ support-files =
child_bug260264.html
devicemotion_inner.html
devicemotion_outer.html
file_bug291653.html
file_bug406375.html
file_bug504862.html
file_bug593174_1.html
file_bug593174_2.html
file_bug809290_b1.html
@ -45,7 +42,6 @@ skip-if = toolkit == 'android'
[test_bug260264_nested.html]
[test_bug265203.html]
[test_bug291377.html]
[test_bug291653.html]
skip-if = toolkit == 'android' #TIMED_OUT
[test_bug304459.html]
[test_bug308856.html]
@ -67,28 +63,21 @@ skip-if = toolkit == 'android' #TIMED_OUT
[test_bug396843.html]
[test_bug400204.html]
[test_bug404748.html]
[test_bug406375.html]
skip-if = 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'
[test_bug440572.html]
[test_bug456151.html]
[test_bug458091.html]
[test_bug459848.html]
[test_bug465263.html]
[test_bug479143.html]
skip-if = toolkit == 'android'
[test_bug484775.html]
[test_bug492925.html]
[test_bug49312.html]
[test_bug495219.html]
[test_bug504862.html]
skip-if = toolkit == 'android' #RANDOM
[test_bug529328.html]
[test_bug531176.html]
@ -126,7 +115,6 @@ skip-if = toolkit == 'android'
[test_bug698061.html]
[test_bug698551.html]
[test_bug707749.html]
[test_bug735237.html]
[test_bug739038.html]
[test_bug740811.html]
[test_bug743615.html]

View file

@ -1,56 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=291653
-->
<head>
<title>Test for Bug 291653</title>
<script type="application/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=291653">Mozilla Bug 291653</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** 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();
}
}
function closeTest() {
w.setTimeout("close()", 0);
setTimeout("finish()", 500);
}
function finish() {
ok(!secondListenerDidRun, "Shouldn't have run second listener!");
SimpleTest.finish();
}
function end() {
setTimeout("closeTest()", 500);
}
start();
</script>
</pre>
</body>
</html>

View file

@ -1,37 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=406375
-->
<head>
<title>Test for Bug 406375</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="runTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=406375">Mozilla Bug 406375</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 406375 **/
SimpleTest.waitForExplicitFinish();
function runTest() {
if ("showModalDialog" in window) {
window.showModalDialog("file_bug406375.html");
}
ok(true, "This test should not hang");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

View file

@ -16,7 +16,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=414291
var result1 = 0;
var result2 = 0;
var result3 = 0;
window.open("data:text/html,<html><body onload='close(); opener.result1 = 1;'>", "w1");
is(result1, 0, "window should not be opened either as modal or loaded synchronously.");
@ -24,11 +23,6 @@ is(result1, 0, "window should not be opened either as modal or loaded synchronou
window.open("data:text/html,<html><body onload='close(); opener.result2 = 2;'>", "w2", "modal=yes");
is(result2, 0, "window should not be opened either as modal or data loaded synchronously.");
if (window.showModalDialog) {
result3 = window.showModalDialog("data:text/html,<html><body onload='close(); returnValue = 3;'>");
is(result3, 3, "window should be opened as modal.");
}
</script>
</pre>
</body>

View file

@ -1,72 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=437361
-->
<head>
<title>Test for Bug 437361</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script class="testbody" type="text/javascript">
/** Test for Bug 437361 **/
function testModalDialogBlockedCleanly() {
is(true, SpecialPowers.getBoolPref("dom.disable_open_during_load"), "mozprefs sanity check");
var rv = window.showModalDialog( // should be blocked without exception
"data:text/html,<html><body onload='close(); returnValue = 1;' /></html>");
is(rv, null, "Modal dialog opened unexpectedly.");
}
function testModalDialogAllowed() {
is(false, SpecialPowers.getBoolPref("dom.disable_open_during_load"), "mozprefs sanity check");
var rv = window.showModalDialog( // should not be blocked this time
"data:text/html,<html><body onload='close(); returnValue = 1;' /></html>");
is(rv, 1, "Problem with modal dialog returnValue.");
}
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");
}
}
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.");
</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">
</pre>
</body>
</html>

View file

@ -1,44 +0,0 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=479143
-->
<head>
<title>Test for Bug 411103</title>
<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=479143">Mozilla Bug 479143</a>
<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);
var xhr = new XMLHttpRequest();
xhr.open("GET", "test_bug479143.html", false);
xhr.send(null);
window.showModalDialog("javascript:" +
"setTimeout(function() { window.close(); }, 1000);",
null);
clearInterval(interval);
}
ok(true, "did not crash");
SimpleTest.finish();
}, 0);
</script>
</pre>
</body>
</html>

View file

@ -1,45 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=504862
-->
<head>
<title>Test for Bug 504862</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=504862">Mozilla Bug 504862</a>
<script class="testbody" type="text/javascript">
/** 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, false);
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");
is(result, undefined, "Able to see return value from cross origin dialog.");
} else {
ok(true, "nothing to do in e10s mode");
}
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

View file

@ -306,28 +306,6 @@ function runtestsInner()
w.close();
// 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 {
w.showModalDialog("data:text/html,%3Cscript>window.close();%3C/script>")
ok(false, "showModalDialog call should throw an exception");
} catch(e) {
is(e.name, "NS_ERROR_NOT_AVAILABLE", "Wrong exception");
}
is (promptState.method, "confirm", "Wrong prompt method called");
is (promptState.parent, w, "Wrong confirm parent");
is (promptState.msg, "Prevent this page from creating additional dialogs",
"Wrong confirm message");
promptState = void(0);
w.close();
}
mockPromptFactoryRegisterer.unregister();
mockPromptServiceRegisterer.unregister();

View file

@ -1,38 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=735237
-->
<head>
<title>Test for Bug 735237</title>
<script type="application/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=735237">Mozilla Bug 735237</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 735237 **/
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.disable_window_showModalDialog", true]]}, function() {
var caughtException = false;
try {
window.showModalDialog("http://example.com/");
} catch (e) {
caughtException = true;
}
ok(caughtException, "showModalDialog should throw an exception");
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>

View file

@ -1,35 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script>
function go() {
is(SpecialPowers.wrap(window).location.toString(), location.toString(), "sanity");
ok("returnValue" in window && "dialogArguments" in window, "We are modal");
var iwin = document.getElementById('ifr').contentWindow;
is(SpecialPowers.Cu.getClassName(iwin, /* aUnwrap = */ true), "Window", "Descendant frames should not be modal");
if (location.origin != "http://mochi.test:8888") {
is(window.dialogArguments, undefined,
"dialogArguments should be undefined cross-origin: " + location.origin);
}
window.returnValue = "rv: " + window.dialogArguments;
// Allow for testing navigations in series.
if (location.search == "") {
window.close();
} else {
var origins = location.search.split('?')[1].split(',');
var newsearch = '?' + origins.splice(1).join(',');
var newurl = location.toString().replace(location.origin, origins[0])
.replace(location.search, newsearch);
location = newurl;
}
}
</script>
</head>
<body onload="opener.postMessage('dosetup', '*');">
<iframe id="ifr"></iframe>
</body>
</html>

View file

@ -9,7 +9,6 @@ support-files =
file_interfaces.xml
file_moving_nodeList.html
file_moving_xhr.html
file_showModalDialog.html
historyframes.html
image_50.png
image_100.png
@ -116,8 +115,6 @@ support-files = test_offsets.js
[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_storagePermissionsAccept.html]

View file

@ -1,60 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=862918
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 862918</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/** Test for window.showModalDialog. **/
// The modal window needs to touch Cu, which means that it needs
// SpecialPowers. But given the semantics of modal windows, we have to
// do some funny stuff with postMessage to set this up.
window.onmessage = function(evt) {
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);
// 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');
// This test used to assert after gc. Make sure it doesn't.
SpecialPowers.gc();
</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">
</div>
<pre id="test">
</pre>
</body>
</html>