blob: 4139ce2c4a8652719675f6cc8fc389b271f2f69f [file] [log] [blame]
CONSOLE WARNING: 'KeyboardEvent.keyLocation' is deprecated and will be removed in M50, around April 2016. Please use 'KeyboardEvent.location' instead. See https://www.chromestatus.com/features/4997403308457984 for more details.
This tests the constructor for the KeyboardEvent DOM class.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS new KeyboardEvent('eventType').bubbles is false
PASS new KeyboardEvent('eventType').cancelable is false
PASS new KeyboardEvent('eventType').view is null
PASS new KeyboardEvent('eventType').detail is 0
PASS new KeyboardEvent('eventType').keyIdentifier is ""
PASS new KeyboardEvent('eventType').location is 0
PASS new KeyboardEvent('eventType').ctrlKey is false
PASS new KeyboardEvent('eventType').altKey is false
PASS new KeyboardEvent('eventType').shiftKey is false
PASS new KeyboardEvent('eventType').metaKey is false
PASS new KeyboardEvent('eventType').repeat is false
PASS new KeyboardEvent('eventType', { bubbles: false }).bubbles is false
PASS new KeyboardEvent('eventType', { bubbles: true }).bubbles is true
PASS new KeyboardEvent('eventType', { cancelable: false }).cancelable is false
PASS new KeyboardEvent('eventType', { cancelable: true }).cancelable is true
PASS new KeyboardEvent('eventType', { view: window }).view is window
PASS new KeyboardEvent('eventType', { view: this }).view is this
PASS new KeyboardEvent('eventType', { view: testObject }).view threw exception TypeError: Failed to construct 'KeyboardEvent': member view is not of type Window..
PASS new KeyboardEvent('eventType', { view: document }).view threw exception TypeError: Failed to construct 'KeyboardEvent': member view is not of type Window..
PASS new KeyboardEvent('eventType', { view: undefined }).view is null
PASS new KeyboardEvent('eventType', { view: null }).view is null
PASS new KeyboardEvent('eventType', { view: false }).view threw exception TypeError: Failed to construct 'KeyboardEvent': member view is not of type Window..
PASS new KeyboardEvent('eventType', { view: true }).view threw exception TypeError: Failed to construct 'KeyboardEvent': member view is not of type Window..
PASS new KeyboardEvent('eventType', { view: '' }).view threw exception TypeError: Failed to construct 'KeyboardEvent': member view is not of type Window..
PASS new KeyboardEvent('eventType', { view: 'chocolate' }).view threw exception TypeError: Failed to construct 'KeyboardEvent': member view is not of type Window..
PASS new KeyboardEvent('eventType', { view: 12345 }).view threw exception TypeError: Failed to construct 'KeyboardEvent': member view is not of type Window..
PASS new KeyboardEvent('eventType', { view: 18446744073709551615 }).view threw exception TypeError: Failed to construct 'KeyboardEvent': member view is not of type Window..
PASS new KeyboardEvent('eventType', { view: NaN }).view threw exception TypeError: Failed to construct 'KeyboardEvent': member view is not of type Window..
PASS new KeyboardEvent('eventType', { view: {valueOf: function () { return window; } } }).view == window threw exception TypeError: Failed to construct 'KeyboardEvent': member view is not of type Window..
PASS new KeyboardEvent('eventType', { get view() { return window; } }).view is window
PASS new KeyboardEvent('eventType', { get view() { return 123; } }).view threw exception TypeError: Failed to construct 'KeyboardEvent': member view is not of type Window..
PASS new KeyboardEvent('eventType', { get view() { throw 'KeyboardEvent Error'; } }) threw exception KeyboardEvent Error.
PASS new KeyboardEvent('eventType', { keyIdentifier: 'koakuma' }).keyIdentifier is "koakuma"
PASS new KeyboardEvent('eventType', { keyIdentifier: '' }).keyIdentifier is ""
PASS new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier is ""
PASS new KeyboardEvent('eventType', { keyIdentifier: null }).keyIdentifier is "null"
PASS new KeyboardEvent('eventType', { keyIdentifier: false }).keyIdentifier is "false"
PASS new KeyboardEvent('eventType', { keyIdentifier: true }).keyIdentifier is "true"
PASS new KeyboardEvent('eventType', { keyIdentifier: 12345 }).keyIdentifier is "12345"
PASS new KeyboardEvent('eventType', { keyIdentifier: 18446744073709551615 }).keyIdentifier is "18446744073709552000"
PASS new KeyboardEvent('eventType', { keyIdentifier: NaN }).keyIdentifier is "NaN"
PASS new KeyboardEvent('eventType', { keyIdentifier: [] }).keyIdentifier is ""
PASS new KeyboardEvent('eventType', { keyIdentifier: [1, 2, 3] }).keyIdentifier is "1,2,3"
PASS new KeyboardEvent('eventType', { keyIdentifier: {koakuma: 12345} }).keyIdentifier is "[object Object]"
PASS new KeyboardEvent('eventType', { keyIdentifier: {valueOf: function () { return 'koakuma'; } } }).keyIdentifier is "[object Object]"
PASS new KeyboardEvent('eventType', { code: 'koakuma' }).code is "koakuma"
PASS new KeyboardEvent('eventType', { code: '' }).code is ""
PASS new KeyboardEvent('eventType', { code: undefined }).code is ""
PASS new KeyboardEvent('eventType', { code: null }).code is "null"
PASS new KeyboardEvent('eventType', { code: false }).code is "false"
PASS new KeyboardEvent('eventType', { code: true }).code is "true"
PASS new KeyboardEvent('eventType', { code: 12345 }).code is "12345"
PASS new KeyboardEvent('eventType', { code: 18446744073709551615 }).code is "18446744073709552000"
PASS new KeyboardEvent('eventType', { code: NaN }).code is "NaN"
PASS new KeyboardEvent('eventType', { code: [] }).code is ""
PASS new KeyboardEvent('eventType', { code: [1, 2, 3] }).code is "1,2,3"
PASS new KeyboardEvent('eventType', { code: {koakuma: 12345} }).code is "[object Object]"
PASS new KeyboardEvent('eventType', { code: {valueOf: function () { return 'koakuma'; } } }).code is "[object Object]"
PASS new KeyboardEvent('eventType', { key: 'koakuma' }).key is "koakuma"
PASS new KeyboardEvent('eventType', { key: '' }).key is ""
PASS new KeyboardEvent('eventType', { key: undefined }).key is ""
PASS new KeyboardEvent('eventType', { key: null }).key is "null"
PASS new KeyboardEvent('eventType', { key: false }).key is "false"
PASS new KeyboardEvent('eventType', { key: true }).key is "true"
PASS new KeyboardEvent('eventType', { key: 12345 }).key is "12345"
PASS new KeyboardEvent('eventType', { key: 18446744073709551615 }).key is "18446744073709552000"
PASS new KeyboardEvent('eventType', { key: NaN }).key is "NaN"
PASS new KeyboardEvent('eventType', { key: [] }).key is ""
PASS new KeyboardEvent('eventType', { key: [1, 2, 3] }).key is "1,2,3"
PASS new KeyboardEvent('eventType', { key: {koakuma: 12345} }).key is "[object Object]"
PASS new KeyboardEvent('eventType', { key: {valueOf: function () { return 'koakuma'; } } }).key is "[object Object]"
PASS new KeyboardEvent('eventType', { location: KeyboardEvent.DOM_KEY_LOCATION_STANDARD }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
PASS new KeyboardEvent('eventType', { location: KeyboardEvent.DOM_KEY_LOCATION_LEFT }).location is KeyboardEvent.DOM_KEY_LOCATION_LEFT
PASS new KeyboardEvent('eventType', { location: 4294967294 }).location is 4294967294
PASS new KeyboardEvent('eventType', { location: 4294967295 }).location is 4294967295
PASS new KeyboardEvent('eventType', { keyLocation: 0 }).keyLocation is 0
PASS new KeyboardEvent('eventType', { keyLocation: 1 }).keyLocation is 1
PASS new KeyboardEvent('eventType', { keyLocation: 1 }).location is 1
PASS new KeyboardEvent('eventType', { location: 1 }).keyLocation is 1
PASS new KeyboardEvent('eventType', { location: 9007199254740991 }).location is 4294967295
PASS new KeyboardEvent('eventType', { location: 18446744073709551615 }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
PASS new KeyboardEvent('eventType', { location: 12345678901234567890 }).location is 3944679424
PASS new KeyboardEvent('eventType', { location: -1 }).location is 4294967295
PASS new KeyboardEvent('eventType', { location: 123.45 }).location is 123
PASS new KeyboardEvent('eventType', { location: NaN }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
PASS new KeyboardEvent('eventType', { location: undefined }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
PASS new KeyboardEvent('eventType', { location: null }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
PASS new KeyboardEvent('eventType', { location: '' }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
PASS new KeyboardEvent('eventType', { location: '12345' }).location is 12345
PASS new KeyboardEvent('eventType', { location: '12345a' }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
PASS new KeyboardEvent('eventType', { location: 'abc' }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
PASS new KeyboardEvent('eventType', { location: [] }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
PASS new KeyboardEvent('eventType', { location: [12345] }).location is 12345
PASS new KeyboardEvent('eventType', { location: [12345, 67890] }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
PASS new KeyboardEvent('eventType', { location: {} }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
PASS new KeyboardEvent('eventType', { location: {moemoe: 12345} }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
PASS new KeyboardEvent('eventType', { location: {valueOf: function () { return 12345; }} }).location is 12345
PASS new KeyboardEvent('eventType', { ctrlKey: false }).ctrlKey is false
PASS new KeyboardEvent('eventType', { ctrlKey: true }).ctrlKey is true
PASS new KeyboardEvent('eventType', { altKey: false }).altKey is false
PASS new KeyboardEvent('eventType', { altKey: true }).altKey is true
PASS new KeyboardEvent('eventType', { shiftKey: false }).shiftKey is false
PASS new KeyboardEvent('eventType', { shiftKey: true }).shiftKey is true
PASS new KeyboardEvent('eventType', { metaKey: false }).metaKey is false
PASS new KeyboardEvent('eventType', { metaKey: true }).metaKey is true
PASS new KeyboardEvent('eventType', { repeat: false }).repeat is false
PASS new KeyboardEvent('eventType', { repeat: true }).repeat is true
PASS new KeyboardEvent('eventType', { ctrlKey: false }).getModifierState('Control'); is false
PASS new KeyboardEvent('eventType', { ctrlKey: true }).getModifierState('Control'); is true
PASS new KeyboardEvent('eventType', { shiftKey: false }).getModifierState('Shift'); is false
PASS new KeyboardEvent('eventType', { shiftKey: true }).getModifierState('Shift'); is true
PASS new KeyboardEvent('eventType', { metaKey: false }).getModifierState('Meta'); is false
PASS new KeyboardEvent('eventType', { metaKey: true }).getModifierState('Meta'); is true
PASS new KeyboardEvent('eventType', { altKey: false }).getModifierState('Alt'); is false
PASS new KeyboardEvent('eventType', { altKey: true }).getModifierState('Alt'); is true
PASS new KeyboardEvent('eventType', { modifierAltGraph: false }).getModifierState('AltGraph'); is false
PASS new KeyboardEvent('eventType', { modifierAltGraph: true }).getModifierState('AltGraph'); is true
PASS new KeyboardEvent('eventType', { modifierOS: false }).getModifierState('OS'); is false
PASS new KeyboardEvent('eventType', { modifierOS: true }).getModifierState('OS'); is true
PASS new KeyboardEvent('eventType', { modifierFn: false }).getModifierState('Fn'); is false
PASS new KeyboardEvent('eventType', { modifierFn: true }).getModifierState('Fn'); is true
PASS new KeyboardEvent('eventType', { modifierCapsLock: false }).getModifierState('CapsLock'); is false
PASS new KeyboardEvent('eventType', { modifierCapsLock: true }).getModifierState('CapsLock'); is true
PASS new KeyboardEvent('eventType', { modifierScrollLock: false }).getModifierState('ScrollLock'); is false
PASS new KeyboardEvent('eventType', { modifierScrollLock: true }).getModifierState('ScrollLock'); is true
PASS new KeyboardEvent('eventType', { modifierNumLock: false }).getModifierState('NumLock'); is false
PASS new KeyboardEvent('eventType', { modifierNumLock: true }).getModifierState('NumLock'); is true
PASS new KeyboardEvent('eventType', { modifierSymbol: false }).getModifierState('Symbol'); is false
PASS new KeyboardEvent('eventType', { modifierSymbol: true }).getModifierState('Symbol'); is true
PASS 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, repeat: true }).bubbles is true
PASS 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, repeat: true }).cancelable is true
PASS 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, repeat: true }).view is window
PASS 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, repeat: true }).detail is 111
PASS 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, repeat: true }).keyIdentifier is "chocolate"
PASS 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, repeat: true }).code is "chocode"
PASS 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, repeat: true }).key is "chokey"
PASS 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, repeat: true }).location is 222
PASS 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, repeat: true }).ctrlKey is true
PASS 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, repeat: true }).altKey is true
PASS 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, repeat: true }).shiftKey is true
PASS 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, repeat: true }).metaKey is true
PASS 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, repeat: true }).repeat is true
PASS successfullyParsed is true
TEST COMPLETE