Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: http3 OR http2
- Manifest: docshell/test/navigation/mochitest.toml
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<!-- Including SimpleTest.js so we can use waitForExplicitFinish !-->
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<iframe style="width:100%;" id="testframe1"></iframe>
<iframe style="width:100%;" id="testframe2"></iframe>
<script class="testbody" type="text/javascript">
/* Description of the test:
*
* +------------------------------------+
* | +----------+ +--------------+ |
* | | Frame 1 | | Frame 2 | |
* | +----------+ | | |
* | | +----------+ | |
* | | | Subframe | | |
* | | +----------+ | |
* | +--------------+ |
* +------------------------------------+
*
* Frame1: test1.mochi.test
* Frame2: test2.mochi.test
* Subframe: test2.mochi.test
*
* (*) Frame1 and Subframe set their document.domain to mochi.test
* (*) Frame1 navigates the Subframe
* (*) TriggeringPrincipal for the Subframe navigation should be
* ==> test1.mochi.test
* (*) LoadingPrincipal for the Subframe navigation should be
* ==> test2.mochi.test
*/
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
const PATH = "tests/docshell/test/navigation/";
const BASEURL1 = BASEDOMAIN1 + PATH;
const BASEURL2 = BASEDOMAIN2 + PATH;
const TRIGGERINGPRINCIPALURI = BASEURL1 + "file_triggeringprincipal_frame_1.html";
const LOADINGPRINCIPALURI = BASEURL2 + "file_triggeringprincipal_frame_2.html";
SimpleTest.waitForExplicitFinish();
window.addEventListener("message", receiveMessage);
function receiveMessage(event) {
is(event.data.triggeringPrincipalURI, TRIGGERINGPRINCIPALURI,
"TriggeringPrincipal should be the navigating iframe (Frame 1)");
is(event.data.loadingPrincipalURI, LOADINGPRINCIPALURI,
"LoadingPrincipal should be the enclosing iframe (Frame 2)");
is(event.data.referrerURI, BASEDOMAIN1,
"The path of Referrer should be trimmed (Frame 1)");
window.removeEventListener("message", receiveMessage);
SimpleTest.finish();
}
var frame1 = document.getElementById("testframe1");
frame1.src = BASEURL1 + "file_triggeringprincipal_frame_1.html";
var frame2 = document.getElementById("testframe2");
frame2.src = BASEURL2 + "file_triggeringprincipal_frame_2.html";
</script>
</body>
</html>