8aafcdd364018496b9641bb6c1f0f95130b70da4
[WebKit-https.git] / LayoutTests / fast / events / constructors / transition-event-constructor.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <script>
8
9 description("This tests the constructor for the TransitionEvent DOM class.");
10
11 // No initializer is passed.
12 shouldBe("new TransitionEvent('eventType').bubbles", "false");
13 shouldBe("new TransitionEvent('eventType').cancelable", "false");
14 shouldBeEqualToString("new TransitionEvent('eventType').propertyName", "");
15 shouldBe("new TransitionEvent('eventType').elapsedTime", "0");
16 shouldBeEqualToString("new TransitionEvent('eventType').pseudoElement", "");
17
18 // bubbles is passed.
19 shouldBe("new TransitionEvent('eventType', { bubbles: false }).bubbles", "false");
20 shouldBe("new TransitionEvent('eventType', { bubbles: true }).bubbles", "true");
21
22 // cancelable is passed.
23 shouldBe("new TransitionEvent('eventType', { cancelable: false }).cancelable", "false");
24 shouldBe("new TransitionEvent('eventType', { cancelable: true }).cancelable", "true");
25
26 // propertyName is passed.
27 // Strings.
28 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: 'doremi' }).propertyName", "doremi");
29 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: '' }).propertyName", "");
30
31 // Non-strings.
32 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: undefined }).propertyName", "undefined");
33 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: null }).propertyName", "null");
34 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: false }).propertyName", "false");
35 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: true }).propertyName", "true");
36 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: 12345 }).propertyName", "12345");
37 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: 18446744073709551615 }).propertyName", "18446744073709552000");
38 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: NaN }).propertyName", "NaN");
39 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: [] }).propertyName", "");
40 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: [1, 2, 3] }).propertyName", "1,2,3");
41 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: {doremi: 12345} }).propertyName", "[object Object]");
42 shouldBeEqualToString("new TransitionEvent('eventType', { propertyName: {valueOf: function () { return 'doremi'; } } }).propertyName", "[object Object]");
43
44 // elapsedTime is passed.
45 // Numeric values.
46 shouldBe("new TransitionEvent('eventType', { elapsedTime: 0 }).elapsedTime", "0");
47 shouldBe("new TransitionEvent('eventType', { elapsedTime: 123.45 }).elapsedTime", "123.45");
48 shouldBe("new TransitionEvent('eventType', { elapsedTime: -123.45 }).elapsedTime", "-123.45");
49 shouldBe("new TransitionEvent('eventType', { elapsedTime: 18446744073709551615 }).elapsedTime", "18446744073709551615");
50 shouldBe("new TransitionEvent('eventType', { elapsedTime: NaN }).elapsedTime", "NaN");
51 shouldBe("new TransitionEvent('eventType', { elapsedTime: Infinity }).elapsedTime", "Infinity");
52 shouldBe("new TransitionEvent('eventType', { elapsedTime: -Infinity }).elapsedTime", "-Infinity");
53
54 // pseudoElement is passed.
55 // Strings.
56 shouldBeEqualToString("new TransitionEvent('eventType', { pseudoElement: '::before' }).pseudoElement", "::before");
57 shouldBeEqualToString("new TransitionEvent('eventType', { pseudoElement: '' }).pseudoElement", "");
58
59 // Non-numeric values.
60 shouldBe("new TransitionEvent('eventType', { elapsedTime: undefined }).elapsedTime", "NaN");
61 shouldBe("new TransitionEvent('eventType', { elapsedTime: null }).elapsedTime", "0");
62 shouldBe("new TransitionEvent('eventType', { elapsedTime: false }).elapsedTime", "0");
63 shouldBe("new TransitionEvent('eventType', { elapsedTime: true }).elapsedTime", "1");
64 shouldBe("new TransitionEvent('eventType', { elapsedTime: '' }).elapsedTime", "0");
65 shouldBe("new TransitionEvent('eventType', { elapsedTime: 'doremi' }).elapsedTime", "NaN");
66 shouldBe("new TransitionEvent('eventType', { elapsedTime: [] }).elapsedTime", "0");
67 shouldBe("new TransitionEvent('eventType', { elapsedTime: [123.45] }).elapsedTime", "123.45");
68 shouldBe("new TransitionEvent('eventType', { elapsedTime: [123.45, 678.90] }).elapsedTime", "NaN");
69 shouldBe("new TransitionEvent('eventType', { elapsedTime: {doremi: 123.45} }).elapsedTime", "NaN");
70 shouldBe("new TransitionEvent('eventType', { elapsedTime: {valueOf: function () { return 123.45 } } }).elapsedTime", "123.45");
71
72 // All initializers are passed.
73 shouldBe("new TransitionEvent('eventType', { bubbles: true, cancelable: true, propertyName: 'doremi', elapsedTime: 123.45, pseudoElement: '::after' }).bubbles", "true");
74 shouldBe("new TransitionEvent('eventType', { bubbles: true, cancelable: true, propertyName: 'doremi', elapsedTime: 123.45, pseudoElement: '::after' }).cancelable", "true");
75 shouldBe("new TransitionEvent('eventType', { bubbles: true, cancelable: true, propertyName: 'doremi', elapsedTime: 123.45, pseudoElement: '::after' }).propertyName", "'doremi'");
76 shouldBe("new TransitionEvent('eventType', { bubbles: true, cancelable: true, propertyName: 'doremi', elapsedTime: 123.45, pseudoElement: '::after' }).elapsedTime", "123.45");
77 shouldBe("new TransitionEvent('eventType', { bubbles: true, cancelable: true, propertyName: 'doremi', elapsedTime: 123.45, pseudoElement: '::after' }).pseudoElement", "'::after'");
78 </script>
79 <script src="../../js/resources/js-test-post.js"></script>
80 </body>
81 </html>