4 <script src=
"../../../resources/js-test.js"></script>
9 description("This tests the constructor for the ErrorEvent DOM class.");
11 // No initializer is passed.
12 shouldBe("new ErrorEvent('eventType').bubbles", "false");
13 shouldBe("new ErrorEvent('eventType').cancelable", "false");
14 shouldBeEqualToString("new ErrorEvent('eventType').message", "");
15 shouldBeEqualToString("new ErrorEvent('eventType').filename", "");
16 shouldBe("new ErrorEvent('eventType').lineno", "0");
19 shouldBe("new ErrorEvent('eventType', { bubbles: false }).bubbles", "false");
20 shouldBe("new ErrorEvent('eventType', { bubbles: true }).bubbles", "true");
22 // cancelable is passed.
23 shouldBe("new ErrorEvent('eventType', { cancelable: false }).cancelable", "false");
24 shouldBe("new ErrorEvent('eventType', { cancelable: true }).cancelable", "true");
26 // message or filename is passed.
27 ["message", "filename"].forEach(function (attr
) {
29 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": 'melancholy' })." + attr
, "melancholy");
30 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": '' })." + attr
, "");
33 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": undefined })." + attr
, "");
34 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": null })." + attr
, "null");
35 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": false })." + attr
, "false");
36 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": true })." + attr
, "true");
37 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": 12345 })." + attr
, "12345");
38 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": 18446744073709551615 })." + attr
, "18446744073709552000");
39 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": NaN })." + attr
, "NaN");
40 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": [] })." + attr
, "");
41 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": [1, 2, 3] })." + attr
, "1,2,3");
42 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": {melancholy: 12345} })." + attr
, "[object Object]");
43 shouldBeEqualToString("new ErrorEvent('eventType', { " + attr
+ ": {valueOf: function () { return 'melancholy'; } } })." + attr
, "[object Object]");
47 // numbers within the unsigned long range.
48 shouldBe("new ErrorEvent('eventType', { lineno: 0 }).lineno", "0");
49 shouldBe("new ErrorEvent('eventType', { lineno: 1 }).lineno", "1");
50 shouldBe("new ErrorEvent('eventType', { lineno: 4294967294 }).lineno", "4294967294");
51 shouldBe("new ErrorEvent('eventType', { lineno: 4294967295 }).lineno", "4294967295");
53 // numbers out of the unsigned long range.
54 // 2^{53}-1, the largest number that can be exactly represented by double.
55 shouldBe("new ErrorEvent('eventType', { lineno: 9007199254740991 }).lineno", "4294967295");
57 shouldBe("new ErrorEvent('eventType', { lineno: 18446744073709551615 }).lineno", "0");
58 shouldBe("new ErrorEvent('eventType', { lineno: 12345678901234567890 }).lineno", "3944679424");
59 shouldBe("new ErrorEvent('eventType', { lineno: -1 }).lineno", "4294967295");
60 shouldBe("new ErrorEvent('eventType', { lineno: 123.45 }).lineno", "123");
61 shouldBe("new ErrorEvent('eventType', { lineno: NaN }).lineno", "0");
63 // Non-numeric values.
64 shouldBe("new ErrorEvent('eventType', { lineno: undefined }).lineno", "0");
65 shouldBe("new ErrorEvent('eventType', { lineno: null }).lineno", "0");
66 shouldBe("new ErrorEvent('eventType', { lineno: '' }).lineno", "0");
67 shouldBe("new ErrorEvent('eventType', { lineno: '12345' }).lineno", "12345");
68 shouldBe("new ErrorEvent('eventType', { lineno: '12345a' }).lineno", "0");
69 shouldBe("new ErrorEvent('eventType', { lineno: 'abc' }).lineno", "0");
70 shouldBe("new ErrorEvent('eventType', { lineno: [] }).lineno", "0");
71 shouldBe("new ErrorEvent('eventType', { lineno: [12345] }).lineno", "12345");
72 shouldBe("new ErrorEvent('eventType', { lineno: [12345, 67890] }).lineno", "0");
73 shouldBe("new ErrorEvent('eventType', { lineno: {} }).lineno", "0");
74 shouldBe("new ErrorEvent('eventType', { lineno: {moemoe: 12345} }).lineno", "0");
75 shouldBe("new ErrorEvent('eventType', { lineno: {valueOf: function () { return 12345; }} }).lineno", "12345");
78 // numbers within the unsigned long range.
79 shouldBe("new ErrorEvent('eventType', { colno: 0 }).colno", "0");
80 shouldBe("new ErrorEvent('eventType', { colno: 1 }).colno", "1");
81 shouldBe("new ErrorEvent('eventType', { colno: 4294967294 }).colno", "4294967294");
82 shouldBe("new ErrorEvent('eventType', { colno: 4294967295 }).colno", "4294967295");
84 // numbers out of the unsigned long range.
85 // 2^{53}-1, the largest number that can be exactly represented by double.
86 shouldBe("new ErrorEvent('eventType', { colno: 9007199254740991 }).colno", "4294967295");
88 shouldBe("new ErrorEvent('eventType', { colno: 18446744073709551615 }).colno", "0");
89 shouldBe("new ErrorEvent('eventType', { colno: 12345678901234567890 }).colno", "3944679424");
90 shouldBe("new ErrorEvent('eventType', { colno: -1 }).colno", "4294967295");
91 shouldBe("new ErrorEvent('eventType', { colno: 123.45 }).colno", "123");
92 shouldBe("new ErrorEvent('eventType', { colno: NaN }).colno", "0");
94 // Non-numeric values.
95 shouldBe("new ErrorEvent('eventType', { colno: undefined }).colno", "0");
96 shouldBe("new ErrorEvent('eventType', { colno: null }).colno", "0");
97 shouldBe("new ErrorEvent('eventType', { colno: '' }).colno", "0");
98 shouldBe("new ErrorEvent('eventType', { colno: '12345' }).colno", "12345");
99 shouldBe("new ErrorEvent('eventType', { colno: '12345a' }).colno", "0");
100 shouldBe("new ErrorEvent('eventType', { colno: 'abc' }).colno", "0");
101 shouldBe("new ErrorEvent('eventType', { colno: [] }).colno", "0");
102 shouldBe("new ErrorEvent('eventType', { colno: [12345] }).colno", "12345");
103 shouldBe("new ErrorEvent('eventType', { colno: [12345, 67890] }).colno", "0");
104 shouldBe("new ErrorEvent('eventType', { colno: {} }).colno", "0");
105 shouldBe("new ErrorEvent('eventType', { colno: {moemoe: 12345} }).colno", "0");
106 shouldBe("new ErrorEvent('eventType', { colno: {valueOf: function () { return 12345; }} }).colno", "12345");
109 shouldBe("new ErrorEvent('eventType', { error: { moemoe: 12345 } }).error.moemoe", "12345");
110 shouldBeEqualToString("new ErrorEvent('eventType', { error: { message: 'Message' } }).error.message", "Message");
112 // All initializers are passed.
113 shouldBe("new ErrorEvent('eventType', { bubbles: true, cancelable: true, message: 'sakuranbo', filename: 'amaenbo', lineno: 12345, colno: 23456, error: { message: 'hi' } }).bubbles", "true");
114 shouldBe("new ErrorEvent('eventType', { bubbles: true, cancelable: true, message: 'sakuranbo', filename: 'amaenbo', lineno: 12345, colno: 23456, error: { message: 'hi' } }).cancelable", "true");
115 shouldBeEqualToString("new ErrorEvent('eventType', { bubbles: true, cancelable: true, message: 'sakuranbo', filename: 'amaenbo', lineno: 12345, colno: 23456, error: { message: 'hi' } }).message", "sakuranbo");
116 shouldBeEqualToString("new ErrorEvent('eventType', { bubbles: true, cancelable: true, message: 'sakuranbo', filename: 'amaenbo', lineno: 12345, colno: 23456, error: { message: 'hi' } }).filename", "amaenbo");
117 shouldBe("new ErrorEvent('eventType', { bubbles: true, cancelable: true, message: 'sakuranbo', filename: 'amaenbo', lineno: 12345, colno: 23456, error: { message: 'hi' } }).lineno", "12345");
118 shouldBe("new ErrorEvent('eventType', { bubbles: true, cancelable: true, message: 'sakuranbo', filename: 'amaenbo', lineno: 12345, colno: 23456, error: { message: 'hi' } }).colno", "23456");
119 shouldBeEqualToString("new ErrorEvent('eventType', { bubbles: true, cancelable: true, message: 'sakuranbo', filename: 'amaenbo', lineno: 12345, colno: 23456, error: { message: 'hi' } }).error.message", "hi");