no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / docshell / test / navigation / test_triggeringprincipal_iframe_iframe_window_open.html
blob115c5f4462c35b1e5409da50507a7642a552d42a
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="/tests/SimpleTest/SimpleTest.js"></script>
5 <script 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 </head>
9 <body>
11 <iframe name="framea" id="framea" src="file_triggeringprincipal_iframe_iframe_window_open_frame_a.html"></iframe>
12 <iframe name="frameb" id="frameb"></iframe>
14 <script type="text/javascript">
16 /* We load an iframe (Frame A) which then gets navigated by another iframe (Frame B)
17 * by calling window.open("http://", "Frame A") later in the test. We then verify the
18 * TriggeringPrincipal and LoadingPrincipal of the navigated iframe (Frame A).
20 * +---------------------------------------+
21 * | Parent |
22 * | |
23 * | +----------------------------+ |
24 * | | Frame A | |
25 * | | | |
26 * | | | |
27 * | +----------------------------+ |
28 * | |
29 * | +----------------------------+ |
30 * | | Frame B | |
31 * | | | |
32 * | | win.open("http://", "A") | |
33 * | +----------------------------+ |
34 * | |
35 * +---------------------------------------+
37 * Sequence of the test:
38 * [1] load Frame A
39 * [2] load Frame B which navigates A
40 * [3] load navigated Frame A and check triggeringPrincipal and loadingPrincipal
43 const TRIGGERING_PRINCIPAL_URI =
44 "http://mochi.test:8888/tests/docshell/test/navigation/file_triggeringprincipal_iframe_iframe_window_open_frame_b.html";
46 const LOADING_PRINCIPAL_URI =
47 "http://mochi.test:8888/tests/docshell/test/navigation/test_triggeringprincipal_iframe_iframe_window_open.html";
49 var frameA = document.getElementById("framea");
51 function checkResults() {
52 frameA.removeEventListener("load", checkResults);
54 var channel = SpecialPowers.wrap(frameA.contentWindow).docShell.currentDocumentChannel;
55 var triggeringPrincipal = channel.loadInfo.triggeringPrincipal.asciiSpec;
56 var loadingPrincipal = channel.loadInfo.loadingPrincipal.asciiSpec;
58 is(triggeringPrincipal, TRIGGERING_PRINCIPAL_URI,
59 "TriggeringPrincipal for targeted window.open() should be the iframe triggering the load");
61 is(frameA.contentDocument.referrer, TRIGGERING_PRINCIPAL_URI,
62 "Referrer for targeted window.open() should be the principal of the iframe triggering the load");
64 is(loadingPrincipal.split("?")[0], LOADING_PRINCIPAL_URI,
65 "LoadingPrincipal for targeted window.open() should be the containing document");
67 SimpleTest.finish();
70 function performNavigation() {
71 frameA.removeEventListener("load", performNavigation);
72 frameA.addEventListener("load", checkResults);
74 // load Frame B which then navigates Frame A
75 var frameB = document.getElementById("frameb");
76 frameB.src = "file_triggeringprincipal_iframe_iframe_window_open_frame_b.html";
79 // start the test
80 SimpleTest.waitForExplicitFinish();
82 frameA.addEventListener("load", performNavigation);
84 </script>
85 </pre>
86 </body>
87 </html>