From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- .../web-platform/tests/resize-observer/META.yml | 4 + .../resize-observer/calculate-depth-for-node.html | 26 + .../callback-cross-realm-report-exception.html | 30 + .../resize-observer/change-layout-in-error.html | 33 + .../resize-observer/create-pattern-data-url.js | 22 + .../tests/resize-observer/devicepixel-ref.html | 27 + .../tests/resize-observer/devicepixel.html | 85 ++ .../tests/resize-observer/devicepixel2-ref.html | 21 + .../tests/resize-observer/devicepixel2.html | 131 +++ .../tests/resize-observer/eventloop.html | 253 +++++ .../tests/resize-observer/fragments.html | 115 +++ .../tests/resize-observer/idlharness.window.js | 37 + .../resize-observer/iframe-same-origin-ref.html | 7 + .../tests/resize-observer/iframe-same-origin.html | 76 ++ .../web-platform/tests/resize-observer/notify.html | 408 ++++++++ .../tests/resize-observer/observe.html | 1007 ++++++++++++++++++++ .../tests/resize-observer/ordering.html | 24 + .../tests/resize-observer/resources/iframe.html | 38 + .../tests/resize-observer/resources/image.png | Bin 0 -> 170 bytes .../resize-observer/resources/resizeTestHelper.js | 195 ++++ .../tests/resize-observer/scrollbars-2.html | 36 + .../tests/resize-observer/scrollbars.html | 56 ++ .../resize-observer/svg-with-css-box-001.html | 91 ++ .../tests/resize-observer/svg-with-css-box-002.svg | 94 ++ .../web-platform/tests/resize-observer/svg.html | 619 ++++++++++++ 25 files changed, 3435 insertions(+) create mode 100644 testing/web-platform/tests/resize-observer/META.yml create mode 100644 testing/web-platform/tests/resize-observer/calculate-depth-for-node.html create mode 100644 testing/web-platform/tests/resize-observer/callback-cross-realm-report-exception.html create mode 100644 testing/web-platform/tests/resize-observer/change-layout-in-error.html create mode 100644 testing/web-platform/tests/resize-observer/create-pattern-data-url.js create mode 100644 testing/web-platform/tests/resize-observer/devicepixel-ref.html create mode 100644 testing/web-platform/tests/resize-observer/devicepixel.html create mode 100644 testing/web-platform/tests/resize-observer/devicepixel2-ref.html create mode 100644 testing/web-platform/tests/resize-observer/devicepixel2.html create mode 100644 testing/web-platform/tests/resize-observer/eventloop.html create mode 100644 testing/web-platform/tests/resize-observer/fragments.html create mode 100644 testing/web-platform/tests/resize-observer/idlharness.window.js create mode 100644 testing/web-platform/tests/resize-observer/iframe-same-origin-ref.html create mode 100644 testing/web-platform/tests/resize-observer/iframe-same-origin.html create mode 100644 testing/web-platform/tests/resize-observer/notify.html create mode 100644 testing/web-platform/tests/resize-observer/observe.html create mode 100644 testing/web-platform/tests/resize-observer/ordering.html create mode 100644 testing/web-platform/tests/resize-observer/resources/iframe.html create mode 100644 testing/web-platform/tests/resize-observer/resources/image.png create mode 100644 testing/web-platform/tests/resize-observer/resources/resizeTestHelper.js create mode 100644 testing/web-platform/tests/resize-observer/scrollbars-2.html create mode 100644 testing/web-platform/tests/resize-observer/scrollbars.html create mode 100644 testing/web-platform/tests/resize-observer/svg-with-css-box-001.html create mode 100644 testing/web-platform/tests/resize-observer/svg-with-css-box-002.svg create mode 100644 testing/web-platform/tests/resize-observer/svg.html (limited to 'testing/web-platform/tests/resize-observer') diff --git a/testing/web-platform/tests/resize-observer/META.yml b/testing/web-platform/tests/resize-observer/META.yml new file mode 100644 index 0000000000..40ebbe9662 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/META.yml @@ -0,0 +1,4 @@ +spec: https://drafts.csswg.org/resize-observer/ +suggested_reviewers: + - atotic + - dholbert diff --git a/testing/web-platform/tests/resize-observer/calculate-depth-for-node.html b/testing/web-platform/tests/resize-observer/calculate-depth-for-node.html new file mode 100644 index 0000000000..339e52bb79 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/calculate-depth-for-node.html @@ -0,0 +1,26 @@ + + + + + +
+ + diff --git a/testing/web-platform/tests/resize-observer/callback-cross-realm-report-exception.html b/testing/web-platform/tests/resize-observer/callback-cross-realm-report-exception.html new file mode 100644 index 0000000000..75a91ec0a1 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/callback-cross-realm-report-exception.html @@ -0,0 +1,30 @@ + + +ResizeObserver reports the exception from its callback in the callback's global object + + + + + + diff --git a/testing/web-platform/tests/resize-observer/change-layout-in-error.html b/testing/web-platform/tests/resize-observer/change-layout-in-error.html new file mode 100644 index 0000000000..9083fb48f9 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/change-layout-in-error.html @@ -0,0 +1,33 @@ + + + + + +
+ + diff --git a/testing/web-platform/tests/resize-observer/create-pattern-data-url.js b/testing/web-platform/tests/resize-observer/create-pattern-data-url.js new file mode 100644 index 0000000000..d3634dc424 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/create-pattern-data-url.js @@ -0,0 +1,22 @@ +const patternSize = 4; + +export default function createPatternDataURL() { + const ctx = document.createElement('canvas').getContext('2d'); + ctx.canvas.width = patternSize; + ctx.canvas.height = patternSize; + + const b = [0, 0, 0, 255]; + const t = [0, 0, 0, 0]; + const r = [255, 0, 0, 255]; + const g = [0, 255, 0, 255]; + + const imageData = new ImageData(patternSize, patternSize); + imageData.data.set([ + b, t, t, r, + t, b, g, t, + t, r, b, t, + g, t, t, b, + ].flat()); + ctx.putImageData(imageData, 0, 0); + return {patternSize, dataURL: ctx.canvas.toDataURL()}; +} diff --git a/testing/web-platform/tests/resize-observer/devicepixel-ref.html b/testing/web-platform/tests/resize-observer/devicepixel-ref.html new file mode 100644 index 0000000000..a006732015 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/devicepixel-ref.html @@ -0,0 +1,27 @@ + + + +
+
+
+
+
+
+ diff --git a/testing/web-platform/tests/resize-observer/devicepixel.html b/testing/web-platform/tests/resize-observer/devicepixel.html new file mode 100644 index 0000000000..e92079bea5 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/devicepixel.html @@ -0,0 +1,85 @@ + + + + + + + +
+ +
+
+ +
+ + + diff --git a/testing/web-platform/tests/resize-observer/devicepixel2-ref.html b/testing/web-platform/tests/resize-observer/devicepixel2-ref.html new file mode 100644 index 0000000000..7674eb0ab8 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/devicepixel2-ref.html @@ -0,0 +1,21 @@ + + + + diff --git a/testing/web-platform/tests/resize-observer/devicepixel2.html b/testing/web-platform/tests/resize-observer/devicepixel2.html new file mode 100644 index 0000000000..97b6255457 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/devicepixel2.html @@ -0,0 +1,131 @@ + + + + + +
+ + diff --git a/testing/web-platform/tests/resize-observer/eventloop.html b/testing/web-platform/tests/resize-observer/eventloop.html new file mode 100644 index 0000000000..3a9e453faf --- /dev/null +++ b/testing/web-platform/tests/resize-observer/eventloop.html @@ -0,0 +1,253 @@ + +ResizeObserver notification event loop tests + + + +
+ diff --git a/testing/web-platform/tests/resize-observer/fragments.html b/testing/web-platform/tests/resize-observer/fragments.html new file mode 100644 index 0000000000..bba94db88e --- /dev/null +++ b/testing/web-platform/tests/resize-observer/fragments.html @@ -0,0 +1,115 @@ + + +ResizeObserver with multiple fragments + + + + + + + +
+ +
+
+
+ + + + diff --git a/testing/web-platform/tests/resize-observer/idlharness.window.js b/testing/web-platform/tests/resize-observer/idlharness.window.js new file mode 100644 index 0000000000..2d459b0b12 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/idlharness.window.js @@ -0,0 +1,37 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js +// META: script=resources/resizeTestHelper.js + +'use strict'; + +// https://wicg.github.io/ResizeObserver/ + +idl_test( + ['resize-observer'], + ['dom', 'geometry'], + async idl_array => { + idl_array.add_objects({ + ResizeObserver: ['observer'], + ResizeObserverEntry: ['entry'], + }); + + const div = document.createElement('div'); + document.body.appendChild(div); + let helper = new ResizeTestHelper( + "ResizeObserverEntry creator", + [ + { + setup: observer => { + self.observer = observer; + observer.observe(div); + div.style.width = "5px"; + }, + notify: entries => { + self.entry = entries[0]; + assert_equals(entries[0].contentRect.width, 5, "target width"); + } + } + ]); + await helper.start(); + } +); diff --git a/testing/web-platform/tests/resize-observer/iframe-same-origin-ref.html b/testing/web-platform/tests/resize-observer/iframe-same-origin-ref.html new file mode 100644 index 0000000000..142db741ef --- /dev/null +++ b/testing/web-platform/tests/resize-observer/iframe-same-origin-ref.html @@ -0,0 +1,7 @@ + +Resize Observer: reference for the usage of iframes in the same origin + +
+Observer callbacks: 3 diff --git a/testing/web-platform/tests/resize-observer/iframe-same-origin.html b/testing/web-platform/tests/resize-observer/iframe-same-origin.html new file mode 100644 index 0000000000..22d8399b23 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/iframe-same-origin.html @@ -0,0 +1,76 @@ + + +Resize Observer: observed elements and ResizeObserver object are in the + differnt documents + + + + + + + +
+ Observer callbacks: 0 + + + + diff --git a/testing/web-platform/tests/resize-observer/notify.html b/testing/web-platform/tests/resize-observer/notify.html new file mode 100644 index 0000000000..dc2e268b8a --- /dev/null +++ b/testing/web-platform/tests/resize-observer/notify.html @@ -0,0 +1,408 @@ + + + + + +

