Files
palemoon27/dom/animation/test/testcommon.js
T
roytam1 30f7e10db1 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 937810 - disable application reputation check on b2g r=mmc,mossop (403f8e0353)
- Bug 1216537 - Check and request storage permission if file download is started. r=nalexander,paolo (9233e7193d)
- Bug 1163937 - Added forceSave function to DownloadIntegration and ensured that downloads removed in Sanitizer do not persist. r=margaret (9610017b5d)
- Bug 989960 - Unhandled rejections in DOM Promises should cause xpcshell tests to fail. r=Yoric (be260d55d2)
- Bug 1177237 - Implement OS query parsing and user search choice. r=jaws (86c807e606)
- Bug 1177443 - Add 'system' purpose for searches coming from outside Firefox, r=MattN. (f6ac86ec2a)
- Bug 1072037, part 2 - Tests for the effect of setting CSS animation's AnimationPlayer.currentTime. r=birtles (79639d2ea4)
- bits of Bug 1145246, part 2 (849519f25d)
- bits of Bug 1145246, part 7 (3ec5500e08)
- bits of Bug 1109390 part 5 (6d849b9b3c)
- Bug 1074630, part 2 - CSS animations tests for Web Animations finishing behavior. r=birtles (bd0aa575bd)
- Bug 1073379, part 6 - Tests for the effect of setting CSS animation's AnimationPlayer.startTime. r=dholbert (9d8aad8d28)
- Bug 1073379, part 6b - Re-enable the player.playState check in checkStateAtActiveIntervalEndTime, but disable the first checkStateAtActiveIntervalEndTime call in the 'Skipping backwards through animation' tests. r=orange (3a9ea58cef)
- Bug 1141710, part 1 - Update to the new version of addDiv() in testcommon.js. r=dholbert (262b9dc018)
- Bug 1141710, part 2 - Update comments to be non-Mozilla specific. r=dholbert (177e8818f8)
- Bug 1141710, part 3 - Stop using ECMAScript 6 features in test_animation-player-starttime.html, since other browsers don't support them. r=dholbert (6f0c6ab687)
- Bug 1141710, part 4 - Avoid race condition when taking timestamps by reusing the original timestamp. r=dholbert (bc6ff2f3b1)
- Bug 1141710, part 5 - Change from assert_true() to the new assert_unreached(). r=dholbert (0c1608c4c4)
- Bug 1141710, part 7 - Create helpers to get the startTime corresponding to various points through the active duration. r=dholbert (568cf9a054)
- Bug 1141710, part 7 - Store the generated 'animation' property string in a global constant and reuse that constant. r=dholbert (ce85c0d7a9)
- Bug 1141710, part 8 - Create helpers to get the startTime corresponding to various points through the active duration. r=dholbert (6d6b1625ff)
- Bug 1141710, part 9 - Get the timeline from the player instead of from the document. r=dholbert (9660c00f1d)
- Bug 1141710, part 10 - Update some assertion text and comments. r=birtles (d238a482b5)
- Bug 1141710, part 11 - Assert that seeking over the before and active phases worked. r=birtles (4aedf388f9)
- Bug 1141710, part 12 - Check that the hold time is updated when the startTime is set to null. r=birtles (0473baeabd)
- Bug 1141710, part 13 - Wrap all lines at the 80 column mark. r=birtles (7d3ed6b453)
- Bug 1141710, part 14 - Get rid of the checks at 90% through the active duration. r=birtles (0f3c4cb7ca)
- part of Bug 1145246, part 2 - (ec09bf3fdd)
- half of Bug 1109390 part 1 - Add tests for getting the startTime; r=jwatt (a682851ba6)
- Bug 1149832 - Replace the Web Animations test helper waitForTwoAnimationFrames() with a helper that takes a frame count. r=birtles (da312eae7d)
- Bug 1235286 - Part 1: Add an argument to waitForAnimationFrames to run a task in each requestAnimationFrame callback. r=birtles (199a789546)
- Bug 1235286 - Part 2: Tests for animation optimizations. r=birtles (e510c68a7c)
- Bug 1235286 - Part 3: Comment out some compositor animations tests. r=birtles (61791d5b69)
- Bug 1235345 - Remove services/metrics. r=gfritzsche (29ac4a5895)
- Bug 1204846 - Modify the NetworkStatsDB to allow getSamples returns expired data at first sample and modify the test case. r=ethan (3e9d1f9a77)
- Bug 1237227 - Check the return of context->GetDisplayRootPresContext() for validity. r=roc (2ad8dcf545)
- sync parts of AppConstants.jsm for isPlatformAndVersion* functions
2023-10-11 11:06:39 +08:00

106 lines
3.2 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Appends a div to the document body.
*
* @param t The testharness.js Test object. If provided, this will be used
* to register a cleanup callback to remove the div when the test
* finishes.
*/
function addDiv(t) {
var div = document.createElement('div');
document.body.appendChild(div);
if (t && typeof t.add_cleanup === 'function') {
t.add_cleanup(function() { div.remove(); });
}
return div;
}
/**
* Some tests cause animations to continue to exist even after their target
* element has been removed from the document tree. To ensure that these
* animations do not impact other tests we should cancel them when the test
* is complete.
*/
function cancelAllAnimationsOnEnd(t) {
t.add_cleanup(function() {
document.timeline.getAnimations().forEach(animation => animation.cancel());
});
}
/**
* Promise wrapper for requestAnimationFrame.
*/
function waitForFrame() {
return new Promise(function(resolve, reject) {
window.requestAnimationFrame(resolve);
});
}
/**
* Returns a Promise that is resolved after the given number of consecutive
* animation frames have occured (using requestAnimationFrame callbacks).
*
* @param frameCount The number of animation frames.
* @param onFrame An optional function to be processed in each animation frame.
*/
function waitForAnimationFrames(frameCount, onFrame) {
return new Promise(function(resolve, reject) {
function handleFrame() {
if (--frameCount <= 0) {
resolve();
} else {
if (onFrame && typeof onFrame === 'function') {
onFrame();
}
window.requestAnimationFrame(handleFrame); // wait another frame
}
}
window.requestAnimationFrame(handleFrame);
});
}
/**
* Wrapper that takes a sequence of N animations and returns:
*
* Promise.all([animations[0].ready, animations[1].ready, ... animations[N-1].ready]);
*/
function waitForAllAnimations(animations) {
return Promise.all(animations.map(function(animation) {
return animation.ready;
}));
}
/**
* Flush the computed style for the given element. This is useful, for example,
* when we are testing a transition and need the initial value of a property
* to be computed so that when we synchronouslyet set it to a different value
* we actually get a transition instead of that being the initial value.
*/
function flushComputedStyle(elem) {
var cs = window.getComputedStyle(elem);
cs.marginLeft;
}
if (opener) {
for (var funcName of ["async_test", "assert_not_equals", "assert_equals",
"assert_approx_equals", "assert_less_than",
"assert_less_than_equal", "assert_greater_than",
"assert_between_inclusive",
"assert_true", "assert_false",
"assert_class_string", "assert_throws",
"assert_unreached", "promise_test", "test"]) {
window[funcName] = opener[funcName].bind(opener);
}
window.EventWatcher = opener.EventWatcher;
function done() {
opener.add_completion_callback(function() {
self.close();
});
opener.done();
}
}