Truly independent web browser
LibWeb: Import WPT coverage for resource render blocking
Andreas Kling7107ae32fc97
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.iniindex 9582fc94d6d..92babce62e2 100644--- a/Tests/LibWeb/TestConfig.ini+++ b/Tests/LibWeb/TestConfig.ini@@ -12,6 +12,19 @@ Text/input/wpt-import/geolocation/Text/input/wpt-import/permissions/; Their harness scripts are served from the WPT root, which a file: page cannot reach.Crash/wpt-import/permissions/+; Render-blocking tests need delayed HTTP responses and module imports.+Text/input/wpt-import/html/dom/render-blocking/blocking-idl-attr.html+Text/input/wpt-import/html/dom/render-blocking/script-inserted-inline-module-with-import.html+Text/input/wpt-import/html/dom/render-blocking/parser-inserted-module-script.html+Text/input/wpt-import/html/dom/render-blocking/script-inserted-stylesheet-link.html+Text/input/wpt-import/html/dom/render-blocking/parser-inserted-async-inline-module-with-import.html+Text/input/wpt-import/html/dom/render-blocking/script-inserted-module-script.html+Text/input/wpt-import/html/dom/render-blocking/parser-inserted-async-script.html+Text/input/wpt-import/html/dom/render-blocking/parser-inserted-defer-script.html+Text/input/wpt-import/html/dom/render-blocking/remove-attr-script-keeps-blocking.html+Text/input/wpt-import/html/dom/render-blocking/parser-inserted-inline-module-with-import.html+Text/input/wpt-import/html/dom/render-blocking/stylesheet-link-href-change-keeps-blocking.html+Text/input/wpt-import/html/dom/render-blocking/script-inserted-script.htmlText/input/HTML/xml-document-encoding.htmlText/input/HTML/createImageBitmap-video.htmlText/input/HTML/HTMLVideoElement-capture-before-seek-keeps-frame.htmldiff --git a/Tests/LibWeb/Text/expected/HTML/blocking-tokens-reflection.txt b/Tests/LibWeb/Text/expected/HTML/blocking-tokens-reflection.txtnew file mode 100644index 00000000000..1f1e5132711--- /dev/null+++ b/Tests/LibWeb/Text/expected/HTML/blocking-tokens-reflection.txt@@ -0,0 +1,3 @@+link: blocking is undefined+script: blocking is undefined+style: blocking is undefineddiff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/blocking-idl-attr.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/blocking-idl-attr.txtnew file mode 100644index 00000000000..c98f20c9837--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/blocking-idl-attr.txt@@ -0,0 +1,11 @@+Harness status: OK++Found 6 tests++6 Fail+Fail Supported tokens of the 'blocking' IDL attribute of the link element+Fail Setting the 'blocking' IDL attribute of the link element+Fail Supported tokens of the 'blocking' IDL attribute of the script element+Fail Setting the 'blocking' IDL attribute of the script element+Fail Supported tokens of the 'blocking' IDL attribute of the style element+Fail Setting the 'blocking' IDL attribute of the style element\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-async-inline-module-with-import.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-async-inline-module-with-import.txtnew file mode 100644index 00000000000..6e9b7b7f31a--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-async-inline-module-with-import.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail Parser-inserted async inline module script elements with "blocking=render" are render-blocking\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-async-script.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-async-script.txtnew file mode 100644index 00000000000..97b28fcac73--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-async-script.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail Rendering is blocked before render-blocking resources are loaded+Pass Parser-inserted render-blocking async script is evaluated\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-defer-script.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-defer-script.txtnew file mode 100644index 00000000000..eeace5f939b--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-defer-script.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail Rendering is blocked before render-blocking resources are loaded+Pass Parser-inserted render-blocking defer script is evaluated\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-inline-module-with-import.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-inline-module-with-import.txtnew file mode 100644index 00000000000..d307f6eece9--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-inline-module-with-import.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail Parser-inserted module script elements with "blocking=render" are render-blocking\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-module-script.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-module-script.txtnew file mode 100644index 00000000000..fece26ac744--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/parser-inserted-module-script.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail Rendering is blocked before render-blocking resources are loaded+Pass Parser-inserted render-blocking module script is evaluated\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/remove-attr-script-keeps-blocking.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/remove-attr-script-keeps-blocking.txtnew file mode 100644index 00000000000..c09c1e308be--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/remove-attr-script-keeps-blocking.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail Rendering is blocked before render-blocking resources are loaded+Pass Render-blocking script is loaded and evaluated\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/script-inserted-inline-module-with-import.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/script-inserted-inline-module-with-import.txtnew file mode 100644index 00000000000..d6089b394e8--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/script-inserted-inline-module-with-import.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail Script-inserted module script elements with "blocking=render" are render-blocking\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/script-inserted-module-script.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/script-inserted-module-script.txtnew file mode 100644index 00000000000..02384e62001--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/script-inserted-module-script.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail Rendering is blocked before render-blocking resources are loaded+Pass Script-inserted render-blocking module script is evaluated\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/script-inserted-script.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/script-inserted-script.txtnew file mode 100644index 00000000000..11274f78b4e--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/script-inserted-script.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail Rendering is blocked before render-blocking resources are loaded+Pass Script-inserted render-blocking script is evaluated\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/script-inserted-stylesheet-link.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/script-inserted-stylesheet-link.txtnew file mode 100644index 00000000000..e0d8b05e0e4--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/script-inserted-stylesheet-link.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail Rendering is blocked before render-blocking resources are loaded+Pass Render-blocking stylesheet is applied\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/stylesheet-link-href-change-keeps-blocking.txt b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/stylesheet-link-href-change-keeps-blocking.txtnew file mode 100644index 00000000000..e1d18367a80--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/dom/render-blocking/stylesheet-link-href-change-keeps-blocking.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail The stylesheet with the new href applies in the first rendering update\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/HTML/blocking-tokens-reflection.html b/Tests/LibWeb/Text/input/HTML/blocking-tokens-reflection.htmlnew file mode 100644index 00000000000..09029cdc14c--- /dev/null+++ b/Tests/LibWeb/Text/input/HTML/blocking-tokens-reflection.html@@ -0,0 +1,26 @@+<!doctype html>+<script src="../include.js"></script>+<script>+ test(() => {+ for (const name of ["link", "script", "style"]) {+ const element = document.createElement(name);+ const tokens = element.blocking;+ if (!tokens) {+ println(`${name}: blocking is ${tokens}`);+ continue;+ }+ println(`${name}: same object ${tokens === element.blocking}`);+ element.setAttribute("blocking", "render extra");+ println(`attribute to tokens: ${tokens.value}, ${tokens.length}`);+ element.blocking = "RENDER";+ println(`tokens to attribute: ${element.getAttribute("blocking")}`);+ println(`supported: ${tokens.supports("render")}, ${tokens.supports("RENDER")}, ${tokens.supports("extra")}`);+ element.setAttributeNS("urn:test", "test:blocking", "other");+ println(`namespaced attribute leaves tokens: ${tokens.value}`);+ tokens.add("other");+ println(`added token: ${element.getAttribute("blocking")}`);+ element.removeAttribute("blocking");+ println(`removed attribute empties tokens: ${tokens.length}`);+ }+ });+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/blocking-idl-attr.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/blocking-idl-attr.htmlnew file mode 100644index 00000000000..18aadb76e46--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/blocking-idl-attr.html@@ -0,0 +1,44 @@+<!DOCTYPE html>+<title>Tests the 'blocking' IDL attribute on link, script and style elements</title>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script>+// Tests that the 'blocking' attribute follows the IDL:+// [SameObject, PutForwards=value] readonly attribute DOMTokenList blocking;++test(() => {+ const link = document.createElement('link');+ assert_true(link.blocking.supports('render'));+ assert_false(link.blocking.supports('asdf'));+}, "Supported tokens of the 'blocking' IDL attribute of the link element");++test(() => {+ const link = document.createElement('link');+ link.blocking = 'asdf';+ assert_equals(link.blocking.value, 'asdf');+}, "Setting the 'blocking' IDL attribute of the link element");++test(() => {+ const script = document.createElement('script');+ assert_true(script.blocking.supports('render'));+ assert_false(script.blocking.supports('asdf'));+}, "Supported tokens of the 'blocking' IDL attribute of the script element");++test(() => {+ const script = document.createElement('script');+ script.blocking = 'asdf';+ assert_equals(script.blocking.value, 'asdf');+}, "Setting the 'blocking' IDL attribute of the script element");++test(() => {+ const style = document.createElement('style');+ assert_true(style.blocking.supports('render'));+ assert_false(style.blocking.supports('asdf'));+}, "Supported tokens of the 'blocking' IDL attribute of the style element");++test(() => {+ const style = document.createElement('style');+ style.blocking = 'asdf';+ assert_equals(style.blocking.value, 'asdf');+}, "Setting the 'blocking' IDL attribute of the style element");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-async-inline-module-with-import.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-async-inline-module-with-import.htmlnew file mode 100644index 00000000000..f660a6c5db5--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-async-inline-module-with-import.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<head>+<title>Parser-inserted async inline module script elements with "blocking=render" are render-blocking</title>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script>+ window.did_execute_script = false;+</script>+<script type="module" blocking="render" async>+ import "../../../loading/resources/dummy.js?pipe=trickle(d1)";+ window.did_execute_script = true;+</script>+</head>+<div id="dummy">some text</div>++<script>+ promise_test(async t => {+ await new Promise(resolve => requestAnimationFrame(() => resolve()));+ assert_true(window.did_execute_script, "Parser-inserted async render-blocking inline module script should execute before rAF callback");+ });+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-async-script.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-async-script.htmlnew file mode 100644index 00000000000..4614bfdc1df--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-async-script.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<title>Parser-inserted async script elements with "blocking=render" are render-blocking</title>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="support/test-render-blocking.js"></script>++<script id="async-script" async blocking="render"+ src="support/dummy-1.js?pipe=trickle(d1)">+</script>++<div>Some text</div>++<script>+const asyncScript = document.getElementById('async-script');+test_render_blocking(+ asyncScript,+ () => assert_equals(window.dummy, 1),+ 'Parser-inserted render-blocking async script is evaluated');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-defer-script.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-defer-script.htmlnew file mode 100644index 00000000000..3c3ed4df445--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-defer-script.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<title>Parser-inserted defer script elements with "blocking=render" are render-blocking</title>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="support/test-render-blocking.js"></script>++<script id="defer-script" defer blocking="render"+ src="support/dummy-1.js?pipe=trickle(d1)">+</script>++<div>Some text</div>++<script>+const deferScript = document.getElementById('defer-script');+test_render_blocking(+ deferScript,+ () => assert_equals(window.dummy, 1),+ 'Parser-inserted render-blocking defer script is evaluated');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-inline-module-with-import.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-inline-module-with-import.htmlnew file mode 100644index 00000000000..9760a58d30c--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-inline-module-with-import.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<head>+<title>Parser-inserted module script elements with "blocking=render" are render-blocking</title>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script>+ window.did_execute_script = false;+</script>+<script type="module" blocking="render">+ import "../../../loading/resources/dummy.js?pipe=trickle(d1)";+ window.did_execute_script = true;+</script>+</head>+<div id="dummy">some text</div>++<script>+ promise_test(async t => {+ await new Promise(resolve => requestAnimationFrame(() => resolve()));+ assert_true(window.did_execute_script, "Parser-inserted render-blocking inline module script should execute before rAF callback");+ });+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-module-script.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-module-script.htmlnew file mode 100644index 00000000000..554ef7b14bf--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/parser-inserted-module-script.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<title>Parser-inserted module script elements with "blocking=render" are render-blocking</title>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="support/test-render-blocking.js"></script>++<script id="module-script" type="module" blocking="render"+ src="support/dummy-1.mjs?pipe=trickle(d1)">+</script>++<div id="dummy">some text</div>++<script>+const moduleScript = document.getElementById('module-script');+test_render_blocking(+ moduleScript,+ () => assert_equals(document.getElementById('dummy').textContent, '1'),+ 'Parser-inserted render-blocking module script is evaluated');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/remove-attr-script-keeps-blocking.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/remove-attr-script-keeps-blocking.htmlnew file mode 100644index 00000000000..d2a7fc4dc9a--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/remove-attr-script-keeps-blocking.html@@ -0,0 +1,25 @@+<!DOCTYPE html>+<title>Synchronous script element still blocks rendering after removing `blocking=render`</title>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="support/test-render-blocking.js"></script>++<script>+// Test script must be added before the synchronous script because the+// synchronous script is parser-blocking.++promise_setup(async () => {+ let script = await nodeInserted(document.head, node => node.id === 'script');+ script.blocking = '';++ // Also inserts some contents for non-compliant UA to render+ document.body = document.createElement('body');+ document.body.appendChild(document.createTextNode('Some text'));+});++test_render_blocking(+ () => assert_equals(window.dummy, 1),+ 'Render-blocking script is loaded and evaluated');+</script>++<script id="script" blocking="render" src="support/dummy-1.js?pipe=trickle(d1)"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/script-inserted-inline-module-with-import.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/script-inserted-inline-module-with-import.htmlnew file mode 100644index 00000000000..87308e30a25--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/script-inserted-inline-module-with-import.html@@ -0,0 +1,25 @@+<!DOCTYPE html>+<head>+<title>Script-inserted module script elements with "blocking=render" are render-blocking</title>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script>+ window.did_execute_script = false;+ const script = document.createElement("script");+ script.type = "module";+ script.blocking = "render";+ script.textContent = `+ import "../../../loading/resources/dummy.js?pipe=trickle(d1)";+ window.did_execute_script = true;+ `;+ document.head.append(script);+</script>+</head>+<div id="dummy">some text</div>++<script>+ promise_test(async t => {+ await new Promise(resolve => requestAnimationFrame(() => resolve()));+ assert_true(window.did_execute_script, "Script-inserted render-blocking inline module script should execute before rAF callback");+ });+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/script-inserted-module-script.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/script-inserted-module-script.htmlnew file mode 100644index 00000000000..144cc2cca85--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/script-inserted-module-script.html@@ -0,0 +1,22 @@+<!DOCTYPE html>+<title>Script-inserted module script elements with "blocking=render" are render-blocking</title>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="support/test-render-blocking.js"></script>++<script>+const moduleScript = document.createElement('script');+moduleScript.type = 'module';+moduleScript.blocking = 'render';+moduleScript.src = 'support/dummy-1.mjs?pipe=trickle(d1)';+document.head.appendChild(moduleScript);+</script>++<div id="dummy">some text</div>++<script>+test_render_blocking(+ moduleScript,+ () => assert_equals(document.getElementById('dummy').textContent, '1'),+ 'Script-inserted render-blocking module script is evaluated');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/script-inserted-script.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/script-inserted-script.htmlnew file mode 100644index 00000000000..92089bc07de--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/script-inserted-script.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<title>Script-inserted script elements with "blocking=render" are render-blocking</title>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="support/test-render-blocking.js"></script>++<script>+const script = document.createElement('script');+script.src = 'support/dummy-1.js?pipe=trickle(d1)';+script.blocking = 'render';+document.head.appendChild(script);+</script>++<div>Some text</div>++<script>+test_render_blocking(+ script,+ () => assert_equals(window.dummy, 1),+ 'Script-inserted render-blocking script is evaluated');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/script-inserted-stylesheet-link.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/script-inserted-stylesheet-link.htmlnew file mode 100644index 00000000000..b2a1b5f2f7e--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/script-inserted-stylesheet-link.html@@ -0,0 +1,27 @@+<!doctype html>+<title>Script-inserted stylesheet links with "blocking=render" are render-blocking</title>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="support/test-render-blocking.js"></script>++<script>+const stylesheet = document.createElement('link');+stylesheet.rel = 'stylesheet';+stylesheet.href = 'support/target-red.css?pipe=trickle(d1)';+stylesheet.blocking = 'render';+document.head.appendChild(stylesheet);+</script>++<div class="target">+ This should be red+</div>++<script>+test_render_blocking(+ stylesheet,+ () => {+ let color = getComputedStyle(document.querySelector('.target')).color;+ assert_equals(color, 'rgb(255, 0, 0)');+ },+ 'Render-blocking stylesheet is applied');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/stylesheet-link-href-change-keeps-blocking.html b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/stylesheet-link-href-change-keeps-blocking.htmlnew file mode 100644index 00000000000..734c24f485d--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/stylesheet-link-href-change-keeps-blocking.html@@ -0,0 +1,33 @@+<!doctype html>+<title>Changing href of a render-blocking stylesheet link keeps rendering blocked until the new stylesheet loads</title>+<link rel="help" href="https://html.spec.whatwg.org/#blocking-attributes">+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>++<script>+const stylesheet = document.createElement('link');+stylesheet.rel = 'stylesheet';+stylesheet.href = 'support/target-red.css?pipe=trickle(d1)';+stylesheet.blocking = 'render';+document.head.appendChild(stylesheet);+stylesheet.href = 'support/target-red.css?pipe=trickle(d2)&second';++// A render-blocked document has no rendering updates, so the first animation+// frame callback runs only after the new stylesheet has loaded.+let colorInFirstFrame;+requestAnimationFrame(() => {+ colorInFirstFrame =+ getComputedStyle(document.querySelector('.target')).color;+});+</script>++<div class="target">+ This should be red+</div>++<script>+promise_test(async test => {+ await test.step_wait(() => colorInFirstFrame !== undefined);+ assert_equals(colorInFirstFrame, 'rgb(255, 0, 0)');+}, 'The stylesheet with the new href applies in the first rendering update');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/support/dummy-1.js b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/support/dummy-1.jsnew file mode 100644index 00000000000..597772cf641--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/support/dummy-1.js@@ -0,0 +1 @@+window.dummy = 1;diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/support/dummy-1.mjs b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/support/dummy-1.mjsnew file mode 100644index 00000000000..9b85a21033e--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/support/dummy-1.mjs@@ -0,0 +1 @@+document.getElementById('dummy').textContent = 1;diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/support/target-red.css b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/support/target-red.cssnew file mode 100644index 00000000000..a387acd4ecb--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/support/target-red.css@@ -0,0 +1,3 @@+.target {+ color: red;+}diff --git a/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/support/test-render-blocking.js b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/support/test-render-blocking.jsnew file mode 100644index 00000000000..71d0d680966--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/dom/render-blocking/support/test-render-blocking.js@@ -0,0 +1,118 @@+// Observes the `load` event of an EventTarget, or the finishing of a resource+// given its url. Requires `/preload/resources/preload_helper.js` for the latter+// usage.+class LoadObserver {+ constructor(target) {+ this.finishTime = null;+ this.load = new Promise((resolve, reject) => {+ if (target.addEventListener) {+ target.addEventListener('load', ev => {+ this.finishTime = ev.timeStamp;+ resolve(ev);+ });+ target.addEventListener('error', reject);+ } else if (typeof target === 'string') {+ const observer = new PerformanceObserver(() => {+ if (numberOfResourceTimingEntries(target)) {+ this.finishTime = performance.now();+ resolve();+ }+ });+ observer.observe({type: 'resource', buffered: true});+ } else {+ reject('Unsupported target for LoadObserver');+ }+ });+ }++ get finished() {+ return this.finishTime !== null;+ }+}++// Observes the insertion of a script/parser-blocking element into DOM via+// MutationObserver, so that we can access the element before it's loaded.+function nodeInserted(parentNode, predicate) {+ return new Promise(resolve => {+ function callback(mutationList) {+ for (let mutation of mutationList) {+ for (let node of mutation.addedNodes) {+ if (predicate(node))+ resolve(node);+ }+ }+ }+ new MutationObserver(callback).observe(parentNode, {childList: true});+ });+}++function createAutofocusTarget() {+ const autofocusTarget = document.createElement('textarea');+ autofocusTarget.setAttribute('autofocus', '');+ // We may not have a body element at this point if we are testing a+ // script-blocking stylesheet. Hence, the new element is added to+ // documentElement.+ document.documentElement.appendChild(autofocusTarget);+ return autofocusTarget;+}++function createScrollTarget() {+ const scrollTarget = document.createElement('div');+ scrollTarget.style.overflow = 'scroll';+ scrollTarget.style.height = '100px';+ const scrollContent = document.createElement('div');+ scrollContent.style.height = '200px';+ scrollTarget.appendChild(scrollContent);+ document.documentElement.appendChild(scrollTarget);+ return scrollTarget;+}++function createAnimationTarget() {+ const style = document.createElement('style');+ style.textContent = `+ @keyframes anim {+ from { height: 100px; }+ to { height: 200px; }+ }+ `;+ const animationTarget = document.createElement('div');+ animationTarget.style.backgroundColor = 'green';+ animationTarget.style.height = '50px';+ animationTarget.style.animation = 'anim 100ms';+ document.documentElement.appendChild(style);+ document.documentElement.appendChild(animationTarget);+ return animationTarget;+}++// Error margin for comparing timestamps of paint and load events, in case they+// are reported by different threads.+const epsilon = 50;++function test_render_blocking(optionalElementOrUrl, finalTest, finalTestTitle) {+ // Ideally, we should observe the 'load' event on the specific render-blocking+ // elements. However, this is not possible for script-blocking stylesheets, so+ // we have to observe the 'load' event on 'window' instead.+ if (!(optionalElementOrUrl instanceof HTMLElement) &&+ typeof optionalElementOrUrl !== 'string') {+ finalTestTitle = finalTest;+ finalTest = optionalElementOrUrl;+ optionalElementOrUrl = undefined;+ }+ const loadObserver = new LoadObserver(optionalElementOrUrl || window);++ promise_test(async test => {+ assert_implements(window.PerformancePaintTiming);++ await test.step_wait(() => performance.getEntriesByType('paint').length);++ assert_true(loadObserver.finished);+ for (let entry of performance.getEntriesByType('paint')) {+ assert_greater_than(entry.startTime, loadObserver.finishTime - epsilon,+ `${entry.name} should occur after loading render-blocking resources`);+ }+ }, 'Rendering is blocked before render-blocking resources are loaded');++ promise_test(test => {+ return loadObserver.load.then(() => finalTest(test));+ }, finalTestTitle);+}diff --git a/Tests/LibWeb/Text/input/wpt-import/loading/resources/dummy.js b/Tests/LibWeb/Text/input/wpt-import/loading/resources/dummy.jsnew file mode 100644index 00000000000..3cae1be79e4--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/loading/resources/dummy.js@@ -0,0 +1 @@+/* Nothing to see here */