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 <script type=
"text/javascript">
13 /* We call window.open() using different URIs and make sure the triggeringPrincipal
14 * loadingPrincipal are correct.
15 * Test1: window.open(http:)
16 * Test2: window.open(javascript:)
19 const TRIGGERING_PRINCIPAL_URI
=
20 "http://mochi.test:8888/tests/docshell/test/navigation/test_triggeringprincipal_window_open.html";
22 SimpleTest
.waitForExplicitFinish();
27 function checkFinish() {
29 if (test_counter
=== NUM_TESTS
) {
34 // ----------------------------------------------------------------------------
35 // Test 1: window.open(http:)
36 var httpWin
= window
.open("file_triggeringprincipal_window_open.html", "_blank", "width=10,height=10");
37 httpWin
.onload = function() {
38 var httpChannel
= SpecialPowers
.wrap(httpWin
).docShell
.currentDocumentChannel
;
39 var httpTriggeringPrincipal
= httpChannel
.loadInfo
.triggeringPrincipal
.asciiSpec
;
40 var httpLoadingPrincipal
= httpChannel
.loadInfo
.loadingPrincipal
;
42 is(httpTriggeringPrincipal
.split("?")[0], TRIGGERING_PRINCIPAL_URI
,
43 "TriggeringPrincipal for window.open(http:) should be the principal of the document");
45 is(httpWin
.document
.referrer
.split("?")[0], TRIGGERING_PRINCIPAL_URI
,
46 "Referrer for window.open(http:) should be the principal of the document");
48 is(httpLoadingPrincipal
, null,
49 "LoadingPrincipal for window.open(http:) should be null");
55 // ----------------------------------------------------------------------------
56 // Test 2: window.open(javascript:)
57 var jsWin
= window
.open("javascript:'<html><body>js</body></html>';", "_blank", "width=10,height=10");
58 jsWin
.onload = function() {
59 var jsChannel
= SpecialPowers
.wrap(jsWin
).docShell
.currentDocumentChannel
;
60 var jsTriggeringPrincipal
= jsChannel
.loadInfo
.triggeringPrincipal
.asciiSpec
;
61 var jsLoadingPrincipal
= jsChannel
.loadInfo
.loadingPrincipal
;
63 is(jsTriggeringPrincipal
.split("?")[0], TRIGGERING_PRINCIPAL_URI
,
64 "TriggeringPrincipal for window.open(javascript:) should be the principal of the document");
66 is(jsWin
.document
.referrer
, "",
67 "Referrer for window.open(javascript:) should be empty");
69 is(jsLoadingPrincipal
, null,
70 "LoadingPrincipal for window.open(javascript:) should be null");