Skip to content

Commit

Permalink
Bug 1768981 [wpt PR 34038] - Add a WPT for when a <script> is not imp…
Browse files Browse the repository at this point in the history
…licitly potentially render-blocking, a=testonly

Automatic update from web-platform-tests
Add a WPT for when a <script> is not implicitly potentially render-blocking

For whatwg/html#7894

Bug: 1271296
Bug: whatwg/html#7893
Change-Id: I95609738722122c96d65ccc588cbbd4c90ce67ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3643218
Auto-Submit: Xiaocheng Hu <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1002737}

--

wpt-commits: 7f4089c1f0ba37dc51fb3a220f8719ff98863374
wpt-pr: 34038
  • Loading branch information
xiaochengh authored and moz-wptsync-bot committed May 17, 2022
1 parent bd2235e commit 953ea49
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<title>Tests when script is not implicitly potentially render-blocking</title>
<link rel="help" href="https://github.com/whatwg/html/pull/7894">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/test-render-blocking.js"></script>

<!--
The test is marked "optional" because even when the document is not
render-blocked, the user agent is still free to take other factors, which are
not limited by the spec, into consideration and therefore decide not to
render. However, it is still more desirable if rendering starts
immediately/soon.
-->

<script class="test" data="parser-inserted async script" async
src="support/dummy-1.js?pipe=trickle(d1)&async"></script>
<script class="test" data="parser-inserted defer script" defer
src="support/dummy-1.js?pipe=trickle(d1)&defer"></script>
<script class="test" data="parser-inserted module script" type="module"
src="support/dummy-1.mjs?pipe=trickle(d1)"></script>
<script class="test" data="parser-inserted async module script" type="module"
async src="support/dummy-1.mjs?pipe=trickle(d1)&async"></script>

<script>
function addTestScriptElement(title, attributes) {
let element = document.createElement('script');
element.className = 'test';
element.setAttribute('data', title);
Object.assign(element, attributes);
document.head.appendChild(element);
}

addTestScriptElement('script-inserted script', {src: 'support/dummy-1.js?pipe=trickle(d1)&dynamic'});
addTestScriptElement('script-inserted sync script', {async: false, src: 'support/dummy-1.js?pipe=trickle(d1)&dynamicSync'});
addTestScriptElement('script-inserted module script', {type: 'module', src: 'support/dummy-1.mjs?pipe=trickle(d1)&dynamic'});
</script>

<div id="dummy">Some text</div>

<script>
const testElements = [...document.querySelectorAll('.test')];
const loadObservers = testElements.map(element => new LoadObserver(element));

promise_setup(async () => {
// Test cases are run after rendering is unblocked.
await new Promise(resolve => requestAnimationFrame(resolve));
});

for (let index = 0; index < testElements.length; ++index) {
promise_test(
async () => assert_false(loadObservers[index].finished),
testElements[index].getAttribute('data') + ' is not implicitly render-blocking');
}

for (let index = 0; index < testElements.length; ++index) {
promise_test(
() => loadObservers[index].load,
testElements[index].getAttribute('data') + ' should eventually be loaded and evaluated');
}
</script>

0 comments on commit 953ea49

Please sign in to comment.