|
1 <!DOCTYPE html> |
|
2 <html> |
|
3 <head> |
|
4 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
5 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
7 <script type="text/javascript" src="NavigationUtils.js"></script> |
|
8 <style type="text/css"> |
|
9 iframe { width: 90%; height: 200px; } |
|
10 </style> |
|
11 <script> |
|
12 if (navigator.platform.startsWith("Mac")) { |
|
13 SimpleTest.expectAssertions(0, 2); |
|
14 } |
|
15 |
|
16 function testTop() { |
|
17 window0 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#top,location", "_blank", "width=10,height=10"); |
|
18 |
|
19 xpcWaitForFinishedFrames(function() { |
|
20 isInaccessible(window0, "Should be able to navigate off-domain top by setting location."); |
|
21 window0.close(); |
|
22 xpcCleanupWindows(); |
|
23 |
|
24 window1 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,open", "_blank", "width=10,height=10"); |
|
25 |
|
26 xpcWaitForFinishedFrames(function() { |
|
27 isInaccessible(window1, "Should be able to navigate off-domain top by calling window.open."); |
|
28 window1.close(); |
|
29 xpcCleanupWindows(); |
|
30 |
|
31 window2 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,form", "_blank", "width=10,height=10"); |
|
32 |
|
33 xpcWaitForFinishedFrames(function() { |
|
34 isInaccessible(window2, "Should be able to navigate off-domain top by submitting form."); |
|
35 window2.close(); |
|
36 xpcCleanupWindows(); |
|
37 |
|
38 window3 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,hyperlink", "_blank", "width=10,height=10"); |
|
39 |
|
40 xpcWaitForFinishedFrames(function() { |
|
41 isInaccessible(window3, "Should be able to navigate off-domain top by targeted hyperlink."); |
|
42 window3.close(); |
|
43 xpcCleanupWindows(); |
|
44 |
|
45 testParent(); |
|
46 }, 1); |
|
47 }, 1); |
|
48 }, 1); |
|
49 }, 1); |
|
50 } |
|
51 |
|
52 function testParent() { |
|
53 document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#parent,location"></iframe>'; |
|
54 |
|
55 xpcWaitForFinishedFrames(function() { |
|
56 isAccessible(frames[0], "Should not be able to navigate off-domain parent by setting location."); |
|
57 xpcCleanupWindows(); |
|
58 |
|
59 document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_parent,open"></iframe>'; |
|
60 |
|
61 xpcWaitForFinishedFrames(function() { |
|
62 isAccessible(frames[0], "Should not be able to navigate off-domain parent by calling window.open."); |
|
63 xpcCleanupWindows(); |
|
64 |
|
65 document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_parent,form"></iframe>'; |
|
66 |
|
67 xpcWaitForFinishedFrames(function() { |
|
68 isAccessible(frames[0], "Should not be able to navigate off-domain parent by submitting form."); |
|
69 xpcCleanupWindows(); |
|
70 |
|
71 document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_parent,hyperlink"></iframe>'; |
|
72 |
|
73 xpcWaitForFinishedFrames(function() { |
|
74 isAccessible(frames[0], "Should not be able to navigate off-domain parent by targeted hyperlink."); |
|
75 xpcCleanupWindows(); |
|
76 |
|
77 document.getElementById("frames").innerHTML = ""; |
|
78 SimpleTest.finish(); |
|
79 }, 1); |
|
80 }, 1); |
|
81 }, 1); |
|
82 }, 1); |
|
83 } |
|
84 |
|
85 window.onload = function() { |
|
86 testTop(); |
|
87 } |
|
88 </script> |
|
89 </head> |
|
90 <body> |
|
91 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408052">Mozilla Bug 408052</a> |
|
92 <div id="frames"> |
|
93 </div> |
|
94 <pre id="test"> |
|
95 <script type="text/javascript"> |
|
96 SimpleTest.waitForExplicitFinish(); |
|
97 </script> |
|
98 </pre> |
|
99 </body> |
|
100 </html> |