From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../blocking-idl-attr.tentative.html | 44 ++++++++ .../non-render-blocking-scripts.optional.html | 61 +++++++++++ .../parser-blocking-script.tentative.html | 19 ++++ .../parser-inserted-async-script.tentative.html | 19 ++++ .../parser-inserted-defer-script.tentative.html | 19 ++++ .../parser-inserted-module-script.tentative.html | 19 ++++ .../parser-inserted-style-element.tentative.html | 20 ++++ .../parser-inserted-stylesheet-link.tentative.html | 18 ++++ ...emove-attr-script-keeps-blocking.tentative.html | 25 +++++ ...remove-attr-style-keeps-blocking.tentative.html | 28 +++++ ...r-stylesheet-link-keeps-blocking.tentative.html | 27 +++++ .../remove-attr-unblocks-rendering.optional.html | 86 +++++++++++++++ ...remove-element-unblocks-rendering.optional.html | 83 +++++++++++++++ ...emove-pending-async-render-blocking-script.html | 19 ++++ .../script-inserted-module-script.tentative.html | 22 ++++ .../render-blocking/script-inserted-script.html | 21 ++++ .../script-inserted-style-element.tentative.html | 26 +++++ .../script-inserted-stylesheet-link.tentative.html | 27 +++++ .../html/dom/render-blocking/support/dummy-1.js | 1 + .../html/dom/render-blocking/support/dummy-1.mjs | 1 + .../dom/render-blocking/support/target-red.css | 3 + .../support/test-render-blocking.js | 118 +++++++++++++++++++++ 22 files changed, 706 insertions(+) create mode 100644 testing/web-platform/tests/html/dom/render-blocking/blocking-idl-attr.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/non-render-blocking-scripts.optional.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/parser-blocking-script.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/parser-inserted-async-script.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/parser-inserted-defer-script.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/parser-inserted-module-script.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/parser-inserted-style-element.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/parser-inserted-stylesheet-link.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/remove-attr-script-keeps-blocking.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/remove-attr-style-keeps-blocking.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/remove-attr-stylesheet-link-keeps-blocking.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/remove-attr-unblocks-rendering.optional.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/remove-element-unblocks-rendering.optional.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/remove-pending-async-render-blocking-script.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/script-inserted-module-script.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/script-inserted-script.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/script-inserted-style-element.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/script-inserted-stylesheet-link.tentative.html create mode 100644 testing/web-platform/tests/html/dom/render-blocking/support/dummy-1.js create mode 100644 testing/web-platform/tests/html/dom/render-blocking/support/dummy-1.mjs create mode 100644 testing/web-platform/tests/html/dom/render-blocking/support/target-red.css create mode 100644 testing/web-platform/tests/html/dom/render-blocking/support/test-render-blocking.js (limited to 'testing/web-platform/tests/html/dom/render-blocking') diff --git a/testing/web-platform/tests/html/dom/render-blocking/blocking-idl-attr.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/blocking-idl-attr.tentative.html new file mode 100644 index 0000000000..c33b411eb4 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/blocking-idl-attr.tentative.html @@ -0,0 +1,44 @@ + +Tests the 'blocking' IDL attribute on link, script and style elements + + + diff --git a/testing/web-platform/tests/html/dom/render-blocking/non-render-blocking-scripts.optional.html b/testing/web-platform/tests/html/dom/render-blocking/non-render-blocking-scripts.optional.html new file mode 100644 index 0000000000..a4c32ea037 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/non-render-blocking-scripts.optional.html @@ -0,0 +1,61 @@ + +Tests when script is not implicitly potentially render-blocking + + + + + + + + + + + + + + +
Some text
+ + diff --git a/testing/web-platform/tests/html/dom/render-blocking/parser-blocking-script.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/parser-blocking-script.tentative.html new file mode 100644 index 0000000000..8d391144b2 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/parser-blocking-script.tentative.html @@ -0,0 +1,19 @@ + +Parser-blocking script elements are implicitly render-blocking + + + + + + + + +
Some more text
diff --git a/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-async-script.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-async-script.tentative.html new file mode 100644 index 0000000000..4b2216dfcb --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-async-script.tentative.html @@ -0,0 +1,19 @@ + +Parser-inserted async script elements with "blocking=render" are render-blocking + + + + + + +
Some text
+ + diff --git a/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-defer-script.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-defer-script.tentative.html new file mode 100644 index 0000000000..1ae8caf2ec --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-defer-script.tentative.html @@ -0,0 +1,19 @@ + +Parser-inserted defer script elements with "blocking=render" are render-blocking + + + + + + +
Some text
+ + diff --git a/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-module-script.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-module-script.tentative.html new file mode 100644 index 0000000000..2bca88e73c --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-module-script.tentative.html @@ -0,0 +1,19 @@ + +Parser-inserted module script elements with "blocking=render" are render-blocking + + + + + + +
some text
+ + diff --git a/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-style-element.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-style-element.tentative.html new file mode 100644 index 0000000000..9a358aa493 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-style-element.tentative.html @@ -0,0 +1,20 @@ + +Parser-inserted style elements are implicitly render-blocking + + + + + +
+ This should be red +
diff --git a/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-stylesheet-link.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-stylesheet-link.tentative.html new file mode 100644 index 0000000000..0a771448fd --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/parser-inserted-stylesheet-link.tentative.html @@ -0,0 +1,18 @@ + +Parser-inserted stylesheet links are implicitly render-blocking + + + + + +
+ This should be red +
diff --git a/testing/web-platform/tests/html/dom/render-blocking/remove-attr-script-keeps-blocking.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/remove-attr-script-keeps-blocking.tentative.html new file mode 100644 index 0000000000..451d2f3695 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/remove-attr-script-keeps-blocking.tentative.html @@ -0,0 +1,25 @@ + +Synchronous script element still blocks rendering after removing `blocking=render` + + + + + + + diff --git a/testing/web-platform/tests/html/dom/render-blocking/remove-attr-style-keeps-blocking.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/remove-attr-style-keeps-blocking.tentative.html new file mode 100644 index 0000000000..31d4b56838 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/remove-attr-style-keeps-blocking.tentative.html @@ -0,0 +1,28 @@ + +Parser-inserted style element still blocks rendering after removing `blocking=render` + + + + + + + + +
Some text
diff --git a/testing/web-platform/tests/html/dom/render-blocking/remove-attr-stylesheet-link-keeps-blocking.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/remove-attr-stylesheet-link-keeps-blocking.tentative.html new file mode 100644 index 0000000000..1248b90b23 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/remove-attr-stylesheet-link-keeps-blocking.tentative.html @@ -0,0 +1,27 @@ + +Parser-inserted stylesheet link still blocks rendering after removing `blocking=render` + + + + + + + + +
Some text
diff --git a/testing/web-platform/tests/html/dom/render-blocking/remove-attr-unblocks-rendering.optional.html b/testing/web-platform/tests/html/dom/render-blocking/remove-attr-unblocks-rendering.optional.html new file mode 100644 index 0000000000..c73e3c6452 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/remove-attr-unblocks-rendering.optional.html @@ -0,0 +1,86 @@ + +Removing `blocking=render` should unblock rendering + + + + + + + + + + + + + + + + + +
Some text
+ + + diff --git a/testing/web-platform/tests/html/dom/render-blocking/remove-element-unblocks-rendering.optional.html b/testing/web-platform/tests/html/dom/render-blocking/remove-element-unblocks-rendering.optional.html new file mode 100644 index 0000000000..ad49c48c2e --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/remove-element-unblocks-rendering.optional.html @@ -0,0 +1,83 @@ + +Removing render-blocking element should unblock rendering + + + + + + + + + + + + + + + + + +
Some text
+ + + diff --git a/testing/web-platform/tests/html/dom/render-blocking/remove-pending-async-render-blocking-script.html b/testing/web-platform/tests/html/dom/render-blocking/remove-pending-async-render-blocking-script.html new file mode 100644 index 0000000000..5f6e8b34d1 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/remove-pending-async-render-blocking-script.html @@ -0,0 +1,19 @@ + +Removed render-blocking script should not indefinitely block rendering + + + + diff --git a/testing/web-platform/tests/html/dom/render-blocking/script-inserted-module-script.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/script-inserted-module-script.tentative.html new file mode 100644 index 0000000000..73f0d3cdf4 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/script-inserted-module-script.tentative.html @@ -0,0 +1,22 @@ + +Script-inserted module script elements with "blocking=render" are render-blocking + + + + + + +
some text
+ + diff --git a/testing/web-platform/tests/html/dom/render-blocking/script-inserted-script.html b/testing/web-platform/tests/html/dom/render-blocking/script-inserted-script.html new file mode 100644 index 0000000000..faf346b4dd --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/script-inserted-script.html @@ -0,0 +1,21 @@ + +Script-inserted script elements with "blocking=render" are render-blocking + + + + + + +
Some text
+ + diff --git a/testing/web-platform/tests/html/dom/render-blocking/script-inserted-style-element.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/script-inserted-style-element.tentative.html new file mode 100644 index 0000000000..683706af50 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/script-inserted-style-element.tentative.html @@ -0,0 +1,26 @@ + +Script-inserted style elements with "blocking=render" are render-blocking + + + + + + +
+ This should be red +
+ + diff --git a/testing/web-platform/tests/html/dom/render-blocking/script-inserted-stylesheet-link.tentative.html b/testing/web-platform/tests/html/dom/render-blocking/script-inserted-stylesheet-link.tentative.html new file mode 100644 index 0000000000..46755387d7 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/script-inserted-stylesheet-link.tentative.html @@ -0,0 +1,27 @@ + +Script-inserted stylesheet links with "blocking=render" are render-blocking + + + + + + +
+ This should be red +
+ + diff --git a/testing/web-platform/tests/html/dom/render-blocking/support/dummy-1.js b/testing/web-platform/tests/html/dom/render-blocking/support/dummy-1.js new file mode 100644 index 0000000000..597772cf64 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/support/dummy-1.js @@ -0,0 +1 @@ +window.dummy = 1; diff --git a/testing/web-platform/tests/html/dom/render-blocking/support/dummy-1.mjs b/testing/web-platform/tests/html/dom/render-blocking/support/dummy-1.mjs new file mode 100644 index 0000000000..9b85a21033 --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/support/dummy-1.mjs @@ -0,0 +1 @@ +document.getElementById('dummy').textContent = 1; diff --git a/testing/web-platform/tests/html/dom/render-blocking/support/target-red.css b/testing/web-platform/tests/html/dom/render-blocking/support/target-red.css new file mode 100644 index 0000000000..a387acd4ec --- /dev/null +++ b/testing/web-platform/tests/html/dom/render-blocking/support/target-red.css @@ -0,0 +1,3 @@ +.target { + color: red; +} diff --git a/testing/web-platform/tests/html/dom/render-blocking/support/test-render-blocking.js b/testing/web-platform/tests/html/dom/render-blocking/support/test-render-blocking.js new file mode 100644 index 0000000000..71d0d68096 --- /dev/null +++ b/testing/web-platform/tests/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); +} -- cgit v1.2.3