blob: d7046e92367b48e1b4d830b9cbd31c1cff0d6cd5 (
plain)
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
64
65
66
67
68
69
70
71
72
73
74
|
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Bug 1181370 - Test triggeringPrincipal for iframe 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="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
const BASEDOMAIN1 = "http://test1.mochi.test:8888/";
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
const BASEDOMAIN2 = "http://test2.mochi.test:8888/";
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>
|