File: test_reserved.html

package info (click to toggle)
firefox 147.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,320 kB
  • sloc: cpp: 7,607,359; javascript: 6,533,295; ansic: 3,775,223; python: 1,415,500; xml: 634,561; asm: 438,949; java: 186,241; sh: 62,752; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (92 lines) | stat: -rw-r--r-- 3,659 bytes parent folder | download | duplicates (24)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html>
<head>
    <script src="/tests/SimpleTest/SimpleTest.js"></script>
    <script src="/tests/SimpleTest/EventUtils.js"></script>
    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    <script type="text/javascript" src="NavigationUtils.js"></script>
    <style type="text/css">
      iframe { width: 90%; height: 200px; }
    </style>
<script>
if (navigator.platform.startsWith("Mac")) {
  SimpleTest.expectAssertions(0, 2);
}

async function testTop() {
  let window0 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#top,location", "_blank", "width=10,height=10");

  await waitForFinishedFrames(1);
  isInaccessible(window0, "Should be able to navigate off-domain top by setting location.");
  window0.close();
  await cleanupWindows();

  let window1 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,open", "_blank", "width=10,height=10");

  await waitForFinishedFrames(1);
  isInaccessible(window1, "Should be able to navigate off-domain top by calling window.open.");
  window1.close();
  await cleanupWindows();

  let window2 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,form", "_blank", "width=10,height=10");

  await waitForFinishedFrames(1);
  isInaccessible(window2, "Should be able to navigate off-domain top by submitting form.");
  window2.close();
  await cleanupWindows();

  let window3 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,hyperlink", "_blank", "width=10,height=10");

  await waitForFinishedFrames(1);
  isInaccessible(window3, "Should be able to navigate off-domain top by targeted hyperlink.");
  window3.close();
  await cleanupWindows();

  await testParent();
}

async function testParent() {
  document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#parent,location"></iframe>';

  await waitForFinishedFrames(1);
  isAccessible(frames[0], "Should not be able to navigate off-domain parent by setting location.");
  await cleanupWindows();

  document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_parent,open"></iframe>';

  await waitForFinishedFrames(1);
  isAccessible(frames[0], "Should not be able to navigate off-domain parent by calling window.open.");
  await cleanupWindows();

  document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_parent,form"></iframe>';

  await waitForFinishedFrames(1);
  isAccessible(frames[0], "Should not be able to navigate off-domain parent by submitting form.");
  await cleanupWindows();

  document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_parent,hyperlink"></iframe>';

  await waitForFinishedFrames(1);
  isAccessible(frames[0], "Should not be able to navigate off-domain parent by targeted hyperlink.");
  await cleanupWindows();

  document.getElementById("frames").innerHTML = "";
  SimpleTest.finish();
}

window.onload = async function() {
  await testTop();
};
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408052">Mozilla Bug 408052</a>
<div id="frames">
</div>
<pre id="test">
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>