mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-10 21:28:04 +02:00
Automatic update from web-platform-tests
[ScrollTimeline] Upstream based currentTime tests to WPT
This CL starts to upstream the currentTime tests to WPT. To split this
up, we start with just the 'basic' tests - basic functionality,
adjusting for time range, and start/end scroll offsets. The writing mode
and NaN tests will follow in later patches.
There are a few mostly non-behavioral changes to the tests in this CL:
* Some comments were edited for clarity.
* For tests with more than one assert_equals(), descriptions were
added to the asserts. This is to help locate failing assert_equal
lines, as jsharness does not print out the line number of a failure.
* In a few places we had more than one assert_equals for the same
scenario (e.g. multiple cases where scroll was after the
startScrollOffset point). These have been deduplicated.
Bug: 911254
Change-Id: I783fcf7f43cda876defa9c36db9a0e7dff4e82c7
Reviewed-on: https://chromium-review.googlesource.com/c/1366297
Reviewed-by: Yi Gu <yigu@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#614510}
--
wpt-commits: 008bfc93426ab6973a843cc201f347b90ae3028f
wpt-pr: 14403
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
// Builds a generic structure that looks like:
|
|
//
|
|
// <div class="scroller"> // 100x100 viewport
|
|
// <div class="contents"></div> // 500x500
|
|
// </div>
|
|
//
|
|
// The |scrollerOverrides| and |contentOverrides| parameters are maps which
|
|
// are applied to the scroller and contents style after basic setup.
|
|
//
|
|
// Appends the outer 'scroller' element to the document body, and returns it.
|
|
function setupScrollTimelineTest(
|
|
scrollerOverrides = new Map(), contentOverrides = new Map()) {
|
|
let scroller = document.createElement('div');
|
|
scroller.style.width = '100px';
|
|
scroller.style.height = '100px';
|
|
scroller.style.overflow = 'scroll';
|
|
for (const [key, value] of scrollerOverrides) {
|
|
scroller.style[key] = value;
|
|
}
|
|
|
|
let contents = document.createElement('div');
|
|
contents.style.width = '500px';
|
|
contents.style.height = '500px';
|
|
for (const [key, value] of contentOverrides) {
|
|
contents.style[key] = value;
|
|
}
|
|
|
|
scroller.appendChild(contents);
|
|
document.body.appendChild(scroller);
|
|
return scroller;
|
|
}
|
|
|
|
// Helper method to calculate the current time, implementing only step 5 of
|
|
// https://wicg.github.io/scroll-animations/#current-time-algorithm
|
|
function calculateCurrentTime(
|
|
currentScrollOffset, startScrollOffset, endScrollOffset,
|
|
effectiveTimeRange) {
|
|
return ((currentScrollOffset - startScrollOffset) /
|
|
(endScrollOffset - startScrollOffset)) *
|
|
effectiveTimeRange;
|
|
}
|
|
|