OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <script> | 7 <script> |
8 | 8 |
9 description("This tests the constructor for the MouseEvent DOM class."); | 9 description("This tests the constructor for the MouseEvent DOM class."); |
10 | 10 |
11 var testObject = {nyannyan: 123}; | 11 var testObject = {nyannyan: 123}; |
12 var testDiv = document.createElement("div"); | 12 var testDiv = document.createElement("div"); |
13 var xhr = new XMLHttpRequest; | 13 var xhr = new XMLHttpRequest; |
14 | 14 |
15 // No initializer is passed. | 15 // No initializer is passed. |
16 shouldBe("new MouseEvent('eventType').bubbles", "false"); | 16 shouldBe("new MouseEvent('eventType').bubbles", "false"); |
17 shouldBe("new MouseEvent('eventType').cancelable", "false"); | 17 shouldBe("new MouseEvent('eventType').cancelable", "false"); |
18 shouldBe("new MouseEvent('eventType').view", "null"); | 18 shouldBe("new MouseEvent('eventType').view", "null"); |
19 shouldBe("new MouseEvent('eventType').detail", "0"); | 19 shouldBe("new MouseEvent('eventType').detail", "0"); |
20 shouldBe("new MouseEvent('eventType').screenX", "0"); | 20 shouldBe("new MouseEvent('eventType').screenX", "0"); |
21 shouldBe("new MouseEvent('eventType').screenY", "0"); | 21 shouldBe("new MouseEvent('eventType').screenY", "0"); |
22 shouldBe("new MouseEvent('eventType').clientX", "0"); | 22 shouldBe("new MouseEvent('eventType').clientX", "0"); |
23 shouldBe("new MouseEvent('eventType').clientY", "0"); | 23 shouldBe("new MouseEvent('eventType').clientY", "0"); |
24 shouldBe("new MouseEvent('eventType').ctrlKey", "false"); | 24 shouldBe("new MouseEvent('eventType').ctrlKey", "false"); |
25 shouldBe("new MouseEvent('eventType').shiftKey", "false"); | 25 shouldBe("new MouseEvent('eventType').shiftKey", "false"); |
26 shouldBe("new MouseEvent('eventType').altKey", "false"); | 26 shouldBe("new MouseEvent('eventType').altKey", "false"); |
27 shouldBe("new MouseEvent('eventType').metaKey", "false"); | 27 shouldBe("new MouseEvent('eventType').metaKey", "false"); |
28 shouldBe("new MouseEvent('eventType').button", "0"); | 28 shouldBe("new MouseEvent('eventType').button", "0"); |
| 29 shouldBe("new MouseEvent('eventType').buttons", "0"); |
29 shouldBe("new MouseEvent('eventType').relatedTarget", "null"); | 30 shouldBe("new MouseEvent('eventType').relatedTarget", "null"); |
30 | 31 |
31 // bubbles is passed. | 32 // bubbles is passed. |
32 shouldBe("new MouseEvent('eventType', { bubbles: false }).bubbles", "false"); | 33 shouldBe("new MouseEvent('eventType', { bubbles: false }).bubbles", "false"); |
33 shouldBe("new MouseEvent('eventType', { bubbles: true }).bubbles", "true"); | 34 shouldBe("new MouseEvent('eventType', { bubbles: true }).bubbles", "true"); |
34 | 35 |
35 // cancelable is passed. | 36 // cancelable is passed. |
36 shouldBe("new MouseEvent('eventType', { cancelable: false }).cancelable", "false
"); | 37 shouldBe("new MouseEvent('eventType', { cancelable: false }).cancelable", "false
"); |
37 shouldBe("new MouseEvent('eventType', { cancelable: true }).cancelable", "true")
; | 38 shouldBe("new MouseEvent('eventType', { cancelable: true }).cancelable", "true")
; |
38 | 39 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 shouldBe("new MouseEvent('eventType', { button: '12345' }).button", "12345"); | 127 shouldBe("new MouseEvent('eventType', { button: '12345' }).button", "12345"); |
127 shouldBe("new MouseEvent('eventType', { button: '12345a' }).button", "0"); | 128 shouldBe("new MouseEvent('eventType', { button: '12345a' }).button", "0"); |
128 shouldBe("new MouseEvent('eventType', { button: 'abc' }).button", "0"); | 129 shouldBe("new MouseEvent('eventType', { button: 'abc' }).button", "0"); |
129 shouldBe("new MouseEvent('eventType', { button: [] }).button", "0"); | 130 shouldBe("new MouseEvent('eventType', { button: [] }).button", "0"); |
130 shouldBe("new MouseEvent('eventType', { button: [12345] }).button", "12345"); | 131 shouldBe("new MouseEvent('eventType', { button: [12345] }).button", "12345"); |
131 shouldBe("new MouseEvent('eventType', { button: [12345, 67890] }).button", "0"); | 132 shouldBe("new MouseEvent('eventType', { button: [12345, 67890] }).button", "0"); |
132 shouldBe("new MouseEvent('eventType', { button: {} }).button", "0"); | 133 shouldBe("new MouseEvent('eventType', { button: {} }).button", "0"); |
133 shouldBe("new MouseEvent('eventType', { button: {moemoe: 12345} }).button", "0")
; | 134 shouldBe("new MouseEvent('eventType', { button: {moemoe: 12345} }).button", "0")
; |
134 shouldBe("new MouseEvent('eventType', { button: {valueOf: function () { return 1
2345; }} }).button", "12345"); | 135 shouldBe("new MouseEvent('eventType', { button: {valueOf: function () { return 1
2345; }} }).button", "12345"); |
135 | 136 |
| 137 // buttons is passed. |
| 138 // Numbers within the unsigned short range. |
| 139 shouldBe("new MouseEvent('eventType', { buttons: 0 }).buttons", "0"); |
| 140 shouldBe("new MouseEvent('eventType', { buttons: 1 }).buttons", "1"); |
| 141 shouldBe("new MouseEvent('eventType', { buttons: 65534 }).buttons", "65534"); |
| 142 |
| 143 // Numbers out of the unsigned short range. |
| 144 // 2^{64}-1 |
| 145 shouldBe("new MouseEvent('eventType', { buttons: 65535 }).buttons", "65535"); |
| 146 shouldBe("new MouseEvent('eventType', { buttons: 9007199254740991 }).buttons", "
65535"); |
| 147 shouldBe("new MouseEvent('eventType', { buttons: -1 }).buttons", "65535"); |
| 148 shouldBe("new MouseEvent('eventType', { buttons: 18446744073709551615 }).buttons
", "0"); |
| 149 shouldBe("new MouseEvent('eventType', { buttons: 12345678901234567890 }).buttons
", "2048"); |
| 150 shouldBe("new MouseEvent('eventType', { buttons: 123.45 }).buttons", "123"); |
| 151 shouldBe("new MouseEvent('eventType', { buttons: NaN }).buttons", "0"); |
| 152 |
| 153 // Non-numeric values. |
| 154 shouldBe("new MouseEvent('eventType', { buttons: undefined }).buttons", "0"); |
| 155 shouldBe("new MouseEvent('eventType', { buttons: null }).buttons", "0"); |
| 156 shouldBe("new MouseEvent('eventType', { buttons: '' }).buttons", "0"); |
| 157 shouldBe("new MouseEvent('eventType', { buttons: '12345' }).buttons", "12345"); |
| 158 shouldBe("new MouseEvent('eventType', { buttons: '12345a' }).buttons", "0"); |
| 159 shouldBe("new MouseEvent('eventType', { buttons: 'abc' }).buttons", "0"); |
| 160 shouldBe("new MouseEvent('eventType', { buttons: [] }).buttons", "0"); |
| 161 shouldBe("new MouseEvent('eventType', { buttons: [12345] }).buttons", "12345"); |
| 162 shouldBe("new MouseEvent('eventType', { buttons: [12345, 67890] }).buttons", "0"
); |
| 163 shouldBe("new MouseEvent('eventType', { buttons: {} }).buttons", "0"); |
| 164 shouldBe("new MouseEvent('eventType', { buttons: {moemoe: 12345} }).buttons", "0
"); |
| 165 shouldBe("new MouseEvent('eventType', { buttons: {valueOf: function () { return
12345; }} }).buttons", "12345"); |
| 166 |
136 // relatedTarget is passed. | 167 // relatedTarget is passed. |
137 // Valid objects. | 168 // Valid objects. |
138 shouldBe("new MouseEvent('eventType', { relatedTarget: testDiv }).relatedTarget"
, "testDiv"); | 169 shouldBe("new MouseEvent('eventType', { relatedTarget: testDiv }).relatedTarget"
, "testDiv"); |
139 shouldBe("new MouseEvent('eventType', { relatedTarget: document }).relatedTarget
", "document"); | 170 shouldBe("new MouseEvent('eventType', { relatedTarget: document }).relatedTarget
", "document"); |
140 shouldBe("new MouseEvent('eventType', { relatedTarget: xhr }).relatedTarget", "x
hr"); | 171 shouldBe("new MouseEvent('eventType', { relatedTarget: xhr }).relatedTarget", "x
hr"); |
141 shouldBe("new MouseEvent('eventType', { relatedTarget: window }).relatedTarget",
"window"); | 172 shouldBe("new MouseEvent('eventType', { relatedTarget: window }).relatedTarget",
"window"); |
142 | 173 |
143 // Invalid objects. | 174 // Invalid objects. |
144 shouldThrow("new MouseEvent('eventType', { relatedTarget: testObject }).relatedT
arget"); | 175 shouldThrow("new MouseEvent('eventType', { relatedTarget: testObject }).relatedT
arget"); |
145 shouldBe("new MouseEvent('eventType', { relatedTarget: undefined }).relatedTarge
t", "null"); | 176 shouldBe("new MouseEvent('eventType', { relatedTarget: undefined }).relatedTarge
t", "null"); |
146 shouldBe("new MouseEvent('eventType', { relatedTarget: null }).relatedTarget", "
null"); | 177 shouldBe("new MouseEvent('eventType', { relatedTarget: null }).relatedTarget", "
null"); |
147 shouldThrow("new MouseEvent('eventType', { relatedTarget: false }).relatedTarget
"); | 178 shouldThrow("new MouseEvent('eventType', { relatedTarget: false }).relatedTarget
"); |
148 shouldThrow("new MouseEvent('eventType', { relatedTarget: true }).relatedTarget"
); | 179 shouldThrow("new MouseEvent('eventType', { relatedTarget: true }).relatedTarget"
); |
149 shouldThrow("new MouseEvent('eventType', { relatedTarget: '' }).relatedTarget"); | 180 shouldThrow("new MouseEvent('eventType', { relatedTarget: '' }).relatedTarget"); |
150 shouldThrow("new MouseEvent('eventType', { relatedTarget: 'chocolate' }).related
Target"); | 181 shouldThrow("new MouseEvent('eventType', { relatedTarget: 'chocolate' }).related
Target"); |
151 shouldThrow("new MouseEvent('eventType', { relatedTarget: 12345 }).relatedTarget
"); | 182 shouldThrow("new MouseEvent('eventType', { relatedTarget: 12345 }).relatedTarget
"); |
152 shouldThrow("new MouseEvent('eventType', { relatedTarget: 18446744073709551615 }
).relatedTarget"); | 183 shouldThrow("new MouseEvent('eventType', { relatedTarget: 18446744073709551615 }
).relatedTarget"); |
153 shouldThrow("new MouseEvent('eventType', { relatedTarget: NaN }).relatedTarget")
; | 184 shouldThrow("new MouseEvent('eventType', { relatedTarget: NaN }).relatedTarget")
; |
154 // Note that valueOf() is not called, when the left hand side is evaluated. | 185 // Note that valueOf() is not called, when the left hand side is evaluated. |
155 shouldThrow("new MouseEvent('eventType', { relatedTarget: {valueOf: function ()
{ return testDiv; } } }).relatedTarget == testDiv"); | 186 shouldThrow("new MouseEvent('eventType', { relatedTarget: {valueOf: function ()
{ return testDiv; } } }).relatedTarget == testDiv"); |
156 shouldBe("new MouseEvent('eventType', { get relatedTarget() { return testDiv; }
}).relatedTarget", "testDiv"); | 187 shouldBe("new MouseEvent('eventType', { get relatedTarget() { return testDiv; }
}).relatedTarget", "testDiv"); |
157 shouldThrow("new MouseEvent('eventType', { get relatedTarget() { return 123; } }
).relatedTarget"); | 188 shouldThrow("new MouseEvent('eventType', { get relatedTarget() { return 123; } }
).relatedTarget"); |
158 shouldThrow("new MouseEvent('eventType', { get relatedTarget() { throw 'MouseEve
nt Error'; } })"); | 189 shouldThrow("new MouseEvent('eventType', { get relatedTarget() { throw 'MouseEve
nt Error'; } })"); |
159 | 190 |
160 // All initializers are passed. | 191 // All initializers are passed. |
161 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).bubbles", "true"); | 192 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).bubbles", "true"); |
162 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).cancelable", "true"); | 193 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).cancelable", "true"); |
163 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).view", "window"); | 194 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).view", "window"); |
164 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).detail", "111"); | 195 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).detail", "111"); |
165 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).screenX", "222"); | 196 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).screenX", "222"); |
166 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).screenY", "333"); | 197 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).screenY", "333"); |
167 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).clientX", "444"); | 198 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).clientX", "444"); |
168 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).clientY", "555"); | 199 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).clientY", "555"); |
169 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).ctrlKey", "true"); | 200 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).ctrlKey", "true"); |
170 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).shiftKey", "true"); | 201 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).shiftKey", "true"); |
171 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).altKey", "true"); | 202 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).altKey", "true"); |
172 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).metaKey", "true"); | 203 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).metaKey", "true"); |
173 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).button", "666"); | 204 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).button", "666"); |
174 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarg
et: testDiv }).relatedTarget", "testDiv"); | 205 shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: w
indow, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrl
Key: true, shiftKey: true, altKey: true, metaKey: true, button: 666, buttons: 77
7, relatedTarget: testDiv }).relatedTarget", "testDiv"); |
175 </script> | 206 </script> |
176 </body> | 207 </body> |
177 </html> | 208 </html> |
OLD | NEW |