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>
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 * +---------------------------------------+
23 * | +----------------------------+ |
27 * | +----------------------------+ |
29 * | +----------------------------+ |
32 * | | win.open("http://", "A") | |
33 * | +----------------------------+ |
35 * +---------------------------------------+
37 * Sequence of the test:
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");
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";
80 SimpleTest
.waitForExplicitFinish();
82 frameA
.addEventListener("load", performNavigation
);