Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: LayoutTests/fast/events/constructors/keyboard-event-constructor.html

Issue 20986003: Define DOM_KEY_LOCATION_* constants on KeyboardEvent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../js/resources/js-test-pre.js"></script> 4 <script src="../../js/resources/js-test-pre.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 8
9 description("This tests the constructor for the KeyboardEvent DOM class."); 9 description("This tests the constructor for the KeyboardEvent DOM class.");
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: 12345 }). keyIdentifier", "12345"); 65 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: 12345 }). keyIdentifier", "12345");
66 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: 184467440 73709551615 }).keyIdentifier", "18446744073709552000"); 66 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: 184467440 73709551615 }).keyIdentifier", "18446744073709552000");
67 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: NaN }).ke yIdentifier", "NaN"); 67 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: NaN }).ke yIdentifier", "NaN");
68 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: [] }).key Identifier", ""); 68 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: [] }).key Identifier", "");
69 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: [1, 2, 3] }).keyIdentifier", "1,2,3"); 69 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: [1, 2, 3] }).keyIdentifier", "1,2,3");
70 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: {koakuma: 12345} }).keyIdentifier", "[object Object]"); 70 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: {koakuma: 12345} }).keyIdentifier", "[object Object]");
71 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: {valueOf: function () { return 'koakuma'; } } }).keyIdentifier", "[object Object]"); 71 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: {valueOf: function () { return 'koakuma'; } } }).keyIdentifier", "[object Object]");
72 72
73 // keyLocation is passed. 73 // keyLocation is passed.
74 // numbers within the unsigned long range. 74 // numbers within the unsigned long range.
75 shouldBe("new KeyboardEvent('eventType', { keyLocation: 0 }).keyLocation", "0"); 75 shouldBe("new KeyboardEvent('eventType', { keyLocation: KeyboardEvent.DOM_KEY_LO CATION_STANDARD }).keyLocation", "KeyboardEvent.DOM_KEY_LOCATION_STANDARD");
76 shouldBe("new KeyboardEvent('eventType', { keyLocation: 1 }).keyLocation", "1"); 76 shouldBe("new KeyboardEvent('eventType', { keyLocation: KeyboardEvent.DOM_KEY_LO CATION_LEFT }).keyLocation", "KeyboardEvent.DOM_KEY_LOCATION_LEFT");
77 shouldBe("new KeyboardEvent('eventType', { keyLocation: 4294967294 }).keyLocatio n", "4294967294"); 77 shouldBe("new KeyboardEvent('eventType', { keyLocation: 4294967294 }).keyLocatio n", "4294967294");
78 shouldBe("new KeyboardEvent('eventType', { keyLocation: 4294967295 }).keyLocatio n", "4294967295"); 78 shouldBe("new KeyboardEvent('eventType', { keyLocation: 4294967295 }).keyLocatio n", "4294967295");
79 79
80 // numbers out of the unsigned long range. 80 // numbers out of the unsigned long range.
81 // 2^{53}-1, the largest number that can be exactly represented by double. 81 // 2^{53}-1, the largest number that can be exactly represented by double.
82 shouldBe("new KeyboardEvent('eventType', { keyLocation: 9007199254740991 }).keyL ocation", "4294967295"); 82 shouldBe("new KeyboardEvent('eventType', { keyLocation: 9007199254740991 }).keyL ocation", "4294967295");
83 // 2^{64}-1 83 // 2^{64}-1
84 shouldBe("new KeyboardEvent('eventType', { keyLocation: 18446744073709551615 }). keyLocation", "0"); 84 shouldBe("new KeyboardEvent('eventType', { keyLocation: 18446744073709551615 }). keyLocation", "KeyboardEvent.DOM_KEY_LOCATION_STANDARD");
85 shouldBe("new KeyboardEvent('eventType', { keyLocation: 12345678901234567890 }). keyLocation", "3944679424"); 85 shouldBe("new KeyboardEvent('eventType', { keyLocation: 12345678901234567890 }). keyLocation", "3944679424");
86 shouldBe("new KeyboardEvent('eventType', { keyLocation: -1 }).keyLocation", "429 4967295"); 86 shouldBe("new KeyboardEvent('eventType', { keyLocation: -1 }).keyLocation", "429 4967295");
87 shouldBe("new KeyboardEvent('eventType', { keyLocation: 123.45 }).keyLocation", "123"); 87 shouldBe("new KeyboardEvent('eventType', { keyLocation: 123.45 }).keyLocation", "123");
88 shouldBe("new KeyboardEvent('eventType', { keyLocation: NaN }).keyLocation", "0" ); 88 shouldBe("new KeyboardEvent('eventType', { keyLocation: NaN }).keyLocation", "Ke yboardEvent.DOM_KEY_LOCATION_STANDARD");
89 89
90 // Non-numeric values. 90 // Non-numeric values.
91 shouldBe("new KeyboardEvent('eventType', { keyLocation: undefined }).keyLocation ", "0"); 91 shouldBe("new KeyboardEvent('eventType', { keyLocation: undefined }).keyLocation ", "KeyboardEvent.DOM_KEY_LOCATION_STANDARD");
92 shouldBe("new KeyboardEvent('eventType', { keyLocation: null }).keyLocation", "0 "); 92 shouldBe("new KeyboardEvent('eventType', { keyLocation: null }).keyLocation", "K eyboardEvent.DOM_KEY_LOCATION_STANDARD");
93 shouldBe("new KeyboardEvent('eventType', { keyLocation: '' }).keyLocation", "0") ; 93 shouldBe("new KeyboardEvent('eventType', { keyLocation: '' }).keyLocation", "Key boardEvent.DOM_KEY_LOCATION_STANDARD");
94 shouldBe("new KeyboardEvent('eventType', { keyLocation: '12345' }).keyLocation", "12345"); 94 shouldBe("new KeyboardEvent('eventType', { keyLocation: '12345' }).keyLocation", "12345");
95 shouldBe("new KeyboardEvent('eventType', { keyLocation: '12345a' }).keyLocation" , "0"); 95 shouldBe("new KeyboardEvent('eventType', { keyLocation: '12345a' }).keyLocation" , "KeyboardEvent.DOM_KEY_LOCATION_STANDARD");
96 shouldBe("new KeyboardEvent('eventType', { keyLocation: 'abc' }).keyLocation", " 0"); 96 shouldBe("new KeyboardEvent('eventType', { keyLocation: 'abc' }).keyLocation", " KeyboardEvent.DOM_KEY_LOCATION_STANDARD");
97 shouldBe("new KeyboardEvent('eventType', { keyLocation: [] }).keyLocation", "0") ; 97 shouldBe("new KeyboardEvent('eventType', { keyLocation: [] }).keyLocation", "Key boardEvent.DOM_KEY_LOCATION_STANDARD");
98 shouldBe("new KeyboardEvent('eventType', { keyLocation: [12345] }).keyLocation", "12345"); 98 shouldBe("new KeyboardEvent('eventType', { keyLocation: [12345] }).keyLocation", "12345");
99 shouldBe("new KeyboardEvent('eventType', { keyLocation: [12345, 67890] }).keyLoc ation", "0"); 99 shouldBe("new KeyboardEvent('eventType', { keyLocation: [12345, 67890] }).keyLoc ation", "KeyboardEvent.DOM_KEY_LOCATION_STANDARD");
100 shouldBe("new KeyboardEvent('eventType', { keyLocation: {} }).keyLocation", "0") ; 100 shouldBe("new KeyboardEvent('eventType', { keyLocation: {} }).keyLocation", "Key boardEvent.DOM_KEY_LOCATION_STANDARD");
101 shouldBe("new KeyboardEvent('eventType', { keyLocation: {moemoe: 12345} }).keyLo cation", "0"); 101 shouldBe("new KeyboardEvent('eventType', { keyLocation: {moemoe: 12345} }).keyLo cation", "KeyboardEvent.DOM_KEY_LOCATION_STANDARD");
102 shouldBe("new KeyboardEvent('eventType', { keyLocation: {valueOf: function () { return 12345; }} }).keyLocation", "12345"); 102 shouldBe("new KeyboardEvent('eventType', { keyLocation: {valueOf: function () { return 12345; }} }).keyLocation", "12345");
103 103
104 // ctrlKey, altKey, shiftKey and metaKey are passed. 104 // ctrlKey, altKey, shiftKey and metaKey are passed.
105 ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach(function (attr) { 105 ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach(function (attr) {
106 shouldBe("new KeyboardEvent('eventType', { " + attr + ": false })." + attr, "false"); 106 shouldBe("new KeyboardEvent('eventType', { " + attr + ": false })." + attr, "false");
107 shouldBe("new KeyboardEvent('eventType', { " + attr + ": true })." + attr, " true"); 107 shouldBe("new KeyboardEvent('eventType', { " + attr + ": true })." + attr, " true");
108 }); 108 });
109 109
110 // All initializers are passed. 110 // All initializers are passed.
111 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).bubbles", "true"); 111 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).bubbles", "true");
112 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).cancelable", "true"); 112 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).cancelable", "true");
113 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).view", "window"); 113 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).view", "window");
114 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).detail", "111"); 114 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).detail", "111");
115 shouldBeEqualToString("new KeyboardEvent('eventType', { bubbles: true, cancelabl e: true, view: window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222 , ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).keyIdentifier", "chocolate"); 115 shouldBeEqualToString("new KeyboardEvent('eventType', { bubbles: true, cancelabl e: true, view: window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222 , ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).keyIdentifier", "chocolate");
116 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).keyLocation", "222"); 116 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).keyLocation", "222");
117 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).ctrlKey", "true"); 117 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).ctrlKey", "true");
118 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).altKey", "true"); 118 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).altKey", "true");
119 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).shiftKey", "true"); 119 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).shiftKey", "true");
120 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).metaKey", "true"); 120 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view : window, detail: 111, keyIdentifier: 'chocolate', keyLocation: 222, ctrlKey: tr ue, altKey: true, shiftKey: true, metaKey: true }).metaKey", "true");
121 </script> 121 </script>
122 <script src="../../js/resources/js-test-post.js"></script> 122 <script src="../../js/resources/js-test-post.js"></script>
123 </body> 123 </body>
124 </html> 124 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698