Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (281501 => 281502)
--- 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)
@@ -1,3 +1,24 @@
+2021-08-24 Chris Dumez <[email protected]>
+
+ Fire a load event for <iframe src=""
+ 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):
+
2021-08-24 Tim Nguyen <[email protected]>
Move cancel dialog task to `defaultKeyboardEventHandler`.
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)
--- 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)
@@ -0,0 +1,13 @@
+
+
+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='' won't get replaced
+PASS Content synchronously added to <iframe> with src='' won't get replaced
+PASS Content synchronously added to <iframe> with src='' 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
+
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)
--- 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)
@@ -0,0 +1,86 @@
+<!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=""
+<script src=""
+<script src=""
+<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 = ""
+ 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 = ""
+ 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 = ""
+ 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 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>
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)
--- 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)
@@ -0,0 +1,8 @@
+
+
+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=''
+PASS load event fires synchronously on <iframe> element created with src=''
+PASS load event fires synchronously on <iframe> element created with src=''
+
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)
--- 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)
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>"load" event fires on the iframe element when loading the initial empty document</title>
+<script src=""
+<script src=""
+<script src=""
+<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 = ""
+ 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 = ""
+ 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 = ""
+ 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=''");
+</script>
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)
--- 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)
@@ -0,0 +1,8 @@
+
+
+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=''
+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=''
+
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)
--- 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)
@@ -0,0 +1,44 @@
+<!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=""
+<script src=""
+<script src=""
+<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 = ""
+ 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 = ""
+ 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 = ""
+ document.body.appendChild(iframe);
+ return assertNoLoadAndPageshowEvent(t, iframe.contentWindow);
+}, "load & pageshow events do not fire on contentWindow of <iframe> element created with src=''");
+</script>
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)
--- 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)
@@ -0,0 +1,7 @@
+
+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')
+
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)
--- 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)
@@ -0,0 +1,35 @@
+<!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=""
+<script src=""
+<script src=""
+<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>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/resources/helpers.js (0 => 281502)
--- 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)
@@ -0,0 +1,11 @@
+// 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);
+ });
+}
Modified: trunk/Source/WebCore/ChangeLog (281501 => 281502)
--- 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)
@@ -1,3 +1,22 @@
+2021-08-24 Chris Dumez <[email protected]>
+
+ Fire a load event for <iframe src=""
+ https://bugs.webkit.org/show_bug.cgi?id=228958
+ <rdar://problem/82035810>
+
+ Reviewed by Darin Adler.
+
+ When loading an iframe with src="" 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):
+
2021-08-24 Alex Christensen <[email protected]>
ThreadSanitizer: data race in WTF::StringImpl::deref() for WebCore::FormDataElement::EncodedFileData::filename
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (281501 => 281502)
--- 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)
@@ -3232,7 +3232,8 @@
&& !shouldReload(m_frame.document()->url(), url)
// We don't want to just scroll if a link from within a
// frameset is trying to reload the frameset into _top.
- && !m_frame.document()->isFrameSet();
+ && !m_frame.document()->isFrameSet()
+ && !stateMachine().isDisplayingInitialEmptyDocument();
}
static bool itemAllowsScrollRestoration(HistoryItem* historyItem)