<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[281502] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/281502">281502</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2021-08-24 11:18:22 -0700 (Tue, 24 Aug 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fire a load event for <iframe src="about:blank#foo">
https://bugs.webkit.org/show_bug.cgi?id=228958
<rdar://problem/82035810>

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Import layout test coverage from WPT.

* web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/initial-content-replacement-expected.txt: Added.
* web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/initial-content-replacement.html: Added.
* web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element-expected.txt: Added.
* web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element.html: Added.
* web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow-expected.txt: Added.
* web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html: Added.
* web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open-expected.txt: Added.
* web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open.html: Added.
* web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/resources/helpers.js: Added.
(assertNoLoadAndPageshowEvent):

Source/WebCore:

When loading an iframe with src="about:blank#foo", we would fail to fire the load event because we would treat
the navigation as a fragment navigation. The reason for that is that the iframe is initially displaying the
initial empty document, which has URL "about:blank". Because the source and destination URL would be the same
when ignoring fragments, our logic would treat this as a pure fragment navigation. To address this, I have
updated FrameLoader::shouldPerformFragmentNavigation() to special case the initial empty document.

Test: imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element.html

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::shouldPerformFragmentNavigation):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/</li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentinitialcontentreplacementexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/initial-content-replacement-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentinitialcontentreplacementhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/initial-content-replacement.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentloadeventiframeelementexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentloadeventiframeelementhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentloadpageshoweventsiframecontentWindowexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentloadpageshoweventsiframecontentWindowhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentloadpageshoweventswindowopenexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentloadpageshoweventswindowopenhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open.html</a></li>
<li>trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/resources/</li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentresourceshelpersjs">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/resources/helpers.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (281501 => 281502)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-08-24 18:00:51 UTC (rev 281501)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2021-08-24 18:18:22 UTC (rev 281502)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2021-08-24  Chris Dumez  <cdumez@apple.com>
+
+        Fire a load event for <iframe src="about:blank#foo">
+        https://bugs.webkit.org/show_bug.cgi?id=228958
+        <rdar://problem/82035810>
+
+        Reviewed by Darin Adler.
+
+        Import layout test coverage from WPT.
+
+        * web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/initial-content-replacement-expected.txt: Added.
+        * web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/initial-content-replacement.html: Added.
+        * web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element-expected.txt: Added.
+        * web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element.html: Added.
+        * web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow-expected.txt: Added.
+        * web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html: Added.
+        * web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open-expected.txt: Added.
+        * web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open.html: Added.
+        * web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/resources/helpers.js: Added.
+        (assertNoLoadAndPageshowEvent):
+
</ins><span class="cx"> 2021-08-24  Tim Nguyen  <ntim@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Move cancel dialog task to `defaultKeyboardEventHandler`.
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentinitialcontentreplacementexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/initial-content-replacement-expected.txt (0 => 281502)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/initial-content-replacement-expected.txt                             (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/initial-content-replacement-expected.txt        2021-08-24 18:18:22 UTC (rev 281502)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+
+
+PASS Content synchronously added to <iframe> with no src won't get replaced
+PASS Content synchronously added to <iframe> with src='' won't get replaced
+PASS Content synchronously added to <iframe> with src='about:blank' won't get replaced
+PASS Content synchronously added to <iframe> with src='about:blank#foo' won't get replaced
+PASS Content synchronously added to <iframe> with src='about:blank?foo' won't get replaced
+PASS Content synchronously added to window.open()-ed document won't get replaced
+PASS Content synchronously added to window.open('')-ed document won't get replaced
+PASS Content synchronously added to window.open('about:blank')-ed document won't get replaced
+PASS Content synchronously added to window.open('about:blank#foo')-ed document won't get replaced
+PASS Content synchronously added to window.open('about:blank?foo')-ed document won't get replaced
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentinitialcontentreplacementhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/initial-content-replacement.html (0 => 281502)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/initial-content-replacement.html                             (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/initial-content-replacement.html        2021-08-24 18:18:22 UTC (rev 281502)
</span><span class="lines">@@ -0,0 +1,86 @@
</span><ins>+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>
+  Content synchronously added to iframe/opened window's document after creation
+  won't get replaced asynchronously when staying on the initial empty document
+</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/helpers.js"></script>
+<body></body>
+<script>
+"use strict";
+
+// Asserts the document on |w| stays the same after waiting 100ms.
+function assertDocumentStaysTheSame(t, w) {
+  const initialDocument = w.document;
+  initialDocument.body.innerHTML = "foo";
+  return new Promise((resolve) => {
+    t.step_timeout(() => {
+      assert_equals(w.document.body.innerHTML, "foo");
+      assert_equals(w.document, initialDocument);
+      resolve();
+    }, 100);
+  });
+}
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  document.body.appendChild(iframe);
+  await assertDocumentStaysTheSame(t, iframe.contentWindow);
+}, "Content synchronously added to <iframe> with no src won't get replaced");
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  iframe.src = "";
+  document.body.appendChild(iframe);
+  await assertDocumentStaysTheSame(t, iframe.contentWindow);
+}, "Content synchronously added to <iframe> with src='' won't get replaced");
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  iframe.src = "about:blank";
+  document.body.appendChild(iframe);
+  await assertDocumentStaysTheSame(t, iframe.contentWindow);
+}, "Content synchronously added to <iframe> with src='about:blank' won't get replaced");
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  iframe.src = "about:blank#foo";
+  document.body.appendChild(iframe);
+  await assertDocumentStaysTheSame(t, iframe.contentWindow);
+}, "Content synchronously added to <iframe> with src='about:blank#foo' won't get replaced");
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  iframe.src = "about:blank?foo";
+  document.body.appendChild(iframe);
+  await assertDocumentStaysTheSame(t, iframe.contentWindow);
+}, "Content synchronously added to <iframe> with src='about:blank?foo' won't get replaced");
+
+promise_test(async t => {
+  const w = window.open();
+  await assertDocumentStaysTheSame(t, w);
+}, "Content synchronously added to window.open()-ed document won't get replaced");
+
+promise_test(async t => {
+  const w = window.open("");
+  await assertDocumentStaysTheSame(t, w);
+}, "Content synchronously added to window.open('')-ed document won't get replaced");
+
+promise_test(async t => {
+  const w = window.open("about:blank");
+  await assertDocumentStaysTheSame(t, w);
+}, "Content synchronously added to window.open('about:blank')-ed document won't get replaced");
+
+promise_test(async t => {
+  const w = window.open("about:blank#foo");
+  await assertDocumentStaysTheSame(t, w);
+}, "Content synchronously added to window.open('about:blank#foo')-ed document won't get replaced");
+
+promise_test(async t => {
+  const w = window.open("about:blank?foo");
+  await assertDocumentStaysTheSame(t, w);
+}, "Content synchronously added to window.open('about:blank?foo')-ed document won't get replaced");
+
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentloadeventiframeelementexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element-expected.txt (0 => 281502)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element-expected.txt                               (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element-expected.txt  2021-08-24 18:18:22 UTC (rev 281502)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+
+
+PASS load event fires synchronously on <iframe> element created with no src
+PASS load event fires synchronously on <iframe> element created with src=''
+PASS load event fires synchronously on <iframe> element created with src='about:blank'
+PASS load event fires synchronously on <iframe> element created with src='about:blank#foo'
+PASS load event fires synchronously on <iframe> element created with src='about:blank?foo'
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentloadeventiframeelementhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element.html (0 => 281502)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element.html                               (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element.html  2021-08-24 18:18:22 UTC (rev 281502)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>"load" event fires on the iframe element when loading the initial empty document</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/helpers.js"></script>
+<body></body>
+<script>
+"use strict";
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  let loadCount = 0;
+  iframe.addEventListener("load", () => {
+    loadCount++;
+  });
+  document.body.appendChild(iframe);
+  assert_equals(loadCount, 1);
+}, "load event fires synchronously on <iframe> element created with no src");
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  iframe.src = "";
+  let loadCount = 0;
+  iframe.addEventListener("load", () => {
+    loadCount++;
+  });
+  document.body.appendChild(iframe);
+  assert_equals(loadCount, 1);
+}, "load event fires synchronously on <iframe> element created with src=''");
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  iframe.src = "about:blank";
+  let loadCount = 0;
+  iframe.addEventListener("load", () => {
+    loadCount++;
+  });
+  document.body.appendChild(iframe);
+  assert_equals(loadCount, 1);
+}, "load event fires synchronously on <iframe> element created with src='about:blank'");
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  iframe.src = "about:blank#foo";
+  let loadCount = 0;
+  iframe.addEventListener("load", () => {
+    loadCount++;
+  });
+  document.body.appendChild(iframe);
+  assert_equals(loadCount, 1);
+}, "load event fires synchronously on <iframe> element created with src='about:blank#foo'");
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  iframe.src = "about:blank?foo";
+  let loadCount = 0;
+  iframe.addEventListener("load", () => {
+    loadCount++;
+  });
+  document.body.appendChild(iframe);
+  assert_equals(loadCount, 1);
+}, "load event fires synchronously on <iframe> element created with src='about:blank?foo'");
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentloadpageshoweventsiframecontentWindowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow-expected.txt (0 => 281502)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow-expected.txt                               (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow-expected.txt  2021-08-24 18:18:22 UTC (rev 281502)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+
+
+PASS load & pageshow event do not fire on contentWindow of <iframe> element created with no src
+PASS load & pageshow events do not fire on contentWindow of <iframe> element created with src=''
+PASS load & pageshow events do not fire on contentWindow of <iframe> element created with src='about:blank'
+PASS load & pageshow events do not fire on contentWindow of <iframe> element created with src='about:blank#foo'
+PASS load & pageshow events do not fire on contentWindow of <iframe> element created with src='about:blank?foo'
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentloadpageshoweventsiframecontentWindowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html (0 => 281502)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html                               (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html  2021-08-24 18:18:22 UTC (rev 281502)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>"load" & "pageshow" events do not fire on contentWindow of iframe that stays on the initial empty document</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/helpers.js"></script>
+<body></body>
+<script>
+"use strict";
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  document.body.appendChild(iframe);
+  return assertNoLoadAndPageshowEvent(t, iframe.contentWindow);
+}, "load & pageshow event do not fire on contentWindow of <iframe> element created with no src");
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  iframe.src = "";
+  document.body.appendChild(iframe);
+  return assertNoLoadAndPageshowEvent(t, iframe.contentWindow);
+}, "load & pageshow events do not fire on contentWindow of <iframe> element created with src=''");
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  iframe.src = "about:blank";
+  document.body.appendChild(iframe);
+  return assertNoLoadAndPageshowEvent(t, iframe.contentWindow);
+}, "load & pageshow events do not fire on contentWindow of <iframe> element created with src='about:blank'");
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  iframe.src = "about:blank#foo";
+  document.body.appendChild(iframe);
+  return assertNoLoadAndPageshowEvent(t, iframe.contentWindow);
+}, "load & pageshow events do not fire on contentWindow of <iframe> element created with src='about:blank#foo'");
+
+promise_test(async t => {
+  const iframe = document.createElement("iframe");
+  iframe.src = "about:blank?foo";
+  document.body.appendChild(iframe);
+  return assertNoLoadAndPageshowEvent(t, iframe.contentWindow);
+}, "load & pageshow events do not fire on contentWindow of <iframe> element created with src='about:blank?foo'");
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentloadpageshoweventswindowopenexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open-expected.txt (0 => 281502)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open-expected.txt   2021-08-24 18:18:22 UTC (rev 281502)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+
+PASS load event does not fire on window.open()
+PASS load event does not fire on window.open('')
+PASS load event does not fire on window.open('about:blank')
+PASS load event does not fire on window.open('about:blank#foo')
+PASS load event does not fire on window.open('about:blank?foo')
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentloadpageshoweventswindowopenhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open.html (0 => 281502)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open.html   2021-08-24 18:18:22 UTC (rev 281502)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>"load" and "pageshow" events don't fire on window.open() that stays on the initial empty document</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/helpers.js"></script>
+<body></body>
+<script>
+"use strict";
+
+promise_test(async t => {
+  const w = window.open();
+  return assertNoLoadAndPageshowEvent(t, w)
+}, "load event does not fire on window.open()");
+
+promise_test(async t => {
+  const w = window.open("");
+  return assertNoLoadAndPageshowEvent(t, w)
+}, "load event does not fire on window.open('')");
+
+promise_test(async t => {
+  const w = window.open("about:blank");
+  return assertNoLoadAndPageshowEvent(t, w)
+}, "load event does not fire on window.open('about:blank')");
+
+promise_test(async t => {
+  const w = window.open("about:blank#foo");
+  return assertNoLoadAndPageshowEvent(t, w)
+}, "load event does not fire on window.open('about:blank#foo')");
+
+promise_test(async t => {
+  const w = window.open("about:blank?foo");
+  return assertNoLoadAndPageshowEvent(t, w)
+}, "load event does not fire on window.open('about:blank?foo')");
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersbrowsingthewebnavigatingacrossdocumentsinitialemptydocumentresourceshelpersjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/resources/helpers.js (0 => 281502)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/resources/helpers.js                         (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/resources/helpers.js    2021-08-24 18:18:22 UTC (rev 281502)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+// Returns a promise that asserts the "load" and "pageshow" events are not
+// fired on |target|.
+function assertNoLoadAndPageshowEvent(t, target) {
+  target.addEventListener("load", t.unreached_func("load should not be fired"));
+  target.addEventListener("pageshow", t.unreached_func("pageshow should not be fired"));
+  return new Promise(resolve => {
+    // Wait 50ms to ensure events fired after asynchronous navigations are
+    // also captured.
+    setTimeout(resolve, 50);
+  });
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (281501 => 281502)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-08-24 18:00:51 UTC (rev 281501)
+++ trunk/Source/WebCore/ChangeLog      2021-08-24 18:18:22 UTC (rev 281502)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2021-08-24  Chris Dumez  <cdumez@apple.com>
+
+        Fire a load event for <iframe src="about:blank#foo">
+        https://bugs.webkit.org/show_bug.cgi?id=228958
+        <rdar://problem/82035810>
+
+        Reviewed by Darin Adler.
+
+        When loading an iframe with src="about:blank#foo", we would fail to fire the load event because we would treat
+        the navigation as a fragment navigation. The reason for that is that the iframe is initially displaying the
+        initial empty document, which has URL "about:blank". Because the source and destination URL would be the same
+        when ignoring fragments, our logic would treat this as a pure fragment navigation. To address this, I have
+        updated FrameLoader::shouldPerformFragmentNavigation() to special case the initial empty document.        
+
+        Test: imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-event-iframe-element.html
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::shouldPerformFragmentNavigation):
+
</ins><span class="cx"> 2021-08-24  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         ThreadSanitizer: data race in WTF::StringImpl::deref() for WebCore::FormDataElement::EncodedFileData::filename
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (281501 => 281502)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp      2021-08-24 18:00:51 UTC (rev 281501)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2021-08-24 18:18:22 UTC (rev 281502)
</span><span class="lines">@@ -3232,7 +3232,8 @@
</span><span class="cx">         && !shouldReload(m_frame.document()->url(), url)
</span><span class="cx">         // We don't want to just scroll if a link from within a
</span><span class="cx">         // frameset is trying to reload the frameset into _top.
</span><del>-        && !m_frame.document()->isFrameSet();
</del><ins>+        && !m_frame.document()->isFrameSet()
+        && !stateMachine().isDisplayingInitialEmptyDocument();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static bool itemAllowsScrollRestoration(HistoryItem* historyItem)
</span></span></pre>
</div>
</div>

</body>
</html>