diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index 2c8a8b9b03afa9..3929fadeaa57e3 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -14,7 +14,7 @@ Last update: - compression: https://github.com/web-platform-tests/wpt/tree/5aa50dd415/compression - console: https://github.com/web-platform-tests/wpt/tree/767ae35464/console - dom/abort: https://github.com/web-platform-tests/wpt/tree/0143fe244b/dom/abort -- dom/events: https://github.com/web-platform-tests/wpt/tree/0a811c5161/dom/events +- dom/events: https://github.com/web-platform-tests/wpt/tree/922a7fe9a4/dom/events - encoding: https://github.com/web-platform-tests/wpt/tree/1ac8deee08/encoding - fetch/data-urls/resources: https://github.com/web-platform-tests/wpt/tree/7c79d998ff/fetch/data-urls/resources - FileAPI: https://github.com/web-platform-tests/wpt/tree/cceaf3628d/FileAPI diff --git a/test/fixtures/wpt/dom/events/scrolling/overscroll-event-fired-to-window.html b/test/fixtures/wpt/dom/events/scrolling/overscroll-event-fired-to-window.html index 348dadcb4c50b7..ef5ae3daef8158 100644 --- a/test/fixtures/wpt/dom/events/scrolling/overscroll-event-fired-to-window.html +++ b/test/fixtures/wpt/dom/events/scrolling/overscroll-event-fired-to-window.html @@ -31,7 +31,7 @@ function onOverscroll(event) { assert_false(event.cancelable); - // overscroll events targeting document are bubbled to the window. + // overscroll events targetting document are bubbled to the window. assert_true(event.bubbles); window_received_overscroll = true; } diff --git a/test/fixtures/wpt/dom/events/scrolling/scroll_support.js b/test/fixtures/wpt/dom/events/scrolling/scroll_support.js index 3d7709772baafb..1cde3a1f6b446f 100644 --- a/test/fixtures/wpt/dom/events/scrolling/scroll_support.js +++ b/test/fixtures/wpt/dom/events/scrolling/scroll_support.js @@ -20,6 +20,41 @@ async function waitForScrollendEventNoTimeout(target) { }); } +// Waits until a rAF callback with no "scroll" event in the last 200ms. +function waitForDelayWithoutScrollEvent(eventTarget) { + const TIMEOUT_IN_MS = 200; + + return new Promise(resolve => { + let lastScrollEventTime = performance.now(); + + const scrollListener = () => { + lastScrollEventTime = performance.now(); + }; + eventTarget.addEventListener('scroll', scrollListener); + + const tick = () => { + if (performance.now() - lastScrollEventTime > TIMEOUT_IN_MS) { + eventTarget.removeEventListener('scroll', scrollListener); + resolve(); + return; + } + requestAnimationFrame(tick); // wait another frame + } + requestAnimationFrame(tick); + }); +} + +// Waits for the end of scrolling. Uses the "scrollend" event if available. +// Otherwise, fall backs to waitForDelayWithoutScrollEvent(). +function waitForScrollEndFallbackToDelayWithoutScrollEvent(eventTarget) { + if (window.onscrollend !== undefined) { + return waitForScrollendEventNoTimeout(eventTarget); + } + return waitForScrollEvent(eventTarget).then(() => { + return waitForDelayWithoutScrollEvent(eventTarget); + }); +} + async function waitForPointercancelEvent(test, target, timeoutMs = 500) { return waitForEvent("pointercancel", test, target, timeoutMs); } @@ -88,7 +123,7 @@ const MAX_UNCHANGED_FRAMES = 20; function waitFor(condition, error_message = 'Reaches the maximum frames.') { return new Promise((resolve, reject) => { function tick(frames) { - // We requestAnimationFrame either for MAX_FRAME frames or until condition + // We requestAnimationFrame either for MAX_FRAM frames or until condition // is met. if (frames >= MAX_FRAME) reject(error_message); diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index a93ad1762feb80..258546e619320e 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -16,7 +16,7 @@ "path": "dom/abort" }, "dom/events": { - "commit": "0a811c51619b14f78fec60ba7dd1603795ca6a21", + "commit": "922a7fe9a4f5bffd0161e11b38bac8f76ef03efd", "path": "dom/events" }, "encoding": {