-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Script-blocking style sheet tests #14899
Conversation
* Introduce new link loading infrastructure, specifically algorithms to fetch and process linked resources that are overridable by the individual link types. This replaces the previous "obtain the resource" algorithms with something more structured and rigorous. * Specify the order in which style sheets are removed, created/added, their corresponding load/error events are fired, and scripting is unblocked from a loading style sheet. * Replace "style sheet done" flag with Document's "script-blocking style sheet counter", which works in tandem with the "contributes a script-blocking style sheet" conditions, which replaces the definition of "a style sheet that is blocking scripts". * Change <link> load/fire events to be fired from tasks queued on the networking task source, instead of the DOM manipulation task source. * Handle much of what #3544 set out to do, minus defining and explicitly fetching a style sheet's critical subresources. Fixes #3610. Tests: web-platform-tests/wpt#14899
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with style suggestions
</script> | ||
<link href="style.css?pipe=trickle(d3)" rel="stylesheet" id="style_test" | ||
onload="t.step(function() { saw_link_onload = true; });" | ||
onerror="t.step(function() { assert_unreached('Sheet should load OK'); });"></link> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use t.unreached_func('Sheet should load OK')
if you want
t.step(function() { | ||
assert_true(document.styleSheets.length === 1 && | ||
document.styleSheets[0].href.includes("style.css"), | ||
"The style sheet 'style.css' is not available to scripts"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, the assertion messages should be stated as things that should happen (like in your other tests), not as things that should not happen. This is inconsistent across WPT but especially for code readers I think it's the right thing to do.
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
var t = async_test("Check that the style sheet loaded by an <link> element " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unclear why this is an async_test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point; mostly that was copy paste
<link href="style.css?pipe=trickle(d3)" rel="stylesheet" id="style_test" | ||
onerror="t.step(function() { assert_unreached('Sheet should load OK'); });"></link> | ||
<script> | ||
t.step(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might as well join these all into one t.step()
* Introduce new link loading infrastructure, specifically algorithms to fetch and process linked resources that are overridable by the individual link types. This replaces the previous "obtain the resource" algorithms with something more structured and rigorous. * Specify the order in which style sheets are removed, created/added, their corresponding load/error events are fired, and scripting is unblocked from a loading style sheet. * Replace "style sheet done" flag with Document's "script-blocking style sheet counter", which works in tandem with the "contributes a script-blocking style sheet" conditions, which replaces the definition of "a style sheet that is blocking scripts". * Change <link> load/fire events to be fired from tasks queued on the networking task source, instead of the DOM manipulation task source. * Handle much of what whatwg#3544 set out to do, minus defining and explicitly fetching a style sheet's critical subresources. Fixes whatwg#3610. Tests: web-platform-tests/wpt#14899
* Introduce new link loading infrastructure, specifically algorithms to fetch and process linked resources that are overridable by the individual link types. This replaces the previous "obtain the resource" algorithms with something more structured and rigorous. * Specify the order in which style sheets are removed, created/added, their corresponding load/error events are fired, and scripting is unblocked from a loading style sheet. * Replace "style sheet done" flag with Document's "script-blocking style sheet counter", which works in tandem with the "contributes a script-blocking style sheet" conditions, which replaces the definition of "a style sheet that is blocking scripts". * Change <link> load/fire events to be fired from tasks queued on the networking task source, instead of the DOM manipulation task source. * Handle much of what whatwg#3544 set out to do, minus defining and explicitly fetching a style sheet's critical subresources. Fixes whatwg#3610. Tests: web-platform-tests/wpt#14899
Tests for whatwg/html#4031.
Explanation of the tests: