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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/constructors/mouse-event-constructor.html

Issue 2406263003: Make PointerEvent coordinates fractional for touch (Closed)
Patch Set: Updated a TODO. Created 4 years, 2 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
OLDNEW
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 MouseEvent DOM class."); 10 description("This tests the constructor for the MouseEvent DOM class.");
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 shouldThrow("new MouseEvent('eventType', { view: 'chocolate' }).view"); 54 shouldThrow("new MouseEvent('eventType', { view: 'chocolate' }).view");
55 shouldThrow("new MouseEvent('eventType', { view: 12345 }).view"); 55 shouldThrow("new MouseEvent('eventType', { view: 12345 }).view");
56 shouldThrow("new MouseEvent('eventType', { view: 18446744073709551615 }).view"); 56 shouldThrow("new MouseEvent('eventType', { view: 18446744073709551615 }).view");
57 shouldThrow("new MouseEvent('eventType', { view: NaN }).view"); 57 shouldThrow("new MouseEvent('eventType', { view: NaN }).view");
58 // Note that valueOf() is not called, when the left hand side is evaluated. 58 // Note that valueOf() is not called, when the left hand side is evaluated.
59 shouldThrow("new MouseEvent('eventType', { view: {valueOf: function () { return window; } } }).view == window"); 59 shouldThrow("new MouseEvent('eventType', { view: {valueOf: function () { return window; } } }).view == window");
60 shouldBe("new MouseEvent('eventType', { get view() { return window; } }).view", "window"); 60 shouldBe("new MouseEvent('eventType', { get view() { return window; } }).view", "window");
61 shouldThrow("new MouseEvent('eventType', { get view() { return 123; } }).view"); 61 shouldThrow("new MouseEvent('eventType', { get view() { return 123; } }).view");
62 shouldThrow("new MouseEvent('eventType', { get view() { throw 'MouseEvent Error' ; } })"); 62 shouldThrow("new MouseEvent('eventType', { get view() { throw 'MouseEvent Error' ; } })");
63 63
64 // Max/min for client positions (LayoutUnit max/min). 64 // detail is passed.
65 // numbers within the long range.
66 shouldBe("new MouseEvent('eventType', { detail: 0 }).detail", "0");
67 shouldBe("new MouseEvent('eventType', { detail: 2147483647 }).detail", "21474836 47");
68 shouldBe("new MouseEvent('eventType', { detail: -1 }).detail", "-1");
69 shouldBe("new MouseEvent('eventType', { detail: -2147483648 }).detail", "-214748 3648");
70 // numbers out of the long range.
71 shouldBe("new MouseEvent('eventType', { detail: 4294967295 }).detail", "-1");
72 // 2^{53}-1, the largest number that can be exactly represented by double.
73 shouldBe("new MouseEvent('eventType', { detail: 9007199254740991 }).detail", "-1 ");
74 // 2^{64}-1
75 shouldBe("new MouseEvent('eventType', { detail: 18446744073709551615 }).detail", "0");
76 shouldBe("new MouseEvent('eventType', { detail: 123.45 }).detail", "123");
77 shouldBe("new MouseEvent('eventType', { detail: NaN }).detail", "0");
78 // Non-numeric values.
79 shouldBe("new MouseEvent('eventType', { detail: undefined }).detail", "0");
80 shouldBe("new MouseEvent('eventType', { detail: null }).detail", "0");
81 shouldBe("new MouseEvent('eventType', { detail: '' }).detail", "0");
82 shouldBe("new MouseEvent('eventType', { detail: '12345' }).detail", "12345");
83 shouldBe("new MouseEvent('eventType', { detail: '12345a' }).detail", "0");
84 shouldBe("new MouseEvent('eventType', { detail: 'abc' }).detail", "0");
85 shouldBe("new MouseEvent('eventType', { detail: [] }).detail", "0");
86 shouldBe("new MouseEvent('eventType', { detail: [12345] }).detail", "12345");
87 shouldBe("new MouseEvent('eventType', { detail: [12345, 67890] }).detail", "0");
88 shouldBe("new MouseEvent('eventType', { detail: {} }).detail", "0");
89 shouldBe("new MouseEvent('eventType', { detail: {moemoe: 12345} }).detail", "0") ;
90 shouldBe("new MouseEvent('eventType', { detail: {valueOf: function () { return 1 2345; }} }).detail", "12345");
91
92 // Max/min for screen/client coordinates (LayoutUnit max/min).
65 var MAX_CLIENT_SIZE = "33554431"; 93 var MAX_CLIENT_SIZE = "33554431";
66 var MIN_CLIENT_SIZE = "-33554432"; 94 var MIN_CLIENT_SIZE = "-33554432";
67 95
68 // detail, screenX, screenY, clientX and clientY are passed. 96 // screenX, screenY, clientX and clientY are passed.
69 ["detail", "screenX", "screenY", "clientX", "clientY"].forEach(function (attr) { 97 ["screenX", "screenY", "clientX", "clientY"].forEach(function (attr) {
70 // numbers within the long range. 98 // numbers within the long range.
71 shouldBe("new MouseEvent('eventType', { " + attr + ": 0 })." + attr, "0"); 99 shouldBe("new MouseEvent('eventType', { " + attr + ": 0 })." + attr, "0");
72 shouldBe("new MouseEvent('eventType', { " + attr + ": 2147483647 })." + attr , attr == "clientX" || attr == "clientY" ? MAX_CLIENT_SIZE : "2147483647"); 100 shouldBe("new MouseEvent('eventType', { " + attr + ": 2147483647 })." + attr , MAX_CLIENT_SIZE);
73 shouldBe("new MouseEvent('eventType', { " + attr + ": -1 })." + attr, "-1"); 101 shouldBe("new MouseEvent('eventType', { " + attr + ": -1 })." + attr, "-1");
74 shouldBe("new MouseEvent('eventType', { " + attr + ": -2147483648 })." + att r, attr == "clientX" || attr == "clientY" ? MIN_CLIENT_SIZE : "-2147483648"); 102 shouldBe("new MouseEvent('eventType', { " + attr + ": -2147483648 })." + att r, MIN_CLIENT_SIZE);
75 103
76 // numbers out of the long range. 104 // numbers out of the long range.
77 shouldBe("new MouseEvent('eventType', { " + attr + ": 4294967295 })." + attr , "-1"); 105 shouldBe("new MouseEvent('eventType', { " + attr + ": 4294967295 })." + attr , MAX_CLIENT_SIZE);
78 // 2^{53}-1, the largest number that can be exactly represented by double. 106 // 2^{53}-1, the largest number that can be exactly represented by double.
79 shouldBe("new MouseEvent('eventType', { " + attr + ": 9007199254740991 })." + attr, "-1"); 107 shouldBe("new MouseEvent('eventType', { " + attr + ": 9007199254740991 })." + attr, MAX_CLIENT_SIZE);
80 // 2^{64}-1 108 // 2^{64}-1
81 shouldBe("new MouseEvent('eventType', { " + attr + ": 18446744073709551615 } )." + attr, "0"); 109 shouldBe("new MouseEvent('eventType', { " + attr + ": 18446744073709551615 } )." + attr, MAX_CLIENT_SIZE);
82 shouldBe("new MouseEvent('eventType', { " + attr + ": 123.45 })." + attr, "1 23"); 110 shouldBe("new MouseEvent('eventType', { " + attr + ": 123.45 })." + attr, "1 23");
83 shouldBe("new MouseEvent('eventType', { " + attr + ": NaN })." + attr, "0"); 111 shouldThrow("new MouseEvent('eventType', { " + attr + ": NaN })." + attr);
84 112
85 // Non-numeric values. 113 // Non-numeric values.
86 shouldBe("new MouseEvent('eventType', { " + attr + ": undefined })." + attr, "0"); 114 shouldBe("new MouseEvent('eventType', { " + attr + ": undefined })." + attr, "0");
87 shouldBe("new MouseEvent('eventType', { " + attr + ": null })." + attr, "0") ; 115 shouldBe("new MouseEvent('eventType', { " + attr + ": null })." + attr, "0") ;
88 shouldBe("new MouseEvent('eventType', { " + attr + ": '' })." + attr, "0"); 116 shouldBe("new MouseEvent('eventType', { " + attr + ": '' })." + attr, "0");
89 shouldBe("new MouseEvent('eventType', { " + attr + ": '12345' })." + attr, " 12345"); 117 shouldBe("new MouseEvent('eventType', { " + attr + ": '12345' })." + attr, " 12345");
90 shouldBe("new MouseEvent('eventType', { " + attr + ": '12345a' })." + attr, "0"); 118 shouldThrow("new MouseEvent('eventType', { " + attr + ": '12345a' })." + att r);
91 shouldBe("new MouseEvent('eventType', { " + attr + ": 'abc' })." + attr, "0" ); 119 shouldThrow("new MouseEvent('eventType', { " + attr + ": 'abc' })." + attr);
92 shouldBe("new MouseEvent('eventType', { " + attr + ": [] })." + attr, "0"); 120 shouldBe("new MouseEvent('eventType', { " + attr + ": [] })." + attr, "0");
93 shouldBe("new MouseEvent('eventType', { " + attr + ": [12345] })." + attr, " 12345"); 121 shouldBe("new MouseEvent('eventType', { " + attr + ": [12345] })." + attr, " 12345");
94 shouldBe("new MouseEvent('eventType', { " + attr + ": [12345, 67890] })." + attr, "0"); 122 shouldThrow("new MouseEvent('eventType', { " + attr + ": [12345, 67890] })." + attr);
95 shouldBe("new MouseEvent('eventType', { " + attr + ": {} })." + attr, "0"); 123 shouldThrow("new MouseEvent('eventType', { " + attr + ": {} })." + attr);
96 shouldBe("new MouseEvent('eventType', { " + attr + ": {moemoe: 12345} })." + attr, "0"); 124 shouldThrow("new MouseEvent('eventType', { " + attr + ": {moemoe: 12345} }). " + attr);
97 shouldBe("new MouseEvent('eventType', { " + attr + ": {valueOf: function () { return 12345; }} })." + attr, "12345"); 125 shouldBe("new MouseEvent('eventType', { " + attr + ": {valueOf: function () { return 12345; }} })." + attr, "12345");
98 }); 126 });
99 127
100 // ctrlKey, altKey, shiftKey and metaKey are passed. 128 // ctrlKey, altKey, shiftKey and metaKey are passed.
101 ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach(function (attr) { 129 ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach(function (attr) {
102 shouldBe("new MouseEvent('eventType', { " + attr + ": false })." + attr, "fa lse"); 130 shouldBe("new MouseEvent('eventType', { " + attr + ": false })." + attr, "fa lse");
103 shouldBe("new MouseEvent('eventType', { " + attr + ": true })." + attr, "tru e"); 131 shouldBe("new MouseEvent('eventType', { " + attr + ": true })." + attr, "tru e");
104 }); 132 });
105 133
106 // all modifiers are passed correctly. 134 // all modifiers are passed correctly.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 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"); 240 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");
213 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"); 241 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");
214 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"); 242 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");
215 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"); 243 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");
216 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"); 244 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");
217 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"); 245 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");
218 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"); 246 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");
219 </script> 247 </script>
220 </body> 248 </body>
221 </html> 249 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698