| 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 <script src="../resources/input-modifiers.js"></script> | 5 <script src="../resources/input-modifiers.js"></script> |
| 6 </head> | 6 </head> |
| 7 <body> | 7 <body> |
| 8 <script> | 8 <script> |
| 9 | 9 |
| 10 description("This tests the constructor for the KeyboardEvent DOM class."); | 10 description("This tests the constructor for the KeyboardEvent DOM class."); |
| 11 | 11 |
| 12 var testObject = {nyannyan: 123}; | 12 var testObject = {nyannyan: 123}; |
| 13 | 13 |
| 14 // No initializer is passed. | 14 // No initializer is passed. |
| 15 shouldBe("new KeyboardEvent('eventType').bubbles", "false"); | 15 shouldBe("new KeyboardEvent('eventType').bubbles", "false"); |
| 16 shouldBe("new KeyboardEvent('eventType').cancelable", "false"); | 16 shouldBe("new KeyboardEvent('eventType').cancelable", "false"); |
| 17 shouldBe("new KeyboardEvent('eventType').view", "null"); | 17 shouldBe("new KeyboardEvent('eventType').view", "null"); |
| 18 shouldBe("new KeyboardEvent('eventType').detail", "0"); | 18 shouldBe("new KeyboardEvent('eventType').detail", "0"); |
| 19 shouldBeEqualToString("new KeyboardEvent('eventType').keyIdentifier", ""); | |
| 20 shouldBe("new KeyboardEvent('eventType').location", "0"); | 19 shouldBe("new KeyboardEvent('eventType').location", "0"); |
| 21 shouldBe("new KeyboardEvent('eventType').ctrlKey", "false"); | 20 shouldBe("new KeyboardEvent('eventType').ctrlKey", "false"); |
| 22 shouldBe("new KeyboardEvent('eventType').altKey", "false"); | 21 shouldBe("new KeyboardEvent('eventType').altKey", "false"); |
| 23 shouldBe("new KeyboardEvent('eventType').shiftKey", "false"); | 22 shouldBe("new KeyboardEvent('eventType').shiftKey", "false"); |
| 24 shouldBe("new KeyboardEvent('eventType').metaKey", "false"); | 23 shouldBe("new KeyboardEvent('eventType').metaKey", "false"); |
| 25 shouldBe("new KeyboardEvent('eventType').repeat", "false"); | 24 shouldBe("new KeyboardEvent('eventType').repeat", "false"); |
| 26 | 25 |
| 27 // bubbles is passed. | 26 // bubbles is passed. |
| 28 shouldBe("new KeyboardEvent('eventType', { bubbles: false }).bubbles", "false"); | 27 shouldBe("new KeyboardEvent('eventType', { bubbles: false }).bubbles", "false"); |
| 29 shouldBe("new KeyboardEvent('eventType', { bubbles: true }).bubbles", "true"); | 28 shouldBe("new KeyboardEvent('eventType', { bubbles: true }).bubbles", "true"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 48 shouldThrow("new KeyboardEvent('eventType', { view: 'chocolate' }).view"); | 47 shouldThrow("new KeyboardEvent('eventType', { view: 'chocolate' }).view"); |
| 49 shouldThrow("new KeyboardEvent('eventType', { view: 12345 }).view"); | 48 shouldThrow("new KeyboardEvent('eventType', { view: 12345 }).view"); |
| 50 shouldThrow("new KeyboardEvent('eventType', { view: 18446744073709551615 }).view
"); | 49 shouldThrow("new KeyboardEvent('eventType', { view: 18446744073709551615 }).view
"); |
| 51 shouldThrow("new KeyboardEvent('eventType', { view: NaN }).view"); | 50 shouldThrow("new KeyboardEvent('eventType', { view: NaN }).view"); |
| 52 // Note that valueOf() is not called, when the left hand side is evaluated. | 51 // Note that valueOf() is not called, when the left hand side is evaluated. |
| 53 shouldThrow("new KeyboardEvent('eventType', { view: {valueOf: function () { retu
rn window; } } }).view == window"); | 52 shouldThrow("new KeyboardEvent('eventType', { view: {valueOf: function () { retu
rn window; } } }).view == window"); |
| 54 shouldBe("new KeyboardEvent('eventType', { get view() { return window; } }).view
", "window"); | 53 shouldBe("new KeyboardEvent('eventType', { get view() { return window; } }).view
", "window"); |
| 55 shouldThrow("new KeyboardEvent('eventType', { get view() { return 123; } }).view
"); | 54 shouldThrow("new KeyboardEvent('eventType', { get view() { return 123; } }).view
"); |
| 56 shouldThrow("new KeyboardEvent('eventType', { get view() { throw 'KeyboardEvent
Error'; } })"); | 55 shouldThrow("new KeyboardEvent('eventType', { get view() { throw 'KeyboardEvent
Error'; } })"); |
| 57 | 56 |
| 58 // keyIdentifier is passed. | |
| 59 // Strings. | |
| 60 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: 'koakuma'
}).keyIdentifier", "koakuma"); | |
| 61 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: '' }).key
Identifier", ""); | |
| 62 | |
| 63 // Non-strings. | |
| 64 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: undefined
}).keyIdentifier", ""); | |
| 65 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: null }).k
eyIdentifier", "null"); | |
| 66 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: false }).
keyIdentifier", "false"); | |
| 67 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: true }).k
eyIdentifier", "true"); | |
| 68 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: 12345 }).
keyIdentifier", "12345"); | |
| 69 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: 184467440
73709551615 }).keyIdentifier", "18446744073709552000"); | |
| 70 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: NaN }).ke
yIdentifier", "NaN"); | |
| 71 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: [] }).key
Identifier", ""); | |
| 72 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: [1, 2, 3]
}).keyIdentifier", "1,2,3"); | |
| 73 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: {koakuma:
12345} }).keyIdentifier", "[object Object]"); | |
| 74 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: {valueOf:
function () { return 'koakuma'; } } }).keyIdentifier", "[object Object]"); | |
| 75 | |
| 76 // code is passed. | 57 // code is passed. |
| 77 // Strings. | 58 // Strings. |
| 78 shouldBeEqualToString("new KeyboardEvent('eventType', { code: 'koakuma' }).code"
, "koakuma"); | 59 shouldBeEqualToString("new KeyboardEvent('eventType', { code: 'koakuma' }).code"
, "koakuma"); |
| 79 shouldBeEqualToString("new KeyboardEvent('eventType', { code: '' }).code", ""); | 60 shouldBeEqualToString("new KeyboardEvent('eventType', { code: '' }).code", ""); |
| 80 | 61 |
| 81 // Non-strings. | 62 // Non-strings. |
| 82 shouldBeEqualToString("new KeyboardEvent('eventType', { code: undefined }).code"
, ""); | 63 shouldBeEqualToString("new KeyboardEvent('eventType', { code: undefined }).code"
, ""); |
| 83 shouldBeEqualToString("new KeyboardEvent('eventType', { code: null }).code", "nu
ll"); | 64 shouldBeEqualToString("new KeyboardEvent('eventType', { code: null }).code", "nu
ll"); |
| 84 shouldBeEqualToString("new KeyboardEvent('eventType', { code: false }).code", "f
alse"); | 65 shouldBeEqualToString("new KeyboardEvent('eventType', { code: false }).code", "f
alse"); |
| 85 shouldBeEqualToString("new KeyboardEvent('eventType', { code: true }).code", "tr
ue"); | 66 shouldBeEqualToString("new KeyboardEvent('eventType', { code: true }).code", "tr
ue"); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 shouldBe("new KeyboardEvent('eventType', { " + attr + ": true })." + attr, "
true"); | 127 shouldBe("new KeyboardEvent('eventType', { " + attr + ": true })." + attr, "
true"); |
| 147 }); | 128 }); |
| 148 | 129 |
| 149 // all modifiers are passed correctly. | 130 // all modifiers are passed correctly. |
| 150 forEachModifier(function(attr, modifierName) { | 131 forEachModifier(function(attr, modifierName) { |
| 151 shouldBe("new KeyboardEvent('eventType', { " + attr + ": false }).getModifie
rState('" + modifierName + "');", "false"); | 132 shouldBe("new KeyboardEvent('eventType', { " + attr + ": false }).getModifie
rState('" + modifierName + "');", "false"); |
| 152 shouldBe("new KeyboardEvent('eventType', { " + attr + ": true }).getModifier
State('" + modifierName + "');", "true"); | 133 shouldBe("new KeyboardEvent('eventType', { " + attr + ": true }).getModifier
State('" + modifierName + "');", "true"); |
| 153 }); | 134 }); |
| 154 | 135 |
| 155 // All initializers are passed. | 136 // All initializers are passed. |
| 156 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode', key: 'chokey
', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, re
peat: true }).bubbles", "true"); | 137 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, code: 'chocode', key: 'chokey', location: 222, ctrlKey: t
rue, altKey: true, shiftKey: true, metaKey: true, repeat: true }).bubbles", "tru
e"); |
| 157 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode', key: 'chokey
', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, re
peat: true }).cancelable", "true"); | 138 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, code: 'chocode', key: 'chokey', location: 222, ctrlKey: t
rue, altKey: true, shiftKey: true, metaKey: true, repeat: true }).cancelable", "
true"); |
| 158 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode', key: 'chokey
', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, re
peat: true }).view", "window"); | 139 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, code: 'chocode', key: 'chokey', location: 222, ctrlKey: t
rue, altKey: true, shiftKey: true, metaKey: true, repeat: true }).view", "window
"); |
| 159 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode', key: 'chokey
', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, re
peat: true }).detail", "111"); | 140 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, code: 'chocode', key: 'chokey', location: 222, ctrlKey: t
rue, altKey: true, shiftKey: true, metaKey: true, repeat: true }).detail", "111"
); |
| 160 shouldBeEqualToString("new KeyboardEvent('eventType', { bubbles: true, cancelabl
e: true, view: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode',
key: 'chokey', location: 222, ctrlKey: true, altKey: true, shiftKey: true, meta
Key: true, repeat: true }).keyIdentifier", "chocolate"); | 141 shouldBeEqualToString("new KeyboardEvent('eventType', { bubbles: true, cancelabl
e: true, view: window, detail: 111, code: 'chocode', key: 'chokey', location: 22
2, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, repeat: true }).c
ode", "chocode"); |
| 161 shouldBeEqualToString("new KeyboardEvent('eventType', { bubbles: true, cancelabl
e: true, view: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode',
key: 'chokey', location: 222, ctrlKey: true, altKey: true, shiftKey: true, meta
Key: true, repeat: true }).code", "chocode"); | 142 shouldBeEqualToString("new KeyboardEvent('eventType', { bubbles: true, cancelabl
e: true, view: window, detail: 111, code: 'chocode', key: 'chokey', location: 22
2, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, repeat: true }).k
ey", "chokey"); |
| 162 shouldBeEqualToString("new KeyboardEvent('eventType', { bubbles: true, cancelabl
e: true, view: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode',
key: 'chokey', location: 222, ctrlKey: true, altKey: true, shiftKey: true, meta
Key: true, repeat: true }).key", "chokey"); | 143 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, code: 'chocode', key: 'chokey', location: 222, ctrlKey: t
rue, altKey: true, shiftKey: true, metaKey: true, repeat: true }).location", "22
2"); |
| 163 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode', key: 'chokey
', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, re
peat: true }).location", "222"); | 144 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, code: 'chocode', key: 'chokey', location: 222, ctrlKey: t
rue, altKey: true, shiftKey: true, metaKey: true, repeat: true }).ctrlKey", "tru
e"); |
| 164 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode', key: 'chokey
', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, re
peat: true }).ctrlKey", "true"); | 145 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, code: 'chocode', key: 'chokey', location: 222, ctrlKey: t
rue, altKey: true, shiftKey: true, metaKey: true, repeat: true }).altKey", "true
"); |
| 165 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode', key: 'chokey
', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, re
peat: true }).altKey", "true"); | 146 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, code: 'chocode', key: 'chokey', location: 222, ctrlKey: t
rue, altKey: true, shiftKey: true, metaKey: true, repeat: true }).shiftKey", "tr
ue"); |
| 166 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode', key: 'chokey
', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, re
peat: true }).shiftKey", "true"); | 147 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, code: 'chocode', key: 'chokey', location: 222, ctrlKey: t
rue, altKey: true, shiftKey: true, metaKey: true, repeat: true }).metaKey", "tru
e"); |
| 167 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode', key: 'chokey
', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, re
peat: true }).metaKey", "true"); | 148 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, code: 'chocode', key: 'chokey', location: 222, ctrlKey: t
rue, altKey: true, shiftKey: true, metaKey: true, repeat: true }).repeat", "true
"); |
| 168 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view
: window, detail: 111, keyIdentifier: 'chocolate', code: 'chocode', key: 'chokey
', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true, re
peat: true }).repeat", "true"); | |
| 169 </script> | 149 </script> |
| 170 </body> | 150 </body> |
| 171 </html> | 151 </html> |
| OLD | NEW |