Commit 66236c64 authored by Dominic Farolino's avatar Dominic Farolino Committed by Commit Bot

Link element events should be able to fire more than once

As per spec https://html.spec.whatwg.org/multipage/links.html#link-type-stylesheet,
the <link> element can have its load and error events fire multiple times,
per resource it loads.

Bug: 922618
Change-Id: Ifc9ade076e119d5cf9f4eaf656c6ea7c1deb0ba9
Reviewed-on: https://chromium-review.googlesource.com/c/1423601Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Dominic Farolino <domfarolino@gmail.com>
Cr-Commit-Position: refs/heads/master@{#628010}
parent c18bad54
...@@ -45,7 +45,6 @@ LinkStyle::LinkStyle(HTMLLinkElement* owner) ...@@ -45,7 +45,6 @@ LinkStyle::LinkStyle(HTMLLinkElement* owner)
disabled_state_(kUnset), disabled_state_(kUnset),
pending_sheet_type_(kNone), pending_sheet_type_(kNone),
loading_(false), loading_(false),
fired_load_(false),
loaded_sheet_(false) {} loaded_sheet_(false) {}
LinkStyle::~LinkStyle() = default; LinkStyle::~LinkStyle() = default;
...@@ -145,12 +144,9 @@ bool LinkStyle::SheetLoaded() { ...@@ -145,12 +144,9 @@ bool LinkStyle::SheetLoaded() {
void LinkStyle::NotifyLoadedSheetAndAllCriticalSubresources( void LinkStyle::NotifyLoadedSheetAndAllCriticalSubresources(
Node::LoadedSheetErrorStatus error_status) { Node::LoadedSheetErrorStatus error_status) {
if (fired_load_)
return;
loaded_sheet_ = (error_status == Node::kNoErrorLoadingSubresource); loaded_sheet_ = (error_status == Node::kNoErrorLoadingSubresource);
if (owner_) if (owner_)
owner_->ScheduleEvent(); owner_->ScheduleEvent();
fired_load_ = true;
} }
void LinkStyle::StartLoadingDynamicSheet() { void LinkStyle::StartLoadingDynamicSheet() {
......
...@@ -79,7 +79,6 @@ class LinkStyle final : public LinkResource, ResourceClient { ...@@ -79,7 +79,6 @@ class LinkStyle final : public LinkResource, ResourceClient {
PendingSheetType pending_sheet_type_; PendingSheetType pending_sheet_type_;
StyleEngineContext style_engine_context_; StyleEngineContext style_engine_context_;
bool loading_; bool loading_;
bool fired_load_;
bool loaded_sheet_; bool loaded_sheet_;
}; };
......
<!DOCTYPE html>
<link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-link-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link id=link rel=stylesheet id=style_test
onload="t.unreached_func('Sheet should fail to load')">
<script>
var t = async_test("Check if the <link>'s error event fires for each style " +
"sheet it fails to load");
link.onerror = t.step_func(() => {
link.onerror = t.step_func_done(() => {});
link.href = 'nonexistent.css?second';
});
link.href = 'nonexistent.css?first';
</script>
</head>
</html>
<!DOCTYPE html>
<link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-link-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link id=link rel=stylesheet id=style_test
onerror="t.unreached_func('Sheet should load successfully')">
<script>
var t = async_test("Check if the <link>'s load event fires for each style " +
"sheet it loads");
link.onload = t.step_func(() => {
link.onload = t.step_func_done(() => {});
link.href = 'style.css?second';
});
link.href = 'style.css?first';
</script>
</head>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment