2016-08-03 00:42:34 +03:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
2019-04-16 06:50:44 +03:00
|
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
2016-08-03 00:42:34 +03:00
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
<script type="text/javascript" src="NavigationUtils.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<iframe name="framea" id="framea" src="file_triggeringprincipal_iframe_iframe_window_open_frame_a.html"></iframe>
|
|
|
|
<iframe name="frameb" id="frameb"></iframe>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
/* We load an iframe (Frame A) which then gets navigated by another iframe (Frame B)
|
|
|
|
* by calling window.open("http://", "Frame A") later in the test. We then verify the
|
|
|
|
* TriggeringPrincipal and LoadingPrincipal of the navigated iframe (Frame A).
|
|
|
|
*
|
|
|
|
* +---------------------------------------+
|
2018-11-07 16:55:47 +03:00
|
|
|
* | Parent |
|
|
|
|
* | |
|
2016-08-03 00:42:34 +03:00
|
|
|
* | +----------------------------+ |
|
2018-11-07 16:55:47 +03:00
|
|
|
* | | Frame A | |
|
2016-08-03 00:42:34 +03:00
|
|
|
* | | | |
|
|
|
|
* | | | |
|
|
|
|
* | +----------------------------+ |
|
2018-11-07 16:55:47 +03:00
|
|
|
* | |
|
2016-08-03 00:42:34 +03:00
|
|
|
* | +----------------------------+ |
|
2018-11-07 16:55:47 +03:00
|
|
|
* | | Frame B | |
|
2016-08-03 00:42:34 +03:00
|
|
|
* | | | |
|
|
|
|
* | | win.open("http://", "A") | |
|
|
|
|
* | +----------------------------+ |
|
|
|
|
* | |
|
|
|
|
* +---------------------------------------+
|
|
|
|
*
|
|
|
|
* Sequence of the test:
|
|
|
|
* [1] load Frame A
|
|
|
|
* [2] load Frame B which navigates A
|
|
|
|
* [3] load navigated Frame A and check triggeringPrincipal and loadingPrincipal
|
|
|
|
*/
|
|
|
|
|
|
|
|
const TRIGGERING_PRINCIPAL_URI =
|
|
|
|
"http://mochi.test:8888/tests/docshell/test/navigation/file_triggeringprincipal_iframe_iframe_window_open_frame_b.html";
|
|
|
|
|
|
|
|
const LOADING_PRINCIPAL_URI =
|
|
|
|
"http://mochi.test:8888/tests/docshell/test/navigation/test_triggeringprincipal_iframe_iframe_window_open.html";
|
|
|
|
|
|
|
|
var frameA = document.getElementById("framea");
|
|
|
|
|
|
|
|
function checkResults() {
|
2018-11-07 16:55:47 +03:00
|
|
|
frameA.removeEventListener("load", checkResults);
|
2016-08-03 00:42:34 +03:00
|
|
|
|
2018-05-22 02:58:23 +03:00
|
|
|
var channel = SpecialPowers.wrap(frameA.contentWindow).docShell.currentDocumentChannel;
|
2016-08-03 00:42:34 +03:00
|
|
|
var triggeringPrincipal = channel.loadInfo.triggeringPrincipal.URI.asciiSpec;
|
|
|
|
var loadingPrincipal = channel.loadInfo.loadingPrincipal.URI.asciiSpec;
|
|
|
|
|
|
|
|
is(triggeringPrincipal, TRIGGERING_PRINCIPAL_URI,
|
|
|
|
"TriggeringPrincipal for targeted window.open() should be the iframe triggering the load");
|
|
|
|
|
|
|
|
is(frameA.contentDocument.referrer, TRIGGERING_PRINCIPAL_URI,
|
|
|
|
"Referrer for targeted window.open() should be the principal of the iframe triggering the load");
|
|
|
|
|
|
|
|
is(loadingPrincipal, LOADING_PRINCIPAL_URI,
|
|
|
|
"LoadingPrincipal for targeted window.open() should be the containing document");
|
2018-11-07 16:55:47 +03:00
|
|
|
|
2016-08-03 00:42:34 +03:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
function performNavigation() {
|
2018-11-07 16:55:47 +03:00
|
|
|
frameA.removeEventListener("load", performNavigation);
|
|
|
|
frameA.addEventListener("load", checkResults);
|
2016-08-03 00:42:34 +03:00
|
|
|
|
|
|
|
// load Frame B which then navigates Frame A
|
|
|
|
var frameB = document.getElementById("frameb");
|
|
|
|
frameB.src = "file_triggeringprincipal_iframe_iframe_window_open_frame_b.html";
|
|
|
|
}
|
|
|
|
|
|
|
|
// start the test
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2018-11-07 16:55:47 +03:00
|
|
|
frameA.addEventListener("load", performNavigation);
|
2016-08-03 00:42:34 +03:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|