File: window-open-aboutblank.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 (81 lines) | stat: -rw-r--r-- 3,594 bytes parent folder | download | duplicates (21)
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
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Navigations on window.open(about:blank) after waiting for it to load</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<body></body>
<script>
/*
  When a new window is opened through window.open() it will contain the initial
  empty document. If the URL parameter is set to about:blank, it will stay on
  the initial empty document (unlike iframes with src="about:blank", which will
  start a navigation to a non-initial about:blank document).
  These tests verify the behavior of navigations that happen on the initial
  empty document in that situation. They should all be converted to do a
  replacement.
*/
"use strict";
const url1 = "resources/code-injector.html?1&pipe=sub(none)&code=" +
              encodeURIComponent(postMessageToOpenerOnLoad);
const url2 = "resources/code-injector.html?2&pipe=sub(none)&code=" +
              encodeURIComponent(postMessageToOpenerOnLoad);

promise_test(async t => {
  // Open a window with URL about:blank, which will commit the
  // initial empty document and stay on it.
  const openedWindow = windowOpenAboutBlank(t);

  // Unlike iframe with src="about:blank", window.open("about:blank") won't
  // trigger a navigation to a non-initial about:blank document, so it should
  // stay on the initial empty document. To verify, wait for 100ms before
  // continuing.
  await new Promise((resolve) => t.step_timeout(resolve, 100));

  // Navigate away from the initial empty document through location.href.
  // This should do a replacement.
  openedWindow.location.href = url1;
  await waitForMessage(t, "loaded");
  assert_equals(openedWindow.history.length, 1,
    "history.length should not increase after normal navigation away from initial empty document");
}, "location.href");

promise_test(async t => {
  // Open a window with URL about:blank, which will commit the
  // initial empty document and stay on it.
  const openedWindow = windowOpenAboutBlank(t);

  // Unlike iframe with src="about:blank", window.open("about:blank") won't
  // trigger a navigation to a non-initial about:blank document, so it should
  // stay on the initial empty document. To verify, wait for 100ms before
  // continuing.
  await new Promise((resolve) => t.step_timeout(resolve, 100));

  // Navigate away from the initial empty document through location.assign().
  // This should do a replacement.
  openedWindow.location.assign(url1);
  await waitForMessage(t, "loaded");
  assert_equals(openedWindow.history.length, 1,
    "history.length should not increase after normal navigation away from initial empty document");
}, "location.assign");
/*
promise_test(async t => {
  // Open a window with URL about:blank, which will commit the
  // initial empty document and stay on it.
  const openedWindow = windowOpenAboutBlank(t);

  // Unlike iframe with src="about:blank", window.open("about:blank") won't
  // trigger a navigation to a non-initial about:blank document, so it should
  // stay on the initial empty document. To verify, wait for 100ms before
  // continuing.
  await new Promise((resolve) => t.step_timeout(resolve, 100));

  // Navigate away from the initial empty document through window.open().
  // This should do a replacement.
  openedWindow.open(url1, "_self");
  await waitForMessage(t, "loaded");
  assert_equals(openedWindow.history.length, 1,
    "history.length should not increase after normal navigation away from initial empty document");
}, "window.open");
*/
</script>