File: iframe-src-aboutblank-navigate-immediately.html

package info (click to toggle)
thunderbird 1%3A144.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,725,312 kB
  • sloc: cpp: 7,869,225; javascript: 5,974,276; ansic: 3,946,747; python: 1,421,062; xml: 654,642; asm: 474,045; java: 183,117; sh: 110,973; makefile: 20,398; perl: 14,362; objc: 13,086; yacc: 4,583; pascal: 3,448; lex: 1,720; ruby: 999; exp: 762; sql: 731; awk: 580; php: 436; lisp: 430; sed: 69; csh: 10
file content (124 lines) | stat: -rw-r--r-- 5,975 bytes parent folder | download | duplicates (20)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Navigations immediately after appending iframe with src='about:blank'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<body></body>
<script>
/*
  When an iframe is created with src="about:blank", it will stay on the initial
  empty document. These tests verify the behavior of navigations that happen
  immediately after the iframe is created, which should result in replacement.
*/
"use strict";
const url1 = "/common/blank.html?1";

promise_test(async t => {
  const startingHistoryLength = history.length;
  // Create an iframe with src set to about:blank. This would trigger a
  // navigation to a non-initial about:blank document.
  const iframe = insertIframeWithAboutBlankSrc(t);
  assert_equals(history.length, startingHistoryLength,
    "Inserting iframe with src='about:blank' must not change history.length");

  // Trigger a navigation to url1 through the iframe's src attribute.
  // The iframe should still be on the initial empty document, and the
  // navigation should do replacement.
  iframe.src = url1;
  // Wait for the latest navigation to finish.
  await waitForLoad(t, iframe, url1);
  assert_equals(history.length, startingHistoryLength,
    "history.length must not change after normal navigation on initial empty document");
}, "Navigating to a different document with src");

promise_test(async t => {
  const startingHistoryLength = history.length;
  // Create an iframe with src set to about:blank but navigate away from it immediately below.
  const iframe = insertIframeWithAboutBlankSrc(t);
  assert_equals(history.length, startingHistoryLength,
    "Inserting iframe with src='about:blank' must not change history.length");

  // Navigate away from the initial empty document through setting
  // location.href. The iframe should still be on the initial empty document,
  // and the navigation should do replacement.
  iframe.contentWindow.location.href = url1;
  await waitForLoad(t, iframe, url1);
  assert_equals(history.length, startingHistoryLength,
    "history.length must not change after normal navigation on initial empty document");
}, "Navigating to a different document with location.href");

promise_test(async t => {
  const startingHistoryLength = history.length;
  // Create an iframe with src set to about:blank but navigate away from it immediately below.
  const iframe = insertIframeWithAboutBlankSrc(t);
  assert_equals(history.length, startingHistoryLength,
    "Inserting iframe with src='about:blank' must not change history.length");

  // Navigate away from the initial empty document through location.assign().
  // The iframe should still be on the initial empty document, and the
  // navigation should do replacement.
  iframe.contentWindow.location.assign(url1);
  await waitForLoad(t, iframe, url1);
  assert_equals(history.length, startingHistoryLength,
    "history.length must not change after normal navigation on initial empty document");
}, "Navigating to a different document with location.assign");

promise_test(async t => {
  const startingHistoryLength = history.length;
  // Create an iframe with src set to about:blank but navigate away from it immediately below.
  const iframe = insertIframeWithAboutBlankSrc(t);
  assert_equals(history.length, startingHistoryLength,
    "Inserting iframe with src='about:blank' must not change history.length");

  // Navigate away from the initial empty document through window.open().
  // The iframe should still be on the initial empty document, and the
  // navigation should do replacement.
  iframe.contentWindow.open(url1, "_self");
  await waitForLoad(t, iframe, url1);
  assert_equals(history.length, startingHistoryLength,
    "history.length must not change after normal navigation on initial empty document");
}, "Navigating to a different document with window.open");

promise_test(async t => {
  const startingHistoryLength = history.length;
  // Create an iframe with src set to about:blank but navigate away from it immediately below.
  const iframe = insertIframeWithAboutBlankSrc(t);
  assert_equals(history.length, startingHistoryLength,
    "Inserting iframe with src='about:blank' must not change history.length");

  // Navigate away from the initial empty document through clicking an <a>
  // element. The iframe should still be on the initial empty document, and the
  // navigation should do replacement.
  const a = iframe.contentDocument.createElement("a");
  a.href = url1;
  iframe.contentDocument.body.appendChild(a);
  a.click();
  await waitForLoad(t, iframe, url1);
  assert_equals(history.length, startingHistoryLength,
    "history.length must not change after normal navigation on initial empty document");
}, "Navigating to a different document with link click");

promise_test(async t => {
  const startingHistoryLength = history.length;
  // Create an iframe with src set to about:blank but navigate away from it immediately below.
  const iframe = insertIframeWithAboutBlankSrc(t);
  assert_equals(history.length, startingHistoryLength,
    "Inserting iframe with src='about:blank' must not change history.length");

  // Navigate away from the initial empty document through form submission.
  // The iframe should still be on the initial empty document, and the
  // navigation should do replacement.
  const form = iframe.contentDocument.createElement("form");
  form.action = "/common/blank.html";
  iframe.contentDocument.body.appendChild(form);
  const input = iframe.contentDocument.createElement("input");
  input.type = "hidden";
  input.name = "1";
  form.append(input);
  form.submit();
  await waitForLoad(t, iframe, url1 + "=");
  assert_equals(history.length, startingHistoryLength,
    "history.length must not change after normal navigation on initial empty document");
}, "Navigating to a different document with form submission");
</script>