зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset a5b13623631c:0200fd49efc3 (bug 838692) for frequent Linux debug test_iframe_sandbox_navigation.html timeouts
CLOSED TREE
This commit is contained in:
Родитель
9a5e7bd409
Коммит
0c06887eb0
|
@ -319,15 +319,6 @@ MOCHITEST_FILES = \
|
||||||
file_iframe_sandbox_d_if11.html \
|
file_iframe_sandbox_d_if11.html \
|
||||||
file_iframe_sandbox_d_if12.html \
|
file_iframe_sandbox_d_if12.html \
|
||||||
file_iframe_sandbox_d_if13.html \
|
file_iframe_sandbox_d_if13.html \
|
||||||
file_iframe_sandbox_d_if14.html \
|
|
||||||
file_iframe_sandbox_d_if15.html \
|
|
||||||
file_iframe_sandbox_d_if16.html \
|
|
||||||
file_iframe_sandbox_d_if17.html \
|
|
||||||
file_iframe_sandbox_d_if18.html \
|
|
||||||
file_iframe_sandbox_d_if19.html \
|
|
||||||
file_iframe_sandbox_d_if20.html \
|
|
||||||
file_iframe_sandbox_d_if21.html \
|
|
||||||
file_iframe_sandbox_d_if22.html \
|
|
||||||
file_iframe_sandbox_navigation_start.html \
|
file_iframe_sandbox_navigation_start.html \
|
||||||
file_iframe_sandbox_navigation_pass.html \
|
file_iframe_sandbox_navigation_pass.html \
|
||||||
file_iframe_sandbox_navigation_fail.html \
|
file_iframe_sandbox_navigation_fail.html \
|
||||||
|
@ -337,19 +328,8 @@ MOCHITEST_FILES = \
|
||||||
file_iframe_sandbox_e_if4.html \
|
file_iframe_sandbox_e_if4.html \
|
||||||
file_iframe_sandbox_e_if5.html \
|
file_iframe_sandbox_e_if5.html \
|
||||||
file_iframe_sandbox_e_if6.html \
|
file_iframe_sandbox_e_if6.html \
|
||||||
file_iframe_sandbox_e_if7.html \
|
|
||||||
file_iframe_sandbox_e_if8.html \
|
|
||||||
file_iframe_sandbox_e_if9.html \
|
|
||||||
file_iframe_sandbox_e_if10.html \
|
|
||||||
file_iframe_sandbox_e_if11.html \
|
|
||||||
file_iframe_sandbox_e_if12.html \
|
|
||||||
file_iframe_sandbox_e_if13.html \
|
|
||||||
file_iframe_sandbox_e_if14.html \
|
|
||||||
file_iframe_sandbox_e_if15.html \
|
|
||||||
file_iframe_sandbox_e_if16.html \
|
|
||||||
file_iframe_sandbox_top_navigation_pass.html \
|
file_iframe_sandbox_top_navigation_pass.html \
|
||||||
file_iframe_sandbox_top_navigation_fail.html \
|
file_iframe_sandbox_top_navigation_fail.html \
|
||||||
file_iframe_sandbox_window_navigation_fail.html \
|
|
||||||
test_iframe_sandbox_plugins.html \
|
test_iframe_sandbox_plugins.html \
|
||||||
file_iframe_sandbox_f_if1.html \
|
file_iframe_sandbox_f_if1.html \
|
||||||
file_iframe_sandbox_f_if2.html \
|
file_iframe_sandbox_f_if2.html \
|
||||||
|
|
|
@ -14,6 +14,6 @@ function doTest() {
|
||||||
<body onload="doTest()">
|
<body onload="doTest()">
|
||||||
I am sandboxed with 'allow-scripts'
|
I am sandboxed with 'allow-scripts'
|
||||||
|
|
||||||
<a href="file_iframe_sandbox_navigation_pass.html?Test 1:%20" target="_self" id='anchor'>
|
<a href="file_iframe_sandbox_navigation_pass.html?if_1" target="_self" id='anchor'>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Tests for Bug 838692</title>
|
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
var test20Context = "Test 20: Navigate another window (not opened by us): ";
|
|
||||||
|
|
||||||
function doTest() {
|
|
||||||
// Try to navigate auxiliary browsing context (window) not opened by us.
|
|
||||||
// We should not be able to do this as we are sandboxed.
|
|
||||||
sendMouseEvent({type:'click'}, 'navigate_window');
|
|
||||||
window.parent.postMessage("test attempted", "*");
|
|
||||||
|
|
||||||
// Try to navigate auxiliary browsing context (window) not opened by us, using window.open().
|
|
||||||
// We should not be able to do this as we are sandboxed.
|
|
||||||
try {
|
|
||||||
window.open("file_iframe_sandbox_window_navigation_fail.html?" + escape(test20Context), "window_to_navigate2");
|
|
||||||
window.parent.postMessage("test attempted", "*");
|
|
||||||
} catch(error) {
|
|
||||||
window.parent.postMessage({ok: true, desc: test20Context + "as expected, error thrown during window.open(..., \"window_to_navigate2\")"}, "*");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="doTest()">
|
|
||||||
I am sandboxed but with "allow-scripts allow-same-origin allow-top-navigation".
|
|
||||||
|
|
||||||
<a href="file_iframe_sandbox_window_navigation_fail.html?Test 14: Navigate another window (not opened by us):%20" target="window_to_navigate" id="navigate_window">navigate window</a>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,14 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
I am an unsandboxed iframe.
|
|
||||||
|
|
||||||
<iframe sandbox="allow-same-origin allow-scripts" id="if_16" src="file_iframe_sandbox_d_if16.html" height="10" width="10"></iframe>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,22 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script type="application/javascript">
|
|
||||||
function doTest() {
|
|
||||||
window.parent.parent.postMessage("test attempted", "*");
|
|
||||||
sendMouseEvent({type:'click'}, 'anchor');
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="doTest()">
|
|
||||||
I am sandboxed with 'allow-same-origin allow-scripts'
|
|
||||||
|
|
||||||
<a href="file_iframe_sandbox_navigation_fail.html?Test 16: Navigate parent/ancestor by name:%20" target='if_parent' id='anchor'>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,24 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script type="application/javascript">
|
|
||||||
var testContext = "Test 17: navigate _self with window.open(): ";
|
|
||||||
|
|
||||||
function doTest() {
|
|
||||||
try {
|
|
||||||
window.open("file_iframe_sandbox_navigation_pass.html?" + escape(testContext), "_self");
|
|
||||||
} catch(error) {
|
|
||||||
window.parent.postMessage({ok: false, desc: testContext + "error thrown during window.open(..., \"_self\")"}, "*");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="doTest()">
|
|
||||||
I am sandboxed with 'allow-scripts'
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,33 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script type="application/javascript">
|
|
||||||
window.addEventListener("message", receiveMessage, false);
|
|
||||||
|
|
||||||
function receiveMessage(event) {
|
|
||||||
window.parent.postMessage(event.data, "*");
|
|
||||||
}
|
|
||||||
|
|
||||||
var testContext = "Test 18: navigate child with window.open(): ";
|
|
||||||
|
|
||||||
function doTest() {
|
|
||||||
try {
|
|
||||||
window.open("file_iframe_sandbox_navigation_pass.html?" + escape(testContext), "foo");
|
|
||||||
} catch(error) {
|
|
||||||
window.parent.postMessage({ok: false, desc: testContext + " error thrown during window.open(..., \"foo\")"}, "*");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="doTest()">
|
|
||||||
I am sandboxed with 'allow-scripts'
|
|
||||||
|
|
||||||
<iframe name="foo" height="10" width="10"></iframe>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,13 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
I am sandboxed with 'allow-scripts'
|
|
||||||
|
|
||||||
<iframe sandbox="allow-scripts" id="if_20" src="file_iframe_sandbox_d_if20.html" height="10" width="10"></iframe>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -11,7 +11,7 @@
|
||||||
window.addEventListener("message", receiveMessage, false);
|
window.addEventListener("message", receiveMessage, false);
|
||||||
|
|
||||||
function receiveMessage(event) {
|
function receiveMessage(event) {
|
||||||
window.parent.postMessage(event.data, "*");
|
window.parent.postMessage({ok: event.data.ok, desc: event.data.desc}, "*");
|
||||||
}
|
}
|
||||||
|
|
||||||
function doTest() {
|
function doTest() {
|
||||||
|
@ -23,6 +23,6 @@ function doTest() {
|
||||||
|
|
||||||
<iframe name="foo" src="file_iframe_sandbox_navigation_start.html" height="10" width="10"></iframe>
|
<iframe name="foo" src="file_iframe_sandbox_navigation_start.html" height="10" width="10"></iframe>
|
||||||
|
|
||||||
<a href="file_iframe_sandbox_navigation_pass.html?Test 2:%20" target='foo' id='anchor'>
|
<a href="file_iframe_sandbox_navigation_pass.html?if2" target='foo' id='anchor'>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script type="application/javascript">
|
|
||||||
var testContext = "Test 19: navigate _parent with window.open(): ";
|
|
||||||
|
|
||||||
function doTest() {
|
|
||||||
try {
|
|
||||||
window.open("file_iframe_sandbox_navigation_fail.html?" + escape(testContext), "_parent");
|
|
||||||
window.parent.parent.postMessage("test attempted", "*");
|
|
||||||
} catch(error) {
|
|
||||||
window.parent.parent.postMessage({ok: true, desc: testContext + "as expected, error thrown during window.open(..., \"_parent\")"}, "*");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="doTest()">
|
|
||||||
I am sandboxed with 'allow-scripts'
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,14 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
I am an unsandboxed iframe.
|
|
||||||
|
|
||||||
<iframe sandbox="allow-same-origin allow-scripts" id="if_22" src="file_iframe_sandbox_d_if22.html" height="10" width="10"></iframe>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,25 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script type="application/javascript">
|
|
||||||
var testContext = "Test 21: navigate parent by name with window.open(): ";
|
|
||||||
|
|
||||||
function doTest() {
|
|
||||||
try {
|
|
||||||
window.open("file_iframe_sandbox_navigation_fail.html?" + escape(testContext), "if_parent2");
|
|
||||||
window.parent.parent.postMessage("test attempted", "*");
|
|
||||||
} catch(error) {
|
|
||||||
window.parent.parent.postMessage({ok: true, desc: testContext + "as expected, error thrown during window.open(..., \"if_parent2\")"}, "*");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="doTest()">
|
|
||||||
I am sandboxed with 'allow-same-origin allow-scripts'
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -8,7 +8,6 @@
|
||||||
</head>
|
</head>
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
function doTest() {
|
function doTest() {
|
||||||
window.parent.parent.postMessage("test attempted", "*");
|
|
||||||
sendMouseEvent({type:'click'}, 'anchor');
|
sendMouseEvent({type:'click'}, 'anchor');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -9,12 +9,11 @@
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
function doTest() {
|
function doTest() {
|
||||||
sendMouseEvent({type:'click'}, 'anchor');
|
sendMouseEvent({type:'click'}, 'anchor');
|
||||||
window.parent.postMessage("test attempted", "*");
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<body onload="doTest()">
|
<body onload="doTest()">
|
||||||
I am sandboxed with 'allow-scripts allow-same-origin'
|
I am sandboxed with 'allow-scripts allow-same-origin'
|
||||||
|
|
||||||
<a href="file_iframe_sandbox_navigation_fail.html?Test 4: Navigate sibling iframe by name:%20" target='if_sibling' id='anchor'>
|
<a href="file_iframe_sandbox_navigation_fail.html" target='sibling' id='anchor'>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -7,11 +7,7 @@
|
||||||
</head>
|
</head>
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
function doTest() {
|
function doTest() {
|
||||||
try {
|
|
||||||
window.parent.ok_wrapper(false, "a sandboxed document when navigated should still NOT be same-origin with its parent");
|
window.parent.ok_wrapper(false, "a sandboxed document when navigated should still NOT be same-origin with its parent");
|
||||||
} catch(error) {
|
|
||||||
window.parent.postMessage({ok: true, desc: "sandboxed document's attempt to access parent after navigation blocked, as not same-origin."}, "*");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<body onload="doTest()">
|
<body onload="doTest()">
|
||||||
|
|
|
@ -7,15 +7,7 @@
|
||||||
</head>
|
</head>
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
function doTest() {
|
function doTest() {
|
||||||
if (location.search == "?onreload") {
|
|
||||||
try {
|
|
||||||
window.parent.modify_if_8();
|
window.parent.modify_if_8();
|
||||||
} catch (error) {
|
|
||||||
window.parent.postMessage({ok: true, desc: "allow-same-origin is no longer in effect after reload - parent access blocked."}, "*");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
window.parent.modify_if_8();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<body onload="doTest()">
|
<body onload="doTest()">
|
||||||
|
|
|
@ -6,15 +6,19 @@
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
window.addEventListener("message", receiveMessage, false);
|
||||||
|
|
||||||
<script>
|
function receiveMessage(event)
|
||||||
function doTest() {
|
{
|
||||||
var testContext = location.search == "" ? "?Test 10: Navigate _top:%20" : location.search;
|
window.parent.postMessage("close", "*");
|
||||||
document.getElementById("if_6").src = "file_iframe_sandbox_e_if6.html" + testContext;
|
|
||||||
|
SimpleTest.executeSoon(function() {
|
||||||
|
window.close();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<iframe sandbox='allow-scripts allow-same-origin' id='if_6' src="file_iframe_sandbox_e_if6.html" height="10" width="10"></iframe>
|
||||||
<body onload="doTest()">
|
|
||||||
<iframe sandbox='allow-scripts' id='if_6' height="10" width="10"></iframe>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function doTest() {
|
|
||||||
var testContext = "?Test 23: Nested navigate _top with window.open():%20";
|
|
||||||
document.getElementById("if_9").src = "file_iframe_sandbox_e_if9.html" + testContext;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="doTest()">
|
|
||||||
<iframe sandbox='allow-scripts allow-top-navigation' id='if_9' height="10" width="10"></iframe>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,24 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
<script>
|
|
||||||
function doTest() {
|
|
||||||
var testContext = location.search.substring(1);
|
|
||||||
try {
|
|
||||||
var topsOpener = window.top.opener;
|
|
||||||
window.open("file_iframe_sandbox_top_navigation_pass.html?" + testContext, "_top");
|
|
||||||
topsOpener.postMessage({ok: true, desc: unescape(testContext) + "top navigation should be allowed by a document sandboxed with 'allow-top-navigation.'"}, "*");
|
|
||||||
} catch(error) {
|
|
||||||
window.top.opener.postMessage({ok: false, desc: unescape(testContext) + "error thrown during window.open(..., \"_top\")"}, "*");
|
|
||||||
window.top.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<body onload="doTest()">
|
|
||||||
I am sandboxed with 'allow-scripts and allow-top-navigation'
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,19 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function doTest() {
|
|
||||||
var testContext = location.search == "" ? "?Test 24: Navigate _top with window.open():%20" : location.search;
|
|
||||||
document.getElementById("if_14").src = "file_iframe_sandbox_e_if14.html" + testContext;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="doTest()">
|
|
||||||
<iframe sandbox='allow-scripts' id='if_14' height="10" width="10"></iframe>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,19 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function doTest() {
|
|
||||||
var testContext = "?Test 25: Nested navigate _top with window.open():%20";
|
|
||||||
document.getElementById("if_12").src = "file_iframe_sandbox_e_if12.html" + testContext;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="doTest()">
|
|
||||||
<iframe sandbox='allow-scripts allow-top-navigation' id='if_12' height="10" width="10"></iframe>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,24 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
<script>
|
|
||||||
function doTest() {
|
|
||||||
var testContext = location.search.substring(1);
|
|
||||||
try {
|
|
||||||
var topsOpener = window.top.opener;
|
|
||||||
window.open("file_iframe_sandbox_top_navigation_fail.html?" + testContext, "_top");
|
|
||||||
topsOpener.postMessage({ok: false, desc: unescape(testContext) + "top navigation should NOT be allowed by a document sandboxed without 'allow-top-navigation.'"}, "*");
|
|
||||||
} catch(error) {
|
|
||||||
window.top.opener.postMessage({ok: true, desc: unescape(testContext) + "as expected error thrown during window.open(..., \"_top\")"}, "*");
|
|
||||||
window.top.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<body onload="doTest()">
|
|
||||||
I am sandboxed with 'allow-scripts'
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,17 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
// Set our name, to allow an attempt to navigate us by name.
|
|
||||||
window.name = "e_if15";
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<iframe sandbox='allow-scripts' id='if_16' src="file_iframe_sandbox_e_if16.html" height="10" width="10"></iframe>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,27 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Tests for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
var testContext = "Test 26: navigate top by name with window.open(): ";
|
|
||||||
|
|
||||||
function doTest() {
|
|
||||||
try {
|
|
||||||
var topsOpener = window.top.opener;
|
|
||||||
window.open("file_iframe_sandbox_top_navigation_fail.html?" + escape(testContext), "e_if15");
|
|
||||||
topsOpener.postMessage({ok: false, desc: unescape(testContext) + "top navigation should NOT be allowed by a document sandboxed without 'allow-top-navigation.'"}, "*");
|
|
||||||
} catch(error) {
|
|
||||||
window.top.opener.postMessage({ok: true, desc: testContext + "as expected, error thrown during window.open(..., \"e_if15\")"}, "*");
|
|
||||||
window.top.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="doTest()">
|
|
||||||
I am sandboxed but with "allow-scripts"
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -7,6 +7,16 @@
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<iframe sandbox='allow-scripts allow-top-navigation allow-same-origin' id='if_1' src="file_iframe_sandbox_e_if1.html?Test 11: Nested navigate _top:%20" height="10" width="10"></iframe>
|
<script>
|
||||||
|
window.addEventListener("message", receiveMessage, false);
|
||||||
|
|
||||||
|
function receiveMessage(event)
|
||||||
|
{
|
||||||
|
SimpleTest.executeSoon(function() {
|
||||||
|
window.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<iframe sandbox='allow-scripts allow-top-navigation allow-same-origin' id='if_1' src="file_iframe_sandbox_e_if1.html" height="10" width="10"></iframe>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -9,14 +9,16 @@
|
||||||
</head>
|
</head>
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
function doTest() {
|
function doTest() {
|
||||||
document.getElementById('anchor').href = "file_iframe_sandbox_top_navigation_fail.html" + location.search;
|
|
||||||
window.top.opener.postMessage("test attempted", "*");
|
|
||||||
sendMouseEvent({type:'click'}, 'anchor');
|
sendMouseEvent({type:'click'}, 'anchor');
|
||||||
|
|
||||||
|
SimpleTest.executeSoon(function() {
|
||||||
|
window.parent.postMessage("close", "*");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<body onload="doTest()">
|
<body onload="doTest()">
|
||||||
I am sandboxed with 'allow-scripts'
|
I am sandboxed with 'allow-scripts'
|
||||||
|
|
||||||
<a target='_top' id='anchor'>
|
<a href="file_iframe_sandbox_top_navigation_fail.html" target='_top' id='anchor'>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
// Set our name, to allow an attempt to navigate us by name.
|
|
||||||
window.name = "e_if7";
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<iframe sandbox='allow-scripts' id='if_8' src="file_iframe_sandbox_e_if8.html" height="10" width="10"></iframe>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,23 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Tests for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function doTest() {
|
|
||||||
// Try to navigate top using its name (e_if7). We should not be able to do this as allow-top-navigation is not specified.
|
|
||||||
window.top.opener.postMessage("test attempted", "*");
|
|
||||||
sendMouseEvent({type:'click'}, 'navigate_top');
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="doTest()">
|
|
||||||
I am sandboxed but with "allow-scripts"
|
|
||||||
|
|
||||||
<a href="file_iframe_sandbox_top_navigation_fail.html?Test 15: Navigate top by name:%20" target="e_if7" id="navigate_top">navigate top</a>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,19 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function doTest() {
|
|
||||||
var testContext = location.search == "" ? "?Test 22: Navigate _top with window.open():%20" : location.search;
|
|
||||||
document.getElementById("if_11").src = "file_iframe_sandbox_e_if11.html" + testContext;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="doTest()">
|
|
||||||
<iframe sandbox='allow-scripts allow-top-navigation' id='if_11' height="10" width="10"></iframe>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -10,8 +10,7 @@ FAIL
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
function doStuff() {
|
function doStuff() {
|
||||||
var testContext = unescape(location.search.substring(1));
|
window.parent.postMessage({ok: false, desc: "this navigation should NOT be allowed by a sandboxed document"}, "*");
|
||||||
window.parent.postMessage({ok: false, desc: testContext + "this navigation should NOT be allowed by a sandboxed document", addToAttempted: false}, "*");
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
</head>
|
</head>
|
||||||
<script>
|
<script>
|
||||||
function doStuff() {
|
function doStuff() {
|
||||||
var testContext = unescape(location.search.substring(1));
|
window.parent.postMessage({ok: true, desc: "this navigation should be allowed by a sandboxed document"}, "*");
|
||||||
window.parent.postMessage({ok: true, desc: testContext + "this navigation should be allowed by a sandboxed document"}, "*");
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<body onLoad="doStuff()">
|
<body onLoad="doStuff()">
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
</head>
|
</head>
|
||||||
<script>
|
<script>
|
||||||
function doStuff() {
|
function doStuff() {
|
||||||
var testContext = unescape(location.search.substring(1));
|
window.opener.postMessage({ok: false, desc: "top navigation should NOT be allowed by a document sandboxed without 'allow-top-navigation'"}, "*");
|
||||||
window.opener.postMessage({ok: false, desc: testContext + "top navigation should NOT be allowed by a document sandboxed without 'allow-top-navigation'", addToAttempted: false}, "*");
|
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
</head>
|
</head>
|
||||||
<script>
|
<script>
|
||||||
function doStuff() {
|
function doStuff() {
|
||||||
var testContext = unescape(location.search.substring(1));
|
window.opener.postMessage({ok: true, desc: "top navigation should be allowed by a document sandboxed with 'allow-top-navigation'"}, "*");
|
||||||
window.opener.postMessage({ok: true, desc: testContext + "top navigation should be allowed by a document sandboxed with 'allow-top-navigation'"}, "*");
|
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for Bug 838692</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function doStuff() {
|
|
||||||
var testContext = unescape(location.search.substring(1));
|
|
||||||
window.opener.postMessage({ok: false, desc: testContext + "a sandboxed document should not be able to navigate a window it hasn't opened.", addToAttempted: false}, "*");
|
|
||||||
window.close();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onLoad="doStuff()">
|
|
||||||
FAIL
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -12,10 +12,12 @@ Implement HTML5 sandbox attribute for IFRAMEs
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
</head>
|
</head>
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
|
|
||||||
|
SimpleTest.expectAssertions(1, 2);
|
||||||
|
|
||||||
/** Test for Bug 341604 - Implement HTML5 sandbox attribute for IFRAMEs **/
|
/** Test for Bug 341604 - Implement HTML5 sandbox attribute for IFRAMEs **/
|
||||||
/** Navigation tests **/
|
/** Navigation tests **/
|
||||||
|
|
||||||
SimpleTest.expectAssertions(1, 3);
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
// a postMessage handler that is used by sandboxed iframes without
|
// a postMessage handler that is used by sandboxed iframes without
|
||||||
// 'allow-same-origin'/other windows to communicate pass/fail back to this main page.
|
// 'allow-same-origin'/other windows to communicate pass/fail back to this main page.
|
||||||
|
@ -29,69 +31,31 @@ function receiveMessage(event) {
|
||||||
// this message is part of if_10's test
|
// this message is part of if_10's test
|
||||||
if (event.data.test == 'if_10') {
|
if (event.data.test == 'if_10') {
|
||||||
doIf10TestPart2();
|
doIf10TestPart2();
|
||||||
} else if (event.data == "test attempted") {
|
return;
|
||||||
testAttempted();
|
|
||||||
} else {
|
|
||||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ok_wrapper(event.data.ok, event.data.desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open windows for tests to attempt to navigate later.
|
var completedTests = 0;
|
||||||
var windowsToClose = new Array();
|
|
||||||
windowsToClose.push(window.open("about:blank", "window_to_navigate"));
|
|
||||||
windowsToClose.push(window.open("about:blank", "window_to_navigate2"));
|
|
||||||
|
|
||||||
var attemptedTests = 0;
|
|
||||||
var passedTests = 0;
|
var passedTests = 0;
|
||||||
var totalTestsToPass = 18;
|
|
||||||
var totalTestsToAttempt = 26;
|
|
||||||
|
|
||||||
function ok_wrapper(result, desc, addToAttempted = true) {
|
function ok_wrapper(result, desc) {
|
||||||
ok(result, desc);
|
ok(result, desc);
|
||||||
|
|
||||||
|
completedTests++;
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
passedTests++;
|
passedTests++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addToAttempted) {
|
if (completedTests == 6) {
|
||||||
testAttempted();
|
is(passedTests, 6, "There are 6 navigation tests that should pass");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Added so that tests that don't register unless they fail,
|
|
||||||
// can at least notify that they've attempted to run.
|
|
||||||
function testAttempted() {
|
|
||||||
attemptedTests++;
|
|
||||||
if (attemptedTests == totalTestsToAttempt) {
|
|
||||||
// Make sure all tests have had a chance to complete.
|
|
||||||
setTimeout(function() {finish();}, 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var finishCalled = false;
|
|
||||||
|
|
||||||
function finish() {
|
|
||||||
if (!finishCalled) {
|
|
||||||
finishCalled = true;
|
|
||||||
is(passedTests, totalTestsToPass, "There are " + totalTestsToPass + " navigation tests that should pass");
|
|
||||||
|
|
||||||
for (var i = 0; i < windowsToClose.length; i++) {
|
|
||||||
windowsToClose[i].close();
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkTestsFinished() {
|
|
||||||
// If our own finish() has not been called, probably failed due to a timeout, so close remaining windows.
|
|
||||||
if (!finishCalled) {
|
|
||||||
for (var i = 0; i < windowsToClose.length; i++) {
|
|
||||||
windowsToClose[i].close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function doTest() {
|
function doTest() {
|
||||||
// passes if good
|
// passes if good
|
||||||
// 1) A sandboxed iframe is allowed to navigate itself
|
// 1) A sandboxed iframe is allowed to navigate itself
|
||||||
|
@ -114,13 +78,13 @@ function doTest() {
|
||||||
// and attempts to navigate file_iframe_navigation_start.html contained in if_sibling on this
|
// and attempts to navigate file_iframe_navigation_start.html contained in if_sibling on this
|
||||||
// page to file_iframe_sandbox_navigation_fail.html).
|
// page to file_iframe_sandbox_navigation_fail.html).
|
||||||
|
|
||||||
// passes if good, fails if bad
|
// fails if bad
|
||||||
// 5) When a link is clicked in a sandboxed iframe, the document navigated to is sandboxed
|
// 5) When a link is clicked in a sandboxed iframe, the document navigated to is sandboxed
|
||||||
// the same as the original document and is not same origin with parent document
|
// the same as the original document and is not same origin with parent document
|
||||||
// (done by file_iframe_sandbox_d_if6.html which simulates a link click and navigates
|
// (done by file_iframe_sandbox_d_if6.html which simulates a link click and navigates
|
||||||
// to file_iframe_sandbox_d_if7.html which attempts to call back into its parent).
|
// to file_iframe_sandbox_d_if7.html which attempts to call back into its parent).
|
||||||
|
|
||||||
// passes if good, fails if bad
|
// fails if bad
|
||||||
// 6) An iframe (if_8) has sandbox="allow-same-origin allow-scripts", the sandboxed document
|
// 6) An iframe (if_8) has sandbox="allow-same-origin allow-scripts", the sandboxed document
|
||||||
// (file_iframe_sandbox_d_if_8.html) that it contains accesses its parent (this file) and removes
|
// (file_iframe_sandbox_d_if_8.html) that it contains accesses its parent (this file) and removes
|
||||||
// 'allow-same-origin' and then triggers a reload.
|
// 'allow-same-origin' and then triggers a reload.
|
||||||
|
@ -152,14 +116,14 @@ function doTest() {
|
||||||
// 10) iframe with sandbox='allow-scripts' can NOT navigate top
|
// 10) iframe with sandbox='allow-scripts' can NOT navigate top
|
||||||
// file_iframe_sandbox_e_if1.html contains file_iframe_sandbox_e_if6.html which
|
// file_iframe_sandbox_e_if1.html contains file_iframe_sandbox_e_if6.html which
|
||||||
// attempts to navigate top
|
// attempts to navigate top
|
||||||
windowsToClose.push(window.open("file_iframe_sandbox_e_if1.html"));
|
window.open("file_iframe_sandbox_e_if1.html");
|
||||||
|
|
||||||
// fails if bad
|
// fails if bad
|
||||||
// 11) iframe with sandbox='allow-scripts' nested inside iframe with
|
// 11) iframe with sandbox='allow-scripts' nested inside iframe with
|
||||||
// 'allow-top-navigation allow-scripts' can NOT navigate top
|
// 'allow-top-navigation allow-scripts' can NOT navigate top
|
||||||
// file_iframe_sandbox_e_if2.html contains file_iframe_sandbox_e_if1.html which
|
// file_iframe_sandbox_e_if2.html contains file_iframe_sandbox_e_if1.html which
|
||||||
// contains file_iframe_sandbox_e_if6.html which attempts to navigate top
|
// contains file_iframe_sandbox_e_if6.html which attempts to navigate top
|
||||||
windowsToClose.push(window.open("file_iframe_sandbox_e_if2.html"));
|
window.open("file_iframe_sandbox_e_if2.html");
|
||||||
|
|
||||||
// passes if good
|
// passes if good
|
||||||
// 12) iframe with sandbox='allow-top-navigation allow-scripts' can navigate top
|
// 12) iframe with sandbox='allow-top-navigation allow-scripts' can navigate top
|
||||||
|
@ -167,90 +131,11 @@ function doTest() {
|
||||||
window.open("file_iframe_sandbox_e_if3.html");
|
window.open("file_iframe_sandbox_e_if3.html");
|
||||||
|
|
||||||
// passes if good
|
// passes if good
|
||||||
// 13) iframe with sandbox='allow-top-navigation allow-scripts' nested inside an iframe with
|
// 131) iframe with sandbox='allow-top-navigation allow-scripts' nested inside an iframe with
|
||||||
// 'allow-top-navigation allow-scripts' can navigate top
|
// 'allow-top-navigation allow-scripts' can navigate top
|
||||||
// file_iframe_sandbox_e_if4.html contains file_iframe_sandbox_e_if3.html which contains
|
// file_iframe_sandbox_e_if4.html contains file_iframe_sandbox_e_if3.html which contains
|
||||||
// file_iframe_sandbox_e_if5.html which navigates top
|
// file_iframe_sandbox_e_if5.html which navigates top
|
||||||
window.open("file_iframe_sandbox_e_if4.html");
|
window.open("file_iframe_sandbox_e_if4.html");
|
||||||
|
|
||||||
// fails if bad
|
|
||||||
// 14) iframe with sandbox='allow-same-origin allow-scripts allow-top-navigation' should not
|
|
||||||
// be able to navigate another window (opened by another browsing context) using its name.
|
|
||||||
// file_iframe_sandbox_d_if14.html in if_14 attempts to navigate "window_to_navigate",
|
|
||||||
// which has been opened in preparation.
|
|
||||||
|
|
||||||
// fails if bad
|
|
||||||
// 15) iframe with sandbox='allow-scripts' should not be able to navigate top using its
|
|
||||||
// real name (instead of _top) as allow-top-navigation is not specified.
|
|
||||||
// file_iframe_sandbox_e_if7.html contains file_iframe_sandbox_e_if8.html, which
|
|
||||||
// attempts to navigate top by name.
|
|
||||||
windowsToClose.push(window.open("file_iframe_sandbox_e_if7.html"));
|
|
||||||
|
|
||||||
// fails if bad
|
|
||||||
// 16) iframe with sandbox='allow-same-origin allow-scripts allow-top-navigation' should not
|
|
||||||
// be able to use its parent's name (instead of _parent) to navigate it, when it is not top.
|
|
||||||
// (Note: this would apply to other ancestors that are not top as well.)
|
|
||||||
// file_iframe_sandbox_d_if15.html in if_15 contains file_iframe_sandbox_d_if16.html, which
|
|
||||||
// tries to navigate if_15 by its name (if_parent).
|
|
||||||
|
|
||||||
// passes if good, fails if bad
|
|
||||||
// 17) A sandboxed iframe is allowed to navigate itself using window.open().
|
|
||||||
// (Done by file_iframe_sandbox_d_if17.html which has 'allow-scripts' and navigates to
|
|
||||||
// file_iframe_sandbox_navigation_pass.html).
|
|
||||||
|
|
||||||
// passes if good, fails if bad
|
|
||||||
// 18) A sandboxed iframe is allowed to navigate its children with window.open(), even if
|
|
||||||
// they are sandboxed. (Done by file_iframe_sandbox_d_if18.html which has 'allow-scripts',
|
|
||||||
// it navigates a child iframe to file_iframe_sandbox_navigation_pass.html).
|
|
||||||
|
|
||||||
// passes if good, fails if bad
|
|
||||||
// 19) A sandboxed iframe is not allowed to navigate its ancestor with window.open().
|
|
||||||
// (Done by file_iframe_sandbox_d_if20.html contained within file_iframe_sandbox_d_if19.html,
|
|
||||||
// it attempts to navigate file_iframe_sandbox_d_if19.html to file_iframe_sandbox_navigation_fail.html).
|
|
||||||
|
|
||||||
// passes if good, fails if bad
|
|
||||||
// 20) iframe with sandbox='allow-same-origin allow-scripts allow-top-navigation' should not
|
|
||||||
// be able to navigate another window (opened by another browsing context) using window.open(..., "<name>").
|
|
||||||
// file_iframe_sandbox_d_if14.html in if_14 attempts to navigate "window_to_navigate2",
|
|
||||||
// which has been opened in preparation, using window.open(..., "window_to_navigate2").
|
|
||||||
|
|
||||||
// passes if good, fails if bad
|
|
||||||
// 21) iframe with sandbox='allow-same-origin allow-scripts allow-top-navigation' should not
|
|
||||||
// be able to use its parent's name (not _parent) to navigate it using window.open(), when it is not top.
|
|
||||||
// (Note: this would apply to other ancestors that are not top as well.)
|
|
||||||
// file_iframe_sandbox_d_if21.html in if_21 contains file_iframe_sandbox_d_if22.html, which
|
|
||||||
// tries to navigate if_21 by its name (if_parent2).
|
|
||||||
|
|
||||||
// passes if good, fails if bad
|
|
||||||
// 22) iframe with sandbox='allow-top-navigation allow-scripts' can navigate top with window.open().
|
|
||||||
// file_iframe_sandbox_e_if9.html contains file_iframe_sandbox_e_if11.html which navigates top.
|
|
||||||
window.open("file_iframe_sandbox_e_if9.html");
|
|
||||||
|
|
||||||
// passes if good, fails if bad
|
|
||||||
// 23) iframe with sandbox='allow-top-navigation allow-scripts' nested inside an iframe with
|
|
||||||
// 'allow-top-navigation allow-scripts' can navigate top, with window.open().
|
|
||||||
// file_iframe_sandbox_e_if10.html contains file_iframe_sandbox_e_if9.html which contains
|
|
||||||
// file_iframe_sandbox_e_if11.html which navigates top.
|
|
||||||
window.open("file_iframe_sandbox_e_if10.html");
|
|
||||||
|
|
||||||
// passes if good, fails if bad
|
|
||||||
// 24) iframe with sandbox='allow-scripts' can NOT navigate top with window.open().
|
|
||||||
// file_iframe_sandbox_e_if12.html contains file_iframe_sandbox_e_if14.html which navigates top.
|
|
||||||
window.open("file_iframe_sandbox_e_if12.html");
|
|
||||||
|
|
||||||
// passes if good, fails if bad
|
|
||||||
// 25) iframe with sandbox='allow-scripts' nested inside an iframe with
|
|
||||||
// 'allow-top-navigation allow-scripts' can NOT navigate top, with window.open(..., "_top").
|
|
||||||
// file_iframe_sandbox_e_if13.html contains file_iframe_sandbox_e_if12.html which contains
|
|
||||||
// file_iframe_sandbox_e_if14.html which navigates top.
|
|
||||||
window.open("file_iframe_sandbox_e_if13.html");
|
|
||||||
|
|
||||||
// passes if good, fails if bad
|
|
||||||
// 26) iframe with sandbox='allow-scripts' should not be able to navigate top using its real name
|
|
||||||
// (not with _top e.g. window.open(..., "topname")) as allow-top-navigation is not specified.
|
|
||||||
// file_iframe_sandbox_e_if15.html contains file_iframe_sandbox_e_if16.html, which
|
|
||||||
// attempts to navigate top by name using window.open().
|
|
||||||
window.open("file_iframe_sandbox_e_if15.html");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addLoadEvent(doTest);
|
addLoadEvent(doTest);
|
||||||
|
@ -259,7 +144,7 @@ window.modified_if_8 = false;
|
||||||
|
|
||||||
function reload_if_8() {
|
function reload_if_8() {
|
||||||
var if_8 = document.getElementById('if_8');
|
var if_8 = document.getElementById('if_8');
|
||||||
if_8.src = 'file_iframe_sandbox_d_if8.html?onreload';
|
if_8.src = 'file_iframe_sandbox_d_if8.html';
|
||||||
}
|
}
|
||||||
|
|
||||||
function modify_if_8() {
|
function modify_if_8() {
|
||||||
|
@ -292,7 +177,7 @@ function modify_if_9() {
|
||||||
// that's a failed test (allow-scripts was removed
|
// that's a failed test (allow-scripts was removed
|
||||||
// the first time).
|
// the first time).
|
||||||
if (window.modified_if_9) {
|
if (window.modified_if_9) {
|
||||||
ok_wrapper(false, "an sandboxed iframe from which 'allow-scripts' should be removed should not be able to access its parent via a script", false);
|
ok_wrapper(false, "an sandboxed iframe from which 'allow-scripts' should be removed should not be able to access its parent via a script");
|
||||||
|
|
||||||
// need to return here since we end up in an infinite loop otherwise
|
// need to return here since we end up in an infinite loop otherwise
|
||||||
return;
|
return;
|
||||||
|
@ -304,7 +189,6 @@ function modify_if_9() {
|
||||||
if_9.sandbox = 'allow-same-origin';
|
if_9.sandbox = 'allow-same-origin';
|
||||||
|
|
||||||
sendMouseEvent({type:'click'}, 'a_button2');
|
sendMouseEvent({type:'click'}, 'a_button2');
|
||||||
testAttempted();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var firstPrincipal = "";
|
var firstPrincipal = "";
|
||||||
|
@ -320,8 +204,8 @@ function doIf10TestPart1() {
|
||||||
var if_10 = document.getElementById('if_10');
|
var if_10 = document.getElementById('if_10');
|
||||||
firstPrincipal = SpecialPowers.wrap(if_10).contentDocument.nodePrincipal.origin;
|
firstPrincipal = SpecialPowers.wrap(if_10).contentDocument.nodePrincipal.origin;
|
||||||
if_10.src = 'file_iframe_sandbox_d_if10.html';
|
if_10.src = 'file_iframe_sandbox_d_if10.html';
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
function doIf10TestPart2() {
|
function doIf10TestPart2() {
|
||||||
var if_10 = document.getElementById('if_10');
|
var if_10 = document.getElementById('if_10');
|
||||||
// use SpecialPowers to get the principal of if_10
|
// use SpecialPowers to get the principal of if_10
|
||||||
|
@ -330,25 +214,19 @@ function doIf10TestPart2() {
|
||||||
" allow-same-origin and the first document is navigated to the second");
|
" allow-same-origin and the first document is navigated to the second");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<body onunload="checkTestsFinished()">
|
<body>
|
||||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=341604">Mozilla Bug 341604</a> - Implement HTML5 sandbox attribute for IFRAMEs
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=341604">Mozilla Bug 341604</a> - Implement HTML5 sandbox attribute for IFRAMEs
|
||||||
<p id="display"></p>
|
<p id="display"></p>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<iframe sandbox="allow-scripts" id="if_1" src="file_iframe_sandbox_d_if1.html" height="10" width="10"></iframe>
|
<iframe sandbox="allow-scripts" id="if_1" src="file_iframe_sandbox_d_if1.html" height="10" width="10"></iframe>
|
||||||
<iframe sandbox="allow-scripts" id="if_2" src="file_iframe_sandbox_d_if2.html" height="10" width="10"></iframe>
|
<iframe sandbox="allow-scripts" id="if_2" src="file_iframe_sandbox_d_if2.html" height="10" width="10"></iframe>
|
||||||
<iframe sandbox="allow-scripts" id="if_3" src="file_iframe_sandbox_d_if3.html" height="10" width="10"></iframe>
|
<iframe sandbox="allow-scripts" id="if_3" src="file_iframe_sandbox_d_if3.html" height="10" width="10"></iframe>
|
||||||
<iframe sandbox="allow-scripts allow-same-origin" id="if_5" src="file_iframe_sandbox_d_if5.html" height="10" width="10"></iframe>
|
<iframe sandbox="allow_scripts allow-same-origin" id="if_5" src="file_iframe_sandbox_d_if5.html" height="10" width="10"></iframe>
|
||||||
<iframe id="if_sibling" name="if_sibling" src="file_iframe_sandbox_navigation_start.html" height="10" width="10"></iframe>
|
<iframe id="if_sibling" src="file_iframe_sandbox_navigation_start.html" height="10" width="10"></iframe>
|
||||||
<iframe sandbox="allow-scripts" id="if_6" src="file_iframe_sandbox_d_if6.html" height="10" width="10"></iframe>
|
<iframe sandbox="allow_scripts" id="if_6" src="file_iframe_sandbox_d_if6.html" height="10" width="10"></iframe>
|
||||||
<iframe sandbox="allow-same-origin allow-scripts" id="if_8" src="file_iframe_sandbox_d_if8.html" height="10" width="10"></iframe>
|
<iframe sandbox="allow-same-origin allow-scripts" id="if_8" src="file_iframe_sandbox_d_if8.html" height="10" width="10"></iframe>
|
||||||
<iframe sandbox="allow-same-origin allow-scripts" id="if_9" src="file_iframe_sandbox_d_if9.html" height="10" width="10"></iframe>
|
<iframe sandbox="allow-same-origin allow-scripts" id="if_9" src="file_iframe_sandbox_d_if9.html" height="10" width="10"></iframe>
|
||||||
<iframe sandbox="allow-scripts" id="if_10" src="file_iframe_sandbox_navigation_start.html" onload='doIf10TestPart1()' height="10" width="10"></iframe>
|
<iframe sandbox="allow-scripts" id="if_10" src="file_iframe_sandbox_navigation_start.html" onload='doIf10TestPart1()' height="10" width="10"></iframe>
|
||||||
<iframe sandbox="allow-same-origin allow-scripts allow-top-navigation" id="if_14" src="file_iframe_sandbox_d_if14.html" height="10" width="10"></iframe>
|
|
||||||
<iframe id="if_15" name="if_parent" src="file_iframe_sandbox_d_if15.html" height="10" width="10"></iframe>
|
|
||||||
<iframe sandbox="allow-scripts" id="if_17" src="file_iframe_sandbox_d_if17.html" height="10" width="10"></iframe>
|
|
||||||
<iframe sandbox="allow-scripts" id="if_18" src="file_iframe_sandbox_d_if18.html" height="10" width="10"></iframe>
|
|
||||||
<iframe sandbox="allow-scripts" id="if_19" src="file_iframe_sandbox_d_if19.html" height="10" width="10"></iframe>
|
|
||||||
<iframe id="if_21" name="if_parent2" src="file_iframe_sandbox_d_if21.html" height="10" width="10"></iframe>
|
|
||||||
</div>
|
</div>
|
||||||
<input type='button' id="a_button" onclick='reload_if_8()'>
|
<input type='button' id="a_button" onclick='reload_if_8()'>
|
||||||
<input type='button' id="a_button2" onclick='reload_if_9()'>
|
<input type='button' id="a_button2" onclick='reload_if_9()'>
|
||||||
|
|
|
@ -3042,18 +3042,14 @@ nsDocShell::FindItemWithName(const PRUnichar * aName,
|
||||||
if (!*aName)
|
if (!*aName)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
if (aRequestor) {
|
if (!aRequestor)
|
||||||
// If aRequestor is not null we don't need to check special names, so
|
{
|
||||||
// just hand straight off to the search by actual name function.
|
nsCOMPtr<nsIDocShellTreeItem> foundItem;
|
||||||
return DoFindItemWithName(aName, aRequestor, aOriginalRequestor,
|
|
||||||
_retval);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// This is the entry point into the target-finding algorithm. Check
|
// This is the entry point into the target-finding algorithm. Check
|
||||||
// for special names. This should only be done once, hence the check
|
// for special names. This should only be done once, hence the check
|
||||||
// for a null aRequestor.
|
// for a null aRequestor.
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> foundItem;
|
|
||||||
nsDependentString name(aName);
|
nsDependentString name(aName);
|
||||||
if (name.LowerCaseEqualsLiteral("_self")) {
|
if (name.LowerCaseEqualsLiteral("_self")) {
|
||||||
foundItem = this;
|
foundItem = this;
|
||||||
|
@ -3102,19 +3098,16 @@ nsDocShell::FindItemWithName(const PRUnichar * aName,
|
||||||
// a new window?
|
// a new window?
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
|
||||||
// Do the search for item by an actual name.
|
|
||||||
DoFindItemWithName(aName, aRequestor, aOriginalRequestor,
|
|
||||||
getter_AddRefs(foundItem));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundItem && !CanAccessItem(foundItem, aOriginalRequestor)) {
|
if (foundItem && !CanAccessItem(foundItem, aOriginalRequestor)) {
|
||||||
foundItem = nullptr;
|
foundItem = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DoFindItemWithName only returns active items and we don't check if
|
|
||||||
// the item is active for the special cases.
|
|
||||||
if (foundItem) {
|
if (foundItem) {
|
||||||
|
// We return foundItem here even if it's not an active
|
||||||
|
// item since all the names we've dealt with so far are
|
||||||
|
// special cases that we won't bother looking for further.
|
||||||
|
|
||||||
// If our document is sandboxed, we need to do some extra checks.
|
// If our document is sandboxed, we need to do some extra checks.
|
||||||
uint32_t sandboxFlags = 0;
|
uint32_t sandboxFlags = 0;
|
||||||
|
@ -3136,14 +3129,17 @@ nsDocShell::FindItemWithName(const PRUnichar * aName,
|
||||||
bool isAncestor = false;
|
bool isAncestor = false;
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
|
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
|
||||||
foundItem->GetSameTypeParent(getter_AddRefs(parentAsItem));
|
GetSameTypeParent(getter_AddRefs(parentAsItem));
|
||||||
|
|
||||||
while (parentAsItem) {
|
while (parentAsItem) {
|
||||||
if (parentAsItem == selfAsItem) {
|
nsCOMPtr<nsIDocShellTreeItem> tmp;
|
||||||
|
parentAsItem->GetParent(getter_AddRefs(tmp));
|
||||||
|
|
||||||
|
if (tmp && tmp == selfAsItem) {
|
||||||
isAncestor = true;
|
isAncestor = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nsCOMPtr<nsIDocShellTreeItem> tmp = parentAsItem;
|
parentAsItem = tmp;
|
||||||
tmp->GetSameTypeParent(getter_AddRefs(parentAsItem));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isAncestor) {
|
if (!isAncestor) {
|
||||||
|
@ -3171,17 +3167,12 @@ nsDocShell::FindItemWithName(const PRUnichar * aName,
|
||||||
}
|
}
|
||||||
|
|
||||||
foundItem.swap(*_retval);
|
foundItem.swap(*_retval);
|
||||||
}
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep looking
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsDocShell::DoFindItemWithName(const PRUnichar* aName,
|
|
||||||
nsISupports* aRequestor,
|
|
||||||
nsIDocShellTreeItem* aOriginalRequestor,
|
|
||||||
nsIDocShellTreeItem** _retval)
|
|
||||||
{
|
|
||||||
// First we check our name.
|
// First we check our name.
|
||||||
if (mName.Equals(aName) && ItemIsActive(this) &&
|
if (mName.Equals(aName) && ItemIsActive(this) &&
|
||||||
CanAccessItem(this, aOriginalRequestor)) {
|
CanAccessItem(this, aOriginalRequestor)) {
|
||||||
|
|
|
@ -875,13 +875,6 @@ private:
|
||||||
int32_t mParentCharsetSource;
|
int32_t mParentCharsetSource;
|
||||||
nsCString mOriginalUriString;
|
nsCString mOriginalUriString;
|
||||||
|
|
||||||
// Separate function to do the actual name (i.e. not _top, _self etc.)
|
|
||||||
// searching for FindItemWithName.
|
|
||||||
nsresult DoFindItemWithName(const PRUnichar* aName,
|
|
||||||
nsISupports* aRequestor,
|
|
||||||
nsIDocShellTreeItem* aOriginalRequestor,
|
|
||||||
nsIDocShellTreeItem** _retval);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// We're counting the number of |nsDocShells| to help find leaks
|
// We're counting the number of |nsDocShells| to help find leaks
|
||||||
static unsigned long gNumberOfDocShells;
|
static unsigned long gNumberOfDocShells;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче