no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / docshell / test / navigation / test_recursive_frames.html
blob3ccc09dd14c4eadea90576f07cacba40462dd34a
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test for Recursive Loads</title>
5 <meta charset="utf-8">
6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
8 </head>
9 <body>
10 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1597427">Mozilla Bug 1597427</a>
11 <p id="display"></p>
12 <div id="content" style="display: none">
14 </div>
15 <pre id="test">
16 <script type="application/javascript">
17 const TEST_CASES = [
18 { // too many recursive iframes
19 frameId: "recursiveFrame",
20 expectedLocations: [
21 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
22 "http://example.com/tests/docshell/test/navigation/frame_recursive.html",
23 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
24 "http://example.com/tests/docshell/test/navigation/frame_recursive.html",
25 "about:blank",
28 { // too many recursive iframes
29 frameId: "twoRecursiveIframes",
30 expectedLocations: [
31 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
32 "http://example.com/tests/docshell/test/navigation/frame_load_as_example_com.html",
33 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
34 "http://example.org/tests/docshell/test/navigation/frame_load_as_example_org.html",
35 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
36 "http://example.com/tests/docshell/test/navigation/frame_load_as_example_com.html",
37 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
38 "http://example.org/tests/docshell/test/navigation/frame_load_as_example_org.html",
39 "about:blank",
42 { // too many recursive iframes
43 frameId: "threeRecursiveIframes",
44 expectedLocations: [
45 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
46 "http://sub1.test1.mochi.test:8888/tests/docshell/test/navigation/frame_load_as_host1.html",
47 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
48 "http://example.com/tests/docshell/test/navigation/frame_load_as_host2.html",
49 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
50 "http://test1.mochi.test:8888/tests/docshell/test/navigation/frame_load_as_host3.html",
51 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
52 "http://sub1.test1.mochi.test:8888/tests/docshell/test/navigation/frame_load_as_host1.html",
53 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
54 "http://example.com/tests/docshell/test/navigation/frame_load_as_host2.html",
55 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
56 "http://test1.mochi.test:8888/tests/docshell/test/navigation/frame_load_as_host3.html",
57 "about:blank",
60 { // too many nested iframes
61 frameId: "sixRecursiveIframes",
62 expectedLocations: [
63 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
64 "http://example.com/tests/docshell/test/navigation/frame_1_out_of_6.html",
65 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
66 "http://test1.mochi.test:8888/tests/docshell/test/navigation/frame_2_out_of_6.html",
67 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
68 "http://sub1.test1.mochi.test:8888/tests/docshell/test/navigation/frame_3_out_of_6.html",
69 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
70 "http://sub2.xn--lt-uia.mochi.test:8888/tests/docshell/test/navigation/frame_4_out_of_6.html",
71 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
72 "http://test2.mochi.test:8888/tests/docshell/test/navigation/frame_5_out_of_6.html",
73 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
74 "http://example.org/tests/docshell/test/navigation/frame_6_out_of_6.html",
75 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
76 "http://example.com/tests/docshell/test/navigation/frame_1_out_of_6.html",
77 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
78 "http://test1.mochi.test:8888/tests/docshell/test/navigation/frame_2_out_of_6.html",
81 { // too many recursive objects
82 frameId: "recursiveObject",
83 expectedLocations: [
84 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
85 "http://sub2.xn--lt-uia.mochi.test:8888/tests/docshell/test/navigation/object_recursive_load.html",
86 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
87 "http://sub2.xn--lt-uia.mochi.test:8888/tests/docshell/test/navigation/object_recursive_load.html",
90 { // 3 nested srcdocs, should show all of them
91 frameId: "nestedSrcdoc",
92 expectedLocations: [
93 "about:srcdoc",
94 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
95 "http://example.com/tests/docshell/test/navigation/file_nested_srcdoc.html",
96 "about:srcdoc",
97 "about:srcdoc",
102 async function checkRecursiveLoad(level) {
103 let el = content.document.getElementById("static");
104 let documentURI = await SpecialPowers.spawn(
107 () => this.content.document.documentURI
109 if (documentURI == "about:blank") {
110 // If we had too many recursive frames, the most inner iframe's uri will be about:blank
111 return [documentURI];
113 if (documentURI == "about:srcdoc" && level == 3) {
114 // Check that we have the correct most inner srcdoc iframe
115 let innerText = await SpecialPowers.spawn(
118 () => this.content.document.body.innerText
120 is(innerText, "Third nested srcdoc", "correct most inner srcdoc iframe");
122 let nestedIfrOrObjectURI = [];
123 try {
124 // Throws an error when we have too many nested frames/objects, because we
125 // claim to have no content window for the inner most frame/object.
126 nestedIfrOrObjectURI = await SpecialPowers.spawn(
128 [level + 1],
129 checkRecursiveLoad
131 } catch (err) {
132 info(
133 `Tried to spawn another task in the iframe/object, but got err: ${err}, must have had too many nested iframes/objects\n`
136 return [documentURI, ...nestedIfrOrObjectURI];
139 add_task(async () => {
140 for (const testCase of TEST_CASES) {
141 let el = document.getElementById(testCase.frameId);
142 let loc = await SpecialPowers.spawn(
145 () => this.content.location.href
147 let locations = await SpecialPowers.spawn(el, [1], checkRecursiveLoad);
148 isDeeply(
149 [loc, ...locations],
150 testCase.expectedLocations,
151 "iframes/object loaded in correct order"
156 </script>
157 </pre>
158 <div>
159 <iframe style="height: 100vh; width:25%;" id="recursiveFrame" src="http://example.com/tests/docshell/test/navigation/frame_recursive.html"></iframe>
160 <iframe style="height: 100vh; width:25%;" id="twoRecursiveIframes" src="http://example.com/tests/docshell/test/navigation/frame_load_as_example_com.html"></iframe>
161 <iframe style="height: 100vh; width:25%;" id="threeRecursiveIframes" src="http://sub1.test1.mochi.test:8888/tests/docshell/test/navigation/frame_load_as_host1.html"></iframe>
162 <iframe style="height: 100vh; width:25%;" id="sixRecursiveIframes" src="http://example.com/tests/docshell/test/navigation/frame_1_out_of_6.html"></iframe>
163 <object width="400" height="300" id="recursiveObject" data="http://sub2.xn--lt-uia.mochi.test:8888/tests/docshell/test/navigation/object_recursive_load.html"></object>
164 <iframe id="nestedSrcdoc" srcdoc="Srcdoc that will embed an iframe &lt;iframe id=&quot;static&quot; src=&quot;http://example.com/tests/docshell/test/navigation/file_nested_srcdoc.html&quot;&gt;&lt;/iframe&gt;"></iframe>
165 </div>
166 </body>
167 </html>