ResizeObserver tests

+
t1 +
t2 +
t3 + inline +
+
+
+
+ diff --git a/testing/web-platform/tests/resize-observer/observe.html b/testing/web-platform/tests/resize-observer/observe.html new file mode 100644 index 0000000000..f6015bef78 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/observe.html @@ -0,0 +1,1007 @@ + +ResizeObserver tests + + + + +
+ + diff --git a/testing/web-platform/tests/resize-observer/ordering.html b/testing/web-platform/tests/resize-observer/ordering.html new file mode 100644 index 0000000000..1cd9950c53 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/ordering.html @@ -0,0 +1,24 @@ + +ResizeObserver and IntersectionObserver ordering + + + diff --git a/testing/web-platform/tests/resize-observer/resources/iframe.html b/testing/web-platform/tests/resize-observer/resources/iframe.html new file mode 100644 index 0000000000..5c801e6368 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/resources/iframe.html @@ -0,0 +1,38 @@ + + + + +

iframe test

+
t1
+ diff --git a/testing/web-platform/tests/resize-observer/resources/image.png b/testing/web-platform/tests/resize-observer/resources/image.png new file mode 100644 index 0000000000..51741584a0 Binary files /dev/null and b/testing/web-platform/tests/resize-observer/resources/image.png differ diff --git a/testing/web-platform/tests/resize-observer/resources/resizeTestHelper.js b/testing/web-platform/tests/resize-observer/resources/resizeTestHelper.js new file mode 100644 index 0000000000..284a780c25 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/resources/resizeTestHelper.js @@ -0,0 +1,195 @@ +'use strict'; + +/** + ResizeTestHelper is a framework to test ResizeObserver + notifications. Use it to make assertions about ResizeObserverEntries. + This framework is needed because ResizeObservations are + delivered asynchronously inside the event loop. + + Features: + - can queue multiple notification steps in a test + - handles timeouts + - returns Promise that is fulfilled when test completes. + Use to chain tests (since parallel async ResizeObserver tests + would conflict if reusing same DOM elements). + + Usage: + + create ResizeTestHelper for every test. + Make assertions inside notify, timeout callbacks. + Start tests with helper.start() + Chain tests with Promises. + Counts animation frames, see startCountingRaf +*/ + +/* + @param name: test name + @param steps: + { + setup: function(ResizeObserver) { + // called at the beginning of the test step + // your observe/resize code goes here + }, + notify: function(entries, observer) { + // ResizeObserver callback. + // Make assertions here. + // Return true if next step should start on the next event loop. + }, + timeout: function() { + // Define this if your test expects to time out, and the expected timeout + // value will be 100ms. + // If undefined, timeout is assert_unreached after 1000ms. + } + } +*/ +function ResizeTestHelper(name, steps) +{ + this._name = name; + this._steps = steps || []; + this._stepIdx = -1; + this._harnessTest = null; + this._observer = new ResizeObserver(this._handleNotification.bind(this)); + this._timeoutBind = this._handleTimeout.bind(this); + this._nextStepBind = this._nextStep.bind(this); +} + +// The default timeout value in ms. +// We expect TIMEOUT to be longer than we would ever have to wait for notify() +// to be fired. This is used for tests which are not expected to time out, so +// it can be large without slowing down the test. +ResizeTestHelper.TIMEOUT = 1000; +// A reasonable short timeout value in ms. +// We expect SHORT_TIMEOUT to be long enough that notify() would usually get a +// chance to fire before SHORT_TIMEOUT expires. This is used for tests which +// *are* expected to time out (with no callbacks fired), so we'd like to keep +// it relatively short to avoid slowing down the test. +ResizeTestHelper.SHORT_TIMEOUT = 100; + +ResizeTestHelper.prototype = { + get _currentStep() { + return this._steps[this._stepIdx]; + }, + + _nextStep: function() { + if (++this._stepIdx == this._steps.length) + return this._done(); + // Use SHORT_TIMEOUT if this step expects timeout. + let timeoutValue = this._steps[this._stepIdx].timeout ? + ResizeTestHelper.SHORT_TIMEOUT : + ResizeTestHelper.TIMEOUT; + this._timeoutId = this._harnessTest.step_timeout( + this._timeoutBind, timeoutValue); + try { + this._steps[this._stepIdx].setup(this._observer); + } + catch(err) { + this._harnessTest.step(() => { + assert_unreached("Caught a throw, possible syntax error"); + }); + } + }, + + _handleNotification: function(entries) { + if (this._timeoutId) { + window.clearTimeout(this._timeoutId); + delete this._timeoutId; + } + this._harnessTest.step(() => { + try { + let rafDelay = this._currentStep.notify(entries, this._observer); + if (rafDelay) + window.requestAnimationFrame(this._nextStepBind); + else + this._nextStep(); + } + catch(err) { + this._harnessTest.step(() => { + throw err; + }); + // Force to _done() the current test. + this._done(); + } + }); + }, + + _handleTimeout: function() { + delete this._timeoutId; + this._harnessTest.step(() => { + if (this._currentStep.timeout) { + this._currentStep.timeout(); + } + else { + this._harnessTest.step(() => { + assert_unreached("Timed out waiting for notification. (" + ResizeTestHelper.TIMEOUT + "ms)"); + }); + } + this._nextStep(); + }); + }, + + _done: function() { + this._observer.disconnect(); + delete this._observer; + this._harnessTest.done(); + if (this._rafCountRequest) { + window.cancelAnimationFrame(this._rafCountRequest); + delete this._rafCountRequest; + } + window.requestAnimationFrame(() => { this._resolvePromise(); }); + }, + + start: function(cleanup) { + this._harnessTest = async_test(this._name); + + if (cleanup) { + this._harnessTest.add_cleanup(cleanup); + } + + this._harnessTest.step(() => { + assert_equals(this._stepIdx, -1, "start can only be called once"); + this._nextStep(); + }); + return new Promise( (resolve, reject) => { + this._resolvePromise = resolve; + this._rejectPromise = reject; + }); + }, + + get rafCount() { + if (!this._rafCountRequest) + throw "rAF count is not active"; + return this._rafCount; + }, + + get test() { + if (!this._harnessTest) { + throw "_harnessTest is not initialized"; + } + return this._harnessTest; + }, + + _incrementRaf: function() { + if (this._rafCountRequest) { + this._rafCount++; + this._rafCountRequest = window.requestAnimationFrame(this._incrementRafBind); + } + }, + + startCountingRaf: function() { + if (this._rafCountRequest) + window.cancelAnimationFrame(this._rafCountRequest); + if (!this._incrementRafBind) + this._incrementRafBind = this._incrementRaf.bind(this); + this._rafCount = 0; + this._rafCountRequest = window.requestAnimationFrame(this._incrementRafBind); + } +} + +function createAndAppendElement(tagName, parent) { + if (!parent) { + parent = document.body; + } + const element = document.createElement(tagName); + parent.appendChild(element); + return element; +} diff --git a/testing/web-platform/tests/resize-observer/scrollbars-2.html b/testing/web-platform/tests/resize-observer/scrollbars-2.html new file mode 100644 index 0000000000..51b470c8a2 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/scrollbars-2.html @@ -0,0 +1,36 @@ + +ResizeObserver content-box size and scrollbars + + + + +
+ diff --git a/testing/web-platform/tests/resize-observer/scrollbars.html b/testing/web-platform/tests/resize-observer/scrollbars.html new file mode 100644 index 0000000000..129e74e5cd --- /dev/null +++ b/testing/web-platform/tests/resize-observer/scrollbars.html @@ -0,0 +1,56 @@ + +ResizeObserver content-box size and scrollbars + + + + +
+
+
+ diff --git a/testing/web-platform/tests/resize-observer/svg-with-css-box-001.html b/testing/web-platform/tests/resize-observer/svg-with-css-box-001.html new file mode 100644 index 0000000000..4ec0a7de72 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/svg-with-css-box-001.html @@ -0,0 +1,91 @@ + +ResizeObserver for SVG elements with CSS box. + + + +
+ + + + + + + + + diff --git a/testing/web-platform/tests/resize-observer/svg-with-css-box-002.svg b/testing/web-platform/tests/resize-observer/svg-with-css-box-002.svg new file mode 100644 index 0000000000..3c009641db --- /dev/null +++ b/testing/web-platform/tests/resize-observer/svg-with-css-box-002.svg @@ -0,0 +1,94 @@ + + +ResizeObserver for SVG elements with CSS box. + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resize-observer/svg.html b/testing/web-platform/tests/resize-observer/svg.html new file mode 100644 index 0000000000..6511afc8b0 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/svg.html @@ -0,0 +1,619 @@ + + + + +

ResizeObserver svg tests

+ + + + + +

Here is a paragraph that requires word wrap

+ +
+ + + + + + + svg text tag + + + +
+ -- cgit v1.2.3