mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Update web-platform-tests to revision b'797e75946c24d0625f04247b16d33c26d4ada273'
This commit is contained in:
parent
4339b3bab4
commit
44e249bebb
414 changed files with 12588 additions and 11565 deletions
|
@ -0,0 +1,66 @@
|
|||
function imageLoadedPromise(image) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (image.complete)
|
||||
resolve();
|
||||
image.addEventListener("load", resolve, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
function videoLoadedPromise(video) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (video.readyState == 4)
|
||||
resolve();
|
||||
else {
|
||||
video.addEventListener("loadeddata", resolve, { once: true });
|
||||
video.addEventListener("error", reject, { once: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function waitForNFrames(count) {
|
||||
if (count <= 0)
|
||||
return Promise.reject(new TypeError("count should be greater than 0!"));
|
||||
|
||||
return new Promise(resolve => {
|
||||
function tick() {
|
||||
(--count) ? requestAnimationFrame(tick) : resolve();
|
||||
}
|
||||
requestAnimationFrame(tick);
|
||||
});
|
||||
}
|
||||
|
||||
function seekTo(video, time) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
video.addEventListener("seeked", async function() {
|
||||
/* Work around flakiness in video players... */
|
||||
await waitForNFrames(3);
|
||||
resolve();
|
||||
}, { once: true });
|
||||
video.currentTime = time;
|
||||
});
|
||||
}
|
||||
|
||||
function checkBoundingBox(actual, expected, fuzziness) {
|
||||
assert_equals(actual.constructor.name, "DOMRectReadOnly");
|
||||
assert_approx_equals(actual.left, expected.left, fuzziness);
|
||||
assert_approx_equals(actual.right, expected.right, fuzziness);
|
||||
assert_approx_equals(actual.top, expected.top, fuzziness);
|
||||
assert_approx_equals(actual.bottom, expected.bottom, fuzziness);
|
||||
}
|
||||
|
||||
function checkPointsLieWithinBoundingBox(points, boundingBox) {
|
||||
for (point of points) {
|
||||
assert_between_inclusive(point.x, boundingBox.left, boundingBox.right);
|
||||
assert_between_inclusive(point.y, boundingBox.top, boundingBox.bottom);
|
||||
}
|
||||
}
|
||||
|
||||
function checkPointIsNear(actual, expected, fuzzinessX, fuzzinessY) {
|
||||
assert_approx_equals(actual.x, expected.x, fuzzinessX);
|
||||
assert_approx_equals(actual.y, expected.y, fuzzinessY);
|
||||
}
|
||||
|
||||
function checkPointsAreNear(actual, expected, fuzzinessX, fuzzinessY) {
|
||||
for (point of actual)
|
||||
checkPointIsNear(point, expected, fuzzinessX, fuzzinessY);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue