-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
link elements should be able to fire more than one load / error event
https://bugs.webkit.org/show_bug.cgi?id=232309 Reviewed by Darin Adler. Based on a patch written by Chris Dumez. This patch makes link element emit more than one load event each time resource is loaded, and fixes the bug that setting rel content attribute to the same value resulted in the resource to be reloaded. New behavior matches that of Chrome and Firefox. * LayoutTests/TestExpectations: Unskip now passing tests. * LayoutTests/fast/dom/HTMLLinkElement/link-preload-load-once-expected.txt: Added. * LayoutTests/fast/dom/HTMLLinkElement/link-preload-load-once.html: Added. * LayoutTests/fast/dom/HTMLLinkElement/link-stylesheet-load-once-expected.txt: Added. * LayoutTests/fast/dom/HTMLLinkElement/link-stylesheet-load-once.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-multiple-error-events-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-multiple-load-events-expected.txt: * LayoutTests/platform/mac-wk1/fast/dom/HTMLLinkElement/link-preload-load-once-expected.txt: * LayoutTests/platform/win/fast/dom/HTMLLinkElement/link-preload-load-once-expected.txt: * Source/WebCore/html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::HTMLLinkElement): (WebCore::HTMLLinkElement::parseAttribute): (WebCore::HTMLLinkElement::process): (WebCore::HTMLLinkElement::didFinishInsertingNode): We need to resolve URL again once this element is connected. (WebCore::HTMLLinkElement::notifyLoadedSheetAndAllCriticalSubresources): * Source/WebCore/html/HTMLLinkElement.h: * Source/WebCore/html/LinkRelAttribute.h: (WebCore::operator==): Added. (WebCore::operator!=): Added. Canonical link: https://commits.webkit.org/254290@main
- Loading branch information
Showing
12 changed files
with
153 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
LayoutTests/fast/dom/HTMLLinkElement/link-preload-load-once-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
data:text/css,div { background: green; width: 100px; height: 100px } - willSendRequest <NSURLRequest URL data:text/css,div { background: green; width: 100px; height: 100px }, main document URL link-preload-load-once.html, http method GET> redirectResponse (null) | ||
link-preload-load-once.html - didFinishLoading | ||
data:text/css,div { background: green; width: 100px; height: 100px } - didReceiveResponse <NSURLResponse data:text/css,div { background: green; width: 100px; height: 100px }, http status code 200> | ||
data:text/css,div { background: green; width: 100px; height: 100px } - didFinishLoading | ||
This tests overriding rel content attribute with the same value. | ||
You should see 1 below: | ||
|
||
1 |
39 changes: 39 additions & 0 deletions
39
LayoutTests/fast/dom/HTMLLinkElement/link-preload-load-once.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.waitUntilDone(); | ||
testRunner.dumpAsText(); | ||
testRunner.dumpResourceLoadCallbacks(); | ||
} | ||
|
||
let loadCount = 0; | ||
function didLoad(element) | ||
{ | ||
if (!loadCount) { | ||
document.querySelector('link').rel = 'preload'; | ||
setTimeout(() => { | ||
document.querySelector('link').rel = 'PreLoad'; | ||
}, 100); | ||
setTimeout(() => { | ||
document.querySelector('link').rel = 'PreLoad '; | ||
}, 200); | ||
setTimeout(() => { | ||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
}, 300); | ||
} | ||
++loadCount; | ||
result.innerHTML = loadCount; | ||
} | ||
|
||
</script> | ||
<link rel="preload" as="style" href="data:text/css,div { background: green; width: 100px; height: 100px }" onload="didLoad(this)"> | ||
</head> | ||
<body> | ||
<p>This tests overriding rel content attribute with the same value.<br> | ||
You should see 1 below:</p> | ||
<div id="result"></div> | ||
</body> | ||
</html> |
8 changes: 8 additions & 0 deletions
8
LayoutTests/fast/dom/HTMLLinkElement/link-stylesheet-load-once-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resources/link-stylesheet-load-once.css - willSendRequest <NSURLRequest URL resources/link-stylesheet-load-once.css, main document URL link-stylesheet-load-once.html, http method GET> redirectResponse (null) | ||
link-stylesheet-load-once.html - didFinishLoading | ||
resources/link-stylesheet-load-once.css - didReceiveResponse <NSURLResponse resources/link-stylesheet-load-once.css, http status code 0> | ||
resources/link-stylesheet-load-once.css - didFinishLoading | ||
This tests overriding rel content attribute with the same value. | ||
You should see 1 in a green box below: | ||
|
||
1 |
40 changes: 40 additions & 0 deletions
40
LayoutTests/fast/dom/HTMLLinkElement/link-stylesheet-load-once.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.waitUntilDone(); | ||
testRunner.dumpAsText(); | ||
testRunner.dumpResourceLoadCallbacks(); | ||
} | ||
|
||
let loadCount = 0; | ||
function didLoad(element) | ||
{ | ||
if (!loadCount) { | ||
document.querySelector('link').rel = 'stylesheet'; | ||
setTimeout(() => document.querySelector('link').rel = 'StyleSheet', 50); | ||
setTimeout(() => document.querySelector('link').rel = ' StyleSheet', 100); | ||
setTimeout(() => document.querySelector('link').media = 'all', 150); | ||
setTimeout(() => document.querySelector('link').media = 'All', 200); | ||
setTimeout(() => document.querySelector('link').type = 'text/css', 250); | ||
setTimeout(() => document.querySelector('link').href = 'resources/link-stylesheet-load-once.css', 300); | ||
setTimeout(() => document.querySelector('link').href = ' ../HTMLLinkElement/resources/link-stylesheet-load-once.css', 350); | ||
setTimeout(() => { | ||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
}, 400); | ||
} | ||
++loadCount; | ||
result.innerHTML = loadCount; | ||
} | ||
|
||
</script> | ||
<link rel="stylesheet" type="text/css" media="all" href="resources/link-stylesheet-load-once.css" onload="didLoad(this)"> | ||
</head> | ||
<body> | ||
<p>This tests overriding rel content attribute with the same value.<br> | ||
You should see 1 in a green box below:</p> | ||
<div id="result"></div> | ||
</body> | ||
</html> |
4 changes: 1 addition & 3 deletions
4
...html/semantics/document-metadata/the-link-element/link-multiple-error-events-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
Harness Error (TIMEOUT), message = null | ||
|
||
TIMEOUT Check if the <link>'s error event fires for each stylesheet it fails to load Test timed out | ||
PASS Check if the <link>'s error event fires for each stylesheet it fails to load | ||
|
4 changes: 1 addition & 3 deletions
4
.../html/semantics/document-metadata/the-link-element/link-multiple-load-events-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
Harness Error (TIMEOUT), message = null | ||
|
||
TIMEOUT Check if the <link>'s load event fires for each stylesheet it loads Test timed out | ||
PASS Check if the <link>'s load event fires for each stylesheet it loads | ||
|
8 changes: 8 additions & 0 deletions
8
LayoutTests/platform/mac-wk1/fast/dom/HTMLLinkElement/link-preload-load-once-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
data:text/css,div%20%7B%20background:%20green;%20width:%20100px;%20height:%20100px%20%7D - willSendRequest <NSURLRequest URL data:text/css,div%20%7B%20background:%20green;%20width:%20100px;%20height:%20100px%20%7D, main document URL link-preload-load-once.html, http method GET> redirectResponse (null) | ||
link-preload-load-once.html - didFinishLoading | ||
data:text/css,div%20%7B%20background:%20green;%20width:%20100px;%20height:%20100px%20%7D - didReceiveResponse <NSURLResponse data:text/css,div%20%7B%20background:%20green;%20width:%20100px;%20height:%20100px%20%7D, http status code 0> | ||
data:text/css,div%20%7B%20background:%20green;%20width:%20100px;%20height:%20100px%20%7D - didFinishLoading | ||
This tests overriding rel content attribute with the same value. | ||
You should see 1 below: | ||
|
||
1 |
8 changes: 8 additions & 0 deletions
8
LayoutTests/platform/win/fast/dom/HTMLLinkElement/link-preload-load-once-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
data:text/css,div { background: green; width: 100px; height: 100px } - willSendRequest <NSURLRequest URL data:text/css,div { background: green; width: 100px; height: 100px }, main document URL link-preload-load-once.html, http method GET> redirectResponse (null) | ||
link-preload-load-once.html - didFinishLoading | ||
data:text/css,div { background: green; width: 100px; height: 100px } - didReceiveResponse <NSURLResponse data:text/css,div { background: green; width: 100px; height: 100px }, http status code 0> | ||
data:text/css,div { background: green; width: 100px; height: 100px } - didFinishLoading | ||
This tests overriding rel content attribute with the same value. | ||
You should see 1 below: | ||
|
||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters