1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test 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="application/javascript">
var test27Context = "Test 27: navigate opened window by name with anchor: ";
var test28Context = "Test 28: navigate opened window by name with window.open(): ";
var windowsToClose = new Array();
function closeWindows() {
for (var i = 0; i < windowsToClose.length; i++) {
windowsToClose[i].close();
}
}
// Add message listener to forward messages on to parent
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
switch (event.data.type) {
case "closeWindows":
closeWindows();
break;
default:
window.parent.postMessage(event.data, "*");
}
}
function doTest() {
try {
windowsToClose.push(window.open("about:blank", "test27window"));
var test27Anchor = document.getElementById("test27Anchor");
test27Anchor.href = "file_iframe_sandbox_window_navigation_pass.html?" + escape(test27Context);
sendMouseEvent({type:"click"}, "test27Anchor");
window.parent.postMessage({type: "attempted"}, "*");
} catch(error) {
window.parent.postMessage({ok: false, desc: test27Context + "error thrown during window.open(): " + error}, "*");
}
try {
windowsToClose.push(window.open("about:blank", "test28window"));
window.open("file_iframe_sandbox_window_navigation_pass.html?" + escape(test28Context), "test28window");
window.parent.postMessage({type: "attempted"}, "*");
} catch(error) {
window.parent.postMessage({ok: false, desc: test28Context + "error thrown during window.open(): " + error}, "*");
}
}
</script>
<body onload="doTest()">
I am sandboxed with 'allow-scripts allow-popups'
<a id="test27Anchor" target="test27window">Test 27 anchor</a>
</body>
</html>
|