diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/server/tests/xpcshell/test_animation_type.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/server/tests/xpcshell/test_animation_type.js')
-rw-r--r-- | devtools/server/tests/xpcshell/test_animation_type.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/devtools/server/tests/xpcshell/test_animation_type.js b/devtools/server/tests/xpcshell/test_animation_type.js new file mode 100644 index 0000000000..261b5ef2ac --- /dev/null +++ b/devtools/server/tests/xpcshell/test_animation_type.js @@ -0,0 +1,72 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +// Test the output of AnimationPlayerActor.getType(). + +const { + ANIMATION_TYPES, + AnimationPlayerActor, +} = require("resource://devtools/server/actors/animation.js"); + +function run_test() { + // Mock a window with just the properties the AnimationPlayerActor uses. + const window = {}; + window.MutationObserver = class { + constructor() { + this.observe = () => {}; + } + }; + window.Animation = class { + constructor() { + this.effect = { target: getMockNode() }; + } + }; + + window.CSSAnimation = class extends window.Animation {}; + window.CSSTransition = class extends window.Animation {}; + + // Helper to get a mock DOM node. + function getMockNode() { + return { + ownerDocument: { + defaultView: window, + }, + }; + } + + // Objects in this array should contain the following properties: + // - desc {String} For logging + // - animation {Object} An animation object instantiated from one of the mock + // window animation constructors. + // - expectedType {String} The expected type returned by + // AnimationPlayerActor.getType. + const TEST_DATA = [ + { + desc: "Test CSSAnimation type", + animation: new window.CSSAnimation(), + expectedType: ANIMATION_TYPES.CSS_ANIMATION, + }, + { + desc: "Test CSSTransition type", + animation: new window.CSSTransition(), + expectedType: ANIMATION_TYPES.CSS_TRANSITION, + }, + { + desc: "Test ScriptAnimation type", + animation: new window.Animation(), + expectedType: ANIMATION_TYPES.SCRIPT_ANIMATION, + }, + { + desc: "Test unknown type", + animation: { effect: { target: getMockNode() } }, + expectedType: ANIMATION_TYPES.UNKNOWN, + }, + ]; + + for (const { desc, animation, expectedType } of TEST_DATA) { + info(desc); + const actor = new AnimationPlayerActor({}, animation); + Assert.equal(actor.getType(), expectedType); + } +} |