Skip to content
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

Merged
merged 5 commits into from
Jan 17, 2019
Merged

Conversation

domfarolino
Copy link
Member

@domfarolino domfarolino commented Jan 16, 2019

Tests for whatwg/html#4031.
Explanation of the tests:

  • link-load-fired-before-scripting-unblocked.html
    • This just tests that scripting is not unblocked until the load event of the element contributing a script-blocking style is fired. TODO: identical test, but for error event
  • stylesheet-not-removed-until-next-stylesheet-loads.html
    • This tests that a style sheet does not become unavailable to scripts until a new one loaded from the same link replaces it

@zcorpan zcorpan assigned domenic and unassigned zqzhang Jan 17, 2019
domenic pushed a commit to whatwg/html that referenced this pull request Jan 17, 2019
* 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
Copy link
Member

@domenic domenic left a 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>
Copy link
Member

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");
Copy link
Member

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 " +
Copy link
Member

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.

Copy link
Member Author

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() {
Copy link
Member

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()

@domfarolino domfarolino merged commit 7422dfa into master Jan 17, 2019
@domfarolino domfarolino deleted the domfarolino/link-loading-tests branch January 17, 2019 18:50
mustaqahmed pushed a commit to mustaqahmed/html that referenced this pull request Feb 15, 2019
* 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
mustaqahmed pushed a commit to mustaqahmed/html that referenced this pull request Feb 15, 2019
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants