Remove support for beforeload on link=prefetch
https://bugs.webkit.org/show_bug.cgi?id=199632
Patch by Rob Buis <rbuis@igalia.com> on 2019-07-16
Reviewed by Youenn Fablet.
Source/WebCore:
Remove support for beforeload on link=prefetch
by not calling shouldLoadLink for prefetch.
Also make loadLink return void since it always
succeeds.
Tests: http/wpt/prefetch/beforeload-dynamic.html
http/wpt/prefetch/beforeload.html
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
* loader/LinkLoader.cpp:
(WebCore::LinkLoader::prefetchIfNeeded):
(WebCore::LinkLoader::loadLink):
* loader/LinkLoader.h:
LayoutTests:
Add tests to verify that beforeload event is not called for link
rel=prefetch.
* TestExpectations:
* fast/dom/HTMLLinkElement/prefetch-beforeload-expected.txt: Removed.
* fast/dom/HTMLLinkElement/prefetch-beforeload.html: Removed.
* http/wpt/prefetch/beforeload-dynamic-expected.txt: Added.
* http/wpt/prefetch/beforeload-dynamic.html: Added.
* http/wpt/prefetch/beforeload-expected.txt: Added.
* http/wpt/prefetch/beforeload.html: Added.
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@247481 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 982ef958..f77d092 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,24 @@
+2019-07-16 Rob Buis <rbuis@igalia.com>
+
+ Remove support for beforeload on link=prefetch
+ https://bugs.webkit.org/show_bug.cgi?id=199632
+
+ Reviewed by Youenn Fablet.
+
+ Add tests to verify that beforeload event is not called for link
+ rel=prefetch.
+
+
+ * TestExpectations:
+ * fast/dom/HTMLLinkElement/prefetch-beforeload-expected.txt: Removed.
+ * fast/dom/HTMLLinkElement/prefetch-beforeload.html: Removed.
+ * http/wpt/prefetch/beforeload-dynamic-expected.txt: Added.
+ * http/wpt/prefetch/beforeload-dynamic.html: Added.
+ * http/wpt/prefetch/beforeload-expected.txt: Added.
+ * http/wpt/prefetch/beforeload.html: Added.
+ * platform/mac-wk1/TestExpectations:
+ * platform/win/TestExpectations:
+
2019-07-15 Ryan Haddad <ryanhaddad@apple.com>
[macOS WK2] Layout Test http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access.html is a flaky timeout
diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations
index a43462b..d414d86 100644
--- a/LayoutTests/TestExpectations
+++ b/LayoutTests/TestExpectations
@@ -2333,7 +2333,6 @@
webkit.org/b/3652 fast/dom/HTMLLinkElement/link-and-subresource-test.html [ Skip ]
webkit.org/b/3652 fast/dom/HTMLLinkElement/link-and-subresource-test-nonexistent.html [ Skip ]
webkit.org/b/3652 fast/dom/HTMLLinkElement/prefetch.html [ Skip ]
-webkit.org/b/3652 fast/dom/HTMLLinkElement/prefetch-beforeload.html [ Skip ]
webkit.org/b/3652 fast/dom/HTMLLinkElement/prefetch-onerror.html [ Skip ]
webkit.org/b/3652 fast/dom/HTMLLinkElement/prefetch-onload.html [ Skip ]
webkit.org/b/3652 fast/dom/HTMLLinkElement/prefetch-too-many-clients.html [ Skip ]
diff --git a/LayoutTests/fast/dom/HTMLLinkElement/prefetch-beforeload-expected.txt b/LayoutTests/fast/dom/HTMLLinkElement/prefetch-beforeload-expected.txt
deleted file mode 100644
index c7fb018..0000000
--- a/LayoutTests/fast/dom/HTMLLinkElement/prefetch-beforeload-expected.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-PASS beforeload called
-This test will only print "PASS" or "FAIL" if link prefetches are enabled, otherwise it will show nothing below.
diff --git a/LayoutTests/fast/dom/HTMLLinkElement/prefetch-beforeload.html b/LayoutTests/fast/dom/HTMLLinkElement/prefetch-beforeload.html
deleted file mode 100644
index bb0da78..0000000
--- a/LayoutTests/fast/dom/HTMLLinkElement/prefetch-beforeload.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<body>
-<div id="console"></div>
-<script src="../../../resources/js-test-pre.js"></script>
-<script>
-if (window.testRunner) {
- testRunner.dumpAsText();
-}
-</script>
-<html>
-<p>This test will only print "PASS" or "FAIL" if link prefetches are
-enabled, otherwise it will show nothing below.</p>
-<link href="prefetch.link" rel="prefetch" onbeforeload="testPassed('beforeload called');return false" onload="testFailed('onload')" onerror="testFailed('onerror')" />
-</html>
-
diff --git a/LayoutTests/http/wpt/prefetch/beforeload-dynamic-expected.txt b/LayoutTests/http/wpt/prefetch/beforeload-dynamic-expected.txt
new file mode 100644
index 0000000..9529be0
--- /dev/null
+++ b/LayoutTests/http/wpt/prefetch/beforeload-dynamic-expected.txt
@@ -0,0 +1,3 @@
+
+PASS Makes sure that dynamically added prefetch does not call beforeload.
+
diff --git a/LayoutTests/http/wpt/prefetch/beforeload-dynamic.html b/LayoutTests/http/wpt/prefetch/beforeload-dynamic.html
new file mode 100644
index 0000000..07d2c1a
--- /dev/null
+++ b/LayoutTests/http/wpt/prefetch/beforeload-dynamic.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+var t = async_test('Makes sure that dynamically added prefetch does not call beforeload.');
+t.step(function() {
+ onload = t.step_func(function() { setTimeout(t.done(), 100); });
+ var link = document.createElement("link");
+ link.rel = "prefetch";
+ link.onbeforeload = t.step_func(function() {
+ assert_unreached("Beforeload should not be called.")
+ })
+ document.body.appendChild(link);
+});
+</script>
+</body>
diff --git a/LayoutTests/http/wpt/prefetch/beforeload-expected.txt b/LayoutTests/http/wpt/prefetch/beforeload-expected.txt
new file mode 100644
index 0000000..d93d929
--- /dev/null
+++ b/LayoutTests/http/wpt/prefetch/beforeload-expected.txt
@@ -0,0 +1,3 @@
+
+PASS Makes sure that prefetch does not call beforeload.
+
diff --git a/LayoutTests/http/wpt/prefetch/beforeload.html b/LayoutTests/http/wpt/prefetch/beforeload.html
new file mode 100644
index 0000000..46f6093
--- /dev/null
+++ b/LayoutTests/http/wpt/prefetch/beforeload.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body onload="setTimeout(t.done(), 100);">
+<script>
+ var t = async_test('Makes sure that prefetch does not call beforeload.');
+</script>
+<link rel="prefetch" onbeforeload="assert_unreached('Beforeload should not be called.')">
+</body>
diff --git a/LayoutTests/platform/mac-wk1/TestExpectations b/LayoutTests/platform/mac-wk1/TestExpectations
index 3bae024..1304363 100644
--- a/LayoutTests/platform/mac-wk1/TestExpectations
+++ b/LayoutTests/platform/mac-wk1/TestExpectations
@@ -736,6 +736,9 @@
webkit.org/b/197371 http/wpt/prefetch/link-prefetch-main-resource-redirect.html [ Skip ]
+webkit.org/b/199632 http/wpt/prefetch/beforeload.html [ Skip ]
+webkit.org/b/199632 http/wpt/prefetch/beforeload-dynamic.html [ Skip ]
+
webkit.org/b/198177 pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed.html [ Skip ]
webkit.org/b/198459 [ HighSierra Debug ] inspector/canvas/recording-2d-full.html [ Slow ]
diff --git a/LayoutTests/platform/win/TestExpectations b/LayoutTests/platform/win/TestExpectations
index 0eed029..98ff6bc 100644
--- a/LayoutTests/platform/win/TestExpectations
+++ b/LayoutTests/platform/win/TestExpectations
@@ -4420,6 +4420,9 @@
webkit.org/b/197371 http/wpt/prefetch/link-prefetch-main-resource-redirect.html [ Skip ]
+webkit.org/b/199632 http/wpt/prefetch/beforeload.html [ Skip ]
+webkit.org/b/199632 http/wpt/prefetch/beforeload-dynamic.html [ Skip ]
+
webkit.org/b/198112 http/tests/security/showModalDialog-sync-cross-origin-page-load2.html [ Skip ]
webkit.org/b/198679 fast/events/fire-mousedown-while-pressing-mouse-button.html [ Failure ]
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 102ad59..93e37eb 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2019-07-16 Rob Buis <rbuis@igalia.com>
+
+ Remove support for beforeload on link=prefetch
+ https://bugs.webkit.org/show_bug.cgi?id=199632
+
+ Reviewed by Youenn Fablet.
+
+ Remove support for beforeload on link=prefetch
+ by not calling shouldLoadLink for prefetch.
+ Also make loadLink return void since it always
+ succeeds.
+
+ Tests: http/wpt/prefetch/beforeload-dynamic.html
+ http/wpt/prefetch/beforeload.html
+
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::process):
+ * loader/LinkLoader.cpp:
+ (WebCore::LinkLoader::prefetchIfNeeded):
+ (WebCore::LinkLoader::loadLink):
+ * loader/LinkLoader.h:
+
2019-07-16 Youenn Fablet <youenn@apple.com>
Hop to main thread for release logging in RealtimeIncomingAudioSource
diff --git a/Source/WebCore/html/HTMLLinkElement.cpp b/Source/WebCore/html/HTMLLinkElement.cpp
index c2c00a2..b8634ca 100644
--- a/Source/WebCore/html/HTMLLinkElement.cpp
+++ b/Source/WebCore/html/HTMLLinkElement.cpp
@@ -273,8 +273,7 @@
attributeWithoutSynchronization(imagesizesAttr)
};
- if (!m_linkLoader.loadLink(params, document()))
- return;
+ m_linkLoader.loadLink(params, document());
bool treatAsStyleSheet = m_relAttribute.isStyleSheet
|| (document().settings().treatsAnyTextCSSLinkAsStylesheet() && m_type.containsIgnoringASCIICase("text/css"));
diff --git a/Source/WebCore/loader/LinkLoader.cpp b/Source/WebCore/loader/LinkLoader.cpp
index d638668..cdf6495 100644
--- a/Source/WebCore/loader/LinkLoader.cpp
+++ b/Source/WebCore/loader/LinkLoader.cpp
@@ -283,7 +283,7 @@
void LinkLoader::prefetchIfNeeded(const LinkLoadParameters& params, Document& document)
{
- if (!params.relAttribute.isLinkPrefetch || !params.href.isValid() || !document.frame() || !m_client.shouldLoadLink())
+ if (!params.href.isValid() || !document.frame())
return;
ASSERT(RuntimeEnabledFeatures::sharedFeatures().linkPrefetchEnabled());
@@ -316,7 +316,7 @@
m_preloadResourceClient->clear();
}
-bool LinkLoader::loadLink(const LinkLoadParameters& params, Document& document)
+void LinkLoader::loadLink(const LinkLoadParameters& params, Document& document)
{
if (params.relAttribute.isDNSPrefetch) {
// FIXME: The href attribute of the link element can be in "//hostname" form, and we shouldn't attempt
@@ -327,6 +327,11 @@
preconnectIfNeeded(params, document);
+ if (params.relAttribute.isLinkPrefetch) {
+ prefetchIfNeeded(params, document);
+ return;
+ }
+
if (m_client.shouldLoadLink()) {
auto resourceClient = preloadIfNeeded(params, document, this);
if (m_preloadResourceClient)
@@ -334,10 +339,6 @@
if (resourceClient)
m_preloadResourceClient = WTFMove(resourceClient);
}
-
- prefetchIfNeeded(params, document);
-
- return true;
}
}
diff --git a/Source/WebCore/loader/LinkLoader.h b/Source/WebCore/loader/LinkLoader.h
index b36d59d..b5c7e36 100644
--- a/Source/WebCore/loader/LinkLoader.h
+++ b/Source/WebCore/loader/LinkLoader.h
@@ -60,7 +60,7 @@
explicit LinkLoader(LinkLoaderClient&);
virtual ~LinkLoader();
- bool loadLink(const LinkLoadParameters&, Document&);
+ void loadLink(const LinkLoadParameters&, Document&);
static Optional<CachedResource::Type> resourceTypeFromAsAttribute(const String& as);
enum class MediaAttributeCheck { MediaAttributeEmpty, MediaAttributeNotEmpty, SkipMediaAttributeCheck };