blob: 956286837f1d1157b2c1756f39cac79bcf75e353 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("This tests the constructor for the WebKitAnimationEvent DOM class.");
// No initializer is passed.
shouldBe("new WebKitAnimationEvent('eventType').bubbles", "false");
shouldBe("new WebKitAnimationEvent('eventType').cancelable", "false");
shouldBeEqualToString("new WebKitAnimationEvent('eventType').animationName", "");
shouldBe("new WebKitAnimationEvent('eventType').elapsedTime", "0");
// bubbles is passed.
shouldBe("new WebKitAnimationEvent('eventType', { bubbles: false }).bubbles", "false");
shouldBe("new WebKitAnimationEvent('eventType', { bubbles: true }).bubbles", "true");
// cancelable is passed.
shouldBe("new WebKitAnimationEvent('eventType', { cancelable: false }).cancelable", "false");
shouldBe("new WebKitAnimationEvent('eventType', { cancelable: true }).cancelable", "true");
// animationName is passed.
// Strings.
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: 'doremi' }).animationName", "doremi");
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: '' }).animationName", "");
// Non-strings.
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: undefined }).animationName", "");
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: null }).animationName", "null");
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: false }).animationName", "false");
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: true }).animationName", "true");
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: 12345 }).animationName", "12345");
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: 18446744073709551615 }).animationName", "18446744073709552000");
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: NaN }).animationName", "NaN");
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: [] }).animationName", "");
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: [1, 2, 3] }).animationName", "1,2,3");
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: {doremi: 12345} }).animationName", "[object Object]");
shouldBeEqualToString("new WebKitAnimationEvent('eventType', { animationName: {valueOf: function () { return 'doremi'; } } }).animationName", "[object Object]");
// elapsedTime is passed.
// Numeric values.
shouldBe("new WebKitAnimationEvent('eventType', { elapsedTime: 0 }).elapsedTime", "0");
shouldBe("new WebKitAnimationEvent('eventType', { elapsedTime: 123.45 }).elapsedTime", "123.45");
shouldBe("new WebKitAnimationEvent('eventType', { elapsedTime: -123.45 }).elapsedTime", "-123.45");
shouldBe("new WebKitAnimationEvent('eventType', { elapsedTime: 18446744073709551615 }).elapsedTime", "18446744073709551615");
shouldThrowErrorName("new WebKitAnimationEvent('eventType', { elapsedTime: NaN }).elapsedTime", "TypeError");
shouldThrowErrorName("new WebKitAnimationEvent('eventType', { elapsedTime: Infinity }).elapsedTime", "TypeError");
shouldThrowErrorName("new WebKitAnimationEvent('eventType', { elapsedTime: -Infinity }).elapsedTime", "TypeError");
// Non-numeric values.
shouldBe("new WebKitAnimationEvent('eventType', { elapsedTime: undefined }).elapsedTime", "0");
shouldBe("new WebKitAnimationEvent('eventType', { elapsedTime: null }).elapsedTime", "0");
shouldBe("new WebKitAnimationEvent('eventType', { elapsedTime: false }).elapsedTime", "0");
shouldBe("new WebKitAnimationEvent('eventType', { elapsedTime: true }).elapsedTime", "1");
shouldBe("new WebKitAnimationEvent('eventType', { elapsedTime: '' }).elapsedTime", "0");
shouldThrowErrorName("new WebKitAnimationEvent('eventType', { elapsedTime: 'doremi' }).elapsedTime", "TypeError");
shouldBe("new WebKitAnimationEvent('eventType', { elapsedTime: [] }).elapsedTime", "0");
shouldBe("new WebKitAnimationEvent('eventType', { elapsedTime: [123.45] }).elapsedTime", "123.45");
shouldThrowErrorName("new WebKitAnimationEvent('eventType', { elapsedTime: [123.45, 678.90] }).elapsedTime", "TypeError");
shouldThrowErrorName("new WebKitAnimationEvent('eventType', { elapsedTime: {doremi: 123.45} }).elapsedTime", "TypeError");
shouldBe("new WebKitAnimationEvent('eventType', { elapsedTime: {valueOf: function () { return 123.45 } } }).elapsedTime", "123.45");
// All initializers are passed.
shouldBe("new WebKitAnimationEvent('eventType', { bubbles: true, cancelable: true, animationName: 'doremi', elapsedTime: 123.45 }).bubbles", "true");
shouldBe("new WebKitAnimationEvent('eventType', { bubbles: true, cancelable: true, animationName: 'doremi', elapsedTime: 123.45 }).cancelable", "true");
shouldBe("new WebKitAnimationEvent('eventType', { bubbles: true, cancelable: true, animationName: 'doremi', elapsedTime: 123.45 }).animationName", "'doremi'");
shouldBe("new WebKitAnimationEvent('eventType', { bubbles: true, cancelable: true, animationName: 'doremi', elapsedTime: 123.45 }).elapsedTime", "123.45");
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>