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>
<script type="text/javascript">
/* We load an third-party iframe which then gets navigated by the iframe's
 * parent by calling iframe.setAttribute("src", same-origin url) later in the
 * test. We then verify the TriggeringPrincipal and LoadingPrincipal of the
 * navigated iframe.
 *
 * +------------------------------------------+
 * |                                          |
 * |  +------------------+                    |
 * |  | testframe        |                    |
 * |  +------------------+                    |
 * |                                          |
 * | iframe.setAttribute("src",               |
 * |                     same-origin url)     |
 * |                                          |
 * +------------------------------------------+
 */
var testframe = document.getElementById("testframe");
window.addEventListener("message", receiveMessage);
const TRIGGERING_PRINCIPAL_URI =
const LOADING_PRINCIPAL_URI = TRIGGERING_PRINCIPAL_URI;
function receiveMessage(event) {
  is(event.data.triggeringPrincipalURI.split("?")[0], TRIGGERING_PRINCIPAL_URI,
     "TriggeringPrincipal should be the parent iframe");
  is(event.data.loadingPrincipalURI.split("?")[0], TRIGGERING_PRINCIPAL_URI,
     "LoadingPrincipal should be the parent iframe");
  window.removeEventListener("message", receiveMessage);
  SimpleTest.finish();
}
function performNavigation() {
  testframe.removeEventListener("load", performNavigation);
  // eslint-disable-next-line @microsoft/sdl/no-insecure-url
  testframe.setAttribute("src", "http://example.com/tests/docshell/test/navigation/file_triggeringprincipal_subframe_same_origin_nav.html");
}
// start the test
SimpleTest.waitForExplicitFinish();
testframe.addEventListener("load", performNavigation);
</script>
</body>
</html>