Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / constructors / ui-event-constructor.html
blob03f8b5b2e27c368c6d171d881b180cc3034374b5
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <script>
9 description("This tests the constructor for the UIEvent DOM class.");
11 var testObject = {nyannyan: 123};
13 // No initializer is passed.
14 shouldBe("new UIEvent('eventType').bubbles", "false");
15 shouldBe("new UIEvent('eventType').cancelable", "false");
16 shouldBe("new UIEvent('eventType').view", "null");
17 shouldBe("new UIEvent('eventType').detail", "0");
19 // bubbles is passed.
20 shouldBe("new UIEvent('eventType', { bubbles: false }).bubbles", "false");
21 shouldBe("new UIEvent('eventType', { bubbles: true }).bubbles", "true");
23 // cancelable is passed.
24 shouldBe("new UIEvent('eventType', { cancelable: false }).cancelable", "false");
25 shouldBe("new UIEvent('eventType', { cancelable: true }).cancelable", "true");
27 // view is passed.
28 // Window objects.
29 shouldBe("new UIEvent('eventType', { view: window }).view", "window");
30 shouldBe("new UIEvent('eventType', { view: this }).view", "this");
32 // Non-window objects.
33 shouldThrow("new UIEvent('eventType', { view: testObject }).view");
34 shouldThrow("new UIEvent('eventType', { view: document }).view");
35 shouldBe("new UIEvent('eventType', { view: undefined }).view", "null");
36 shouldBe("new UIEvent('eventType', { view: null }).view", "null");
37 shouldThrow("new UIEvent('eventType', { view: false }).view");
38 shouldThrow("new UIEvent('eventType', { view: true }).view");
39 shouldThrow("new UIEvent('eventType', { view: '' }).view");
40 shouldThrow("new UIEvent('eventType', { view: 'chocolate' }).view");
41 shouldThrow("new UIEvent('eventType', { view: 12345 }).view");
42 shouldThrow("new UIEvent('eventType', { view: 18446744073709551615 }).view");
43 shouldThrow("new UIEvent('eventType', { view: NaN }).view");
44 // Note that valueOf() is not called, when the left hand side is evaluated.
45 shouldThrow("new UIEvent('eventType', { view: {valueOf: function () { return window; } } }).view == window");
46 shouldBe("new UIEvent('eventType', { get view() { return window; } }).view", "window");
47 shouldThrow("new UIEvent('eventType', { get view() { return 123; } }).view");
48 shouldThrow("new UIEvent('eventType', { get view() { throw 'UIEvent Error'; } })");
50 // detail is passed.
51 // numbers within the long range.
52 shouldBe("new UIEvent('eventType', { detail: 0 }).detail", "0");
53 shouldBe("new UIEvent('eventType', { detail: 2147483647 }).detail", "2147483647");
54 shouldBe("new UIEvent('eventType', { detail: -1 }).detail", "-1");
55 shouldBe("new UIEvent('eventType', { detail: -2147483648 }).detail", "-2147483648");
57 // numbers out of the long range.
58 shouldBe("new UIEvent('eventType', { detail: 4294967295 }).detail", "-1");
59 // 2^{53}-1, the largest number that can be exactly represented by double.
60 shouldBe("new UIEvent('eventType', { detail: 9007199254740991 }).detail", "-1");
61 // 2^{64}-1
62 shouldBe("new UIEvent('eventType', { detail: 18446744073709551615 }).detail", "0");
63 shouldBe("new UIEvent('eventType', { detail: 123.45 }).detail", "123");
64 shouldBe("new UIEvent('eventType', { detail: NaN }).detail", "0");
66 // Non-numeric values.
67 shouldBe("new UIEvent('eventType', { detail: undefined }).detail", "0");
68 shouldBe("new UIEvent('eventType', { detail: null }).detail", "0");
69 shouldBe("new UIEvent('eventType', { detail: '' }).detail", "0");
70 shouldBe("new UIEvent('eventType', { detail: '12345' }).detail", "12345");
71 shouldBe("new UIEvent('eventType', { detail: '12345a' }).detail", "0");
72 shouldBe("new UIEvent('eventType', { detail: 'abc' }).detail", "0");
73 shouldBe("new UIEvent('eventType', { detail: [] }).detail", "0");
74 shouldBe("new UIEvent('eventType', { detail: [12345] }).detail", "12345");
75 shouldBe("new UIEvent('eventType', { detail: [12345, 67890] }).detail", "0");
76 shouldBe("new UIEvent('eventType', { detail: {} }).detail", "0");
77 shouldBe("new UIEvent('eventType', { detail: {moemoe: 12345} }).detail", "0");
78 shouldBe("new UIEvent('eventType', { detail: {valueOf: function () { return 12345; }} }).detail", "12345");
80 // All initializers are passed.
81 shouldBe("new UIEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 123 }).bubbles", "true");
82 shouldBe("new UIEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 123 }).cancelable", "true");
83 shouldBe("new UIEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 123 }).view", "window");
84 shouldBe("new UIEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 123 }).detail", "123");
85 </script>
86 </body>
87 </html>