File: test_triggeringprincipal_frame_same_origin_nav.html

package info (click to toggle)
thunderbird 1%3A140.4.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 4,609,432 kB
  • sloc: cpp: 7,672,442; javascript: 5,901,613; ansic: 3,898,954; python: 1,413,343; xml: 653,997; asm: 462,286; java: 180,927; sh: 113,489; makefile: 20,460; perl: 14,288; objc: 13,059; yacc: 4,583; pascal: 3,352; lex: 1,720; ruby: 1,222; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (63 lines) | stat: -rw-r--r-- 2,347 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Bug 1639195 - Test triggeringPrincipal for iframe same-origin navigations</title>
  <!-- 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="testframe" src="http://example.com/"></iframe>

<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 =
  "http://mochi.test:8888/tests/docshell/test/navigation/test_triggeringprincipal_frame_same_origin_nav.html";

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>