|
16 | 16 |
|
17 | 17 | promise_test(async t => { |
18 | 18 | const startingHistoryLength = history.length; |
19 | | - // Create an iframe with src set to about:blank. This would trigger a |
20 | | - // navigation to a non-initial about:blank document. |
| 19 | + // Create an iframe with src set to about:blank. Per the HTML Standard, this |
| 20 | + // stays on the "initial about:blank Document" [1], because the "process the |
| 21 | + // iframe attributes" algorithm [2] catches the "about:blank" navigation and |
| 22 | + // fires a special synchronous `load` event at the initial about:blank |
| 23 | + // Document, instead of replacing it with a non-initial, second about:blank |
| 24 | + // Document. This is documented in the note at the end of [3]. |
| 25 | + // |
| 26 | + // [1]: https://html.spec.whatwg.org/#is-initial-about:blank. |
| 27 | + // [2]: https://html.spec.whatwg.org/#process-the-iframe-attributes |
| 28 | + // [3]: https://html.spec.whatwg.org/#completely-finish-loading |
21 | 29 | const iframe = insertIframeWithAboutBlankSrc(t); |
22 | 30 | assert_equals(history.length, startingHistoryLength, |
23 | 31 | "Inserting iframe with src='about:blank' must not change history.length"); |
24 | 32 |
|
25 | | - // Trigger a navigation to url1 through the iframe's src attribute. |
26 | | - // The iframe should still be on the initial empty document, and the |
27 | | - // navigation should do replacement. |
| 33 | + // Trigger a navigation from the initial about:blank Document, to url1 through |
| 34 | + // the iframe's src attribute. Because we're navigating from the initial |
| 35 | + // about:blank Document, the navigation should be a replacement. |
28 | 36 | iframe.src = url1; |
| 37 | + |
29 | 38 | // Wait for the latest navigation to finish. |
30 | 39 | await waitForLoad(t, iframe, url1); |
31 | 40 | assert_equals(history.length, startingHistoryLength, |
32 | | - "history.length must not change after normal navigation on initial empty document"); |
33 | | -}, "Navigating to a different document with src"); |
| 41 | + "history.length must not change after normal navigation from initial " + |
| 42 | + "about:blank Document"); |
| 43 | +}, "Navigating away from the initial about:blank Document to a different " + |
| 44 | + "one, with src"); |
34 | 45 |
|
35 | 46 | promise_test(async t => { |
36 | 47 | const startingHistoryLength = history.length; |
37 | | - // Create an iframe with src set to about:blank but navigate away from it immediately below. |
38 | 48 | const iframe = insertIframeWithAboutBlankSrc(t); |
39 | 49 | assert_equals(history.length, startingHistoryLength, |
40 | 50 | "Inserting iframe with src='about:blank' must not change history.length"); |
41 | 51 |
|
42 | | - // Navigate away from the initial empty document through setting |
43 | | - // location.href. The iframe should still be on the initial empty document, |
44 | | - // and the navigation should do replacement. |
| 52 | + // Trigger a navigation from the initial about:blank Document, to url1 through |
| 53 | + // location.href. Because we're navigating from the initial about:blank |
| 54 | + // Document, the navigation should be a replacement. |
45 | 55 | iframe.contentWindow.location.href = url1; |
46 | 56 | await waitForLoad(t, iframe, url1); |
47 | 57 | assert_equals(history.length, startingHistoryLength, |
|
50 | 60 |
|
51 | 61 | promise_test(async t => { |
52 | 62 | const startingHistoryLength = history.length; |
53 | | - // Create an iframe with src set to about:blank but navigate away from it immediately below. |
54 | 63 | const iframe = insertIframeWithAboutBlankSrc(t); |
55 | 64 | assert_equals(history.length, startingHistoryLength, |
56 | 65 | "Inserting iframe with src='about:blank' must not change history.length"); |
57 | 66 |
|
58 | | - // Navigate away from the initial empty document through location.assign(). |
59 | | - // The iframe should still be on the initial empty document, and the |
60 | | - // navigation should do replacement. |
| 67 | + // Trigger a navigation from the initial about:blank Document, to url1 through |
| 68 | + // location.assign(). Because we're navigating from the initial about:blank |
| 69 | + // Document, the navigation should be a replacement. |
61 | 70 | iframe.contentWindow.location.assign(url1); |
62 | 71 | await waitForLoad(t, iframe, url1); |
63 | 72 | assert_equals(history.length, startingHistoryLength, |
|
66 | 75 |
|
67 | 76 | promise_test(async t => { |
68 | 77 | const startingHistoryLength = history.length; |
69 | | - // Create an iframe with src set to about:blank but navigate away from it immediately below. |
70 | 78 | const iframe = insertIframeWithAboutBlankSrc(t); |
71 | 79 | assert_equals(history.length, startingHistoryLength, |
72 | 80 | "Inserting iframe with src='about:blank' must not change history.length"); |
73 | 81 |
|
74 | | - // Navigate away from the initial empty document through window.open(). |
75 | | - // The iframe should still be on the initial empty document, and the |
76 | | - // navigation should do replacement. |
| 82 | + // Trigger a navigation from the initial about:blank Document, to url1 through |
| 83 | + // window.open(). Because we're navigating from the initial about:blank |
| 84 | + // Document, the navigation should be a replacement. |
77 | 85 | iframe.contentWindow.open(url1, "_self"); |
78 | 86 | await waitForLoad(t, iframe, url1); |
79 | 87 | assert_equals(history.length, startingHistoryLength, |
|
82 | 90 |
|
83 | 91 | promise_test(async t => { |
84 | 92 | const startingHistoryLength = history.length; |
85 | | - // Create an iframe with src set to about:blank but navigate away from it immediately below. |
86 | 93 | const iframe = insertIframeWithAboutBlankSrc(t); |
87 | 94 | assert_equals(history.length, startingHistoryLength, |
88 | 95 | "Inserting iframe with src='about:blank' must not change history.length"); |
89 | 96 |
|
90 | | - // Navigate away from the initial empty document through clicking an <a> |
91 | | - // element. The iframe should still be on the initial empty document, and the |
92 | | - // navigation should do replacement. |
| 97 | + // Trigger a navigation from the initial about:blank Document, to url1 through |
| 98 | + // clicking an `<a>` element. Because we're navigating from the initial |
| 99 | + // about:blank Document, the navigation should be a replacement. |
93 | 100 | const a = iframe.contentDocument.createElement("a"); |
94 | 101 | a.href = url1; |
95 | 102 | iframe.contentDocument.body.appendChild(a); |
|
101 | 108 |
|
102 | 109 | promise_test(async t => { |
103 | 110 | const startingHistoryLength = history.length; |
104 | | - // Create an iframe with src set to about:blank but navigate away from it immediately below. |
105 | 111 | const iframe = insertIframeWithAboutBlankSrc(t); |
106 | 112 | assert_equals(history.length, startingHistoryLength, |
107 | 113 | "Inserting iframe with src='about:blank' must not change history.length"); |
108 | 114 |
|
109 | | - // Navigate away from the initial empty document through form submission. |
110 | | - // The iframe should still be on the initial empty document, and the |
111 | | - // navigation should do replacement. |
| 115 | + // Trigger a navigation from the initial about:blank Document, to url1 through |
| 116 | + // a form submission. Because we're navigating from the initial about:blank |
| 117 | + // Document, the navigation should be a replacement. |
112 | 118 | const form = iframe.contentDocument.createElement("form"); |
113 | 119 | form.action = "/common/blank.html"; |
114 | 120 | iframe.contentDocument.body.appendChild(form); |
|
0 commit comments