Index: third_party/WebKit/LayoutTests/fast/events/constructors/mouse-event-constructor.html |
diff --git a/third_party/WebKit/LayoutTests/fast/events/constructors/mouse-event-constructor.html b/third_party/WebKit/LayoutTests/fast/events/constructors/mouse-event-constructor.html |
index 6e5b2d7e9e1ec03adff29077b11c78bdef8f2c01..e35a2435731c41a5f1d371d8e4a00c1c2220e8df 100644 |
--- a/third_party/WebKit/LayoutTests/fast/events/constructors/mouse-event-constructor.html |
+++ b/third_party/WebKit/LayoutTests/fast/events/constructors/mouse-event-constructor.html |
@@ -61,39 +61,67 @@ shouldBe("new MouseEvent('eventType', { get view() { return window; } }).view", |
shouldThrow("new MouseEvent('eventType', { get view() { return 123; } }).view"); |
shouldThrow("new MouseEvent('eventType', { get view() { throw 'MouseEvent Error'; } })"); |
-// Max/min for client positions (LayoutUnit max/min). |
+// detail is passed. |
+// numbers within the long range. |
+shouldBe("new MouseEvent('eventType', { detail: 0 }).detail", "0"); |
+shouldBe("new MouseEvent('eventType', { detail: 2147483647 }).detail", "2147483647"); |
+shouldBe("new MouseEvent('eventType', { detail: -1 }).detail", "-1"); |
+shouldBe("new MouseEvent('eventType', { detail: -2147483648 }).detail", "-2147483648"); |
+// numbers out of the long range. |
+shouldBe("new MouseEvent('eventType', { detail: 4294967295 }).detail", "-1"); |
+// 2^{53}-1, the largest number that can be exactly represented by double. |
+shouldBe("new MouseEvent('eventType', { detail: 9007199254740991 }).detail", "-1"); |
+// 2^{64}-1 |
+shouldBe("new MouseEvent('eventType', { detail: 18446744073709551615 }).detail", "0"); |
+shouldBe("new MouseEvent('eventType', { detail: 123.45 }).detail", "123"); |
+shouldBe("new MouseEvent('eventType', { detail: NaN }).detail", "0"); |
+// Non-numeric values. |
+shouldBe("new MouseEvent('eventType', { detail: undefined }).detail", "0"); |
+shouldBe("new MouseEvent('eventType', { detail: null }).detail", "0"); |
+shouldBe("new MouseEvent('eventType', { detail: '' }).detail", "0"); |
+shouldBe("new MouseEvent('eventType', { detail: '12345' }).detail", "12345"); |
+shouldBe("new MouseEvent('eventType', { detail: '12345a' }).detail", "0"); |
+shouldBe("new MouseEvent('eventType', { detail: 'abc' }).detail", "0"); |
+shouldBe("new MouseEvent('eventType', { detail: [] }).detail", "0"); |
+shouldBe("new MouseEvent('eventType', { detail: [12345] }).detail", "12345"); |
+shouldBe("new MouseEvent('eventType', { detail: [12345, 67890] }).detail", "0"); |
+shouldBe("new MouseEvent('eventType', { detail: {} }).detail", "0"); |
+shouldBe("new MouseEvent('eventType', { detail: {moemoe: 12345} }).detail", "0"); |
+shouldBe("new MouseEvent('eventType', { detail: {valueOf: function () { return 12345; }} }).detail", "12345"); |
+ |
+// Max/min for screen/client coordinates (LayoutUnit max/min). |
var MAX_CLIENT_SIZE = "33554431"; |
var MIN_CLIENT_SIZE = "-33554432"; |
-// detail, screenX, screenY, clientX and clientY are passed. |
-["detail", "screenX", "screenY", "clientX", "clientY"].forEach(function (attr) { |
+// screenX, screenY, clientX and clientY are passed. |
+["screenX", "screenY", "clientX", "clientY"].forEach(function (attr) { |
// numbers within the long range. |
shouldBe("new MouseEvent('eventType', { " + attr + ": 0 })." + attr, "0"); |
- shouldBe("new MouseEvent('eventType', { " + attr + ": 2147483647 })." + attr, attr == "clientX" || attr == "clientY" ? MAX_CLIENT_SIZE : "2147483647"); |
+ shouldBe("new MouseEvent('eventType', { " + attr + ": 2147483647 })." + attr, MAX_CLIENT_SIZE); |
shouldBe("new MouseEvent('eventType', { " + attr + ": -1 })." + attr, "-1"); |
- shouldBe("new MouseEvent('eventType', { " + attr + ": -2147483648 })." + attr, attr == "clientX" || attr == "clientY" ? MIN_CLIENT_SIZE : "-2147483648"); |
+ shouldBe("new MouseEvent('eventType', { " + attr + ": -2147483648 })." + attr, MIN_CLIENT_SIZE); |
// numbers out of the long range. |
- shouldBe("new MouseEvent('eventType', { " + attr + ": 4294967295 })." + attr, "-1"); |
+ shouldBe("new MouseEvent('eventType', { " + attr + ": 4294967295 })." + attr, MAX_CLIENT_SIZE); |
// 2^{53}-1, the largest number that can be exactly represented by double. |
- shouldBe("new MouseEvent('eventType', { " + attr + ": 9007199254740991 })." + attr, "-1"); |
+ shouldBe("new MouseEvent('eventType', { " + attr + ": 9007199254740991 })." + attr, MAX_CLIENT_SIZE); |
// 2^{64}-1 |
- shouldBe("new MouseEvent('eventType', { " + attr + ": 18446744073709551615 })." + attr, "0"); |
+ shouldBe("new MouseEvent('eventType', { " + attr + ": 18446744073709551615 })." + attr, MAX_CLIENT_SIZE); |
shouldBe("new MouseEvent('eventType', { " + attr + ": 123.45 })." + attr, "123"); |
- shouldBe("new MouseEvent('eventType', { " + attr + ": NaN })." + attr, "0"); |
+ shouldThrow("new MouseEvent('eventType', { " + attr + ": NaN })." + attr); |
// Non-numeric values. |
shouldBe("new MouseEvent('eventType', { " + attr + ": undefined })." + attr, "0"); |
shouldBe("new MouseEvent('eventType', { " + attr + ": null })." + attr, "0"); |
shouldBe("new MouseEvent('eventType', { " + attr + ": '' })." + attr, "0"); |
shouldBe("new MouseEvent('eventType', { " + attr + ": '12345' })." + attr, "12345"); |
- shouldBe("new MouseEvent('eventType', { " + attr + ": '12345a' })." + attr, "0"); |
- shouldBe("new MouseEvent('eventType', { " + attr + ": 'abc' })." + attr, "0"); |
+ shouldThrow("new MouseEvent('eventType', { " + attr + ": '12345a' })." + attr); |
+ shouldThrow("new MouseEvent('eventType', { " + attr + ": 'abc' })." + attr); |
shouldBe("new MouseEvent('eventType', { " + attr + ": [] })." + attr, "0"); |
shouldBe("new MouseEvent('eventType', { " + attr + ": [12345] })." + attr, "12345"); |
- shouldBe("new MouseEvent('eventType', { " + attr + ": [12345, 67890] })." + attr, "0"); |
- shouldBe("new MouseEvent('eventType', { " + attr + ": {} })." + attr, "0"); |
- shouldBe("new MouseEvent('eventType', { " + attr + ": {moemoe: 12345} })." + attr, "0"); |
+ shouldThrow("new MouseEvent('eventType', { " + attr + ": [12345, 67890] })." + attr); |
+ shouldThrow("new MouseEvent('eventType', { " + attr + ": {} })." + attr); |
+ shouldThrow("new MouseEvent('eventType', { " + attr + ": {moemoe: 12345} })." + attr); |
shouldBe("new MouseEvent('eventType', { " + attr + ": {valueOf: function () { return 12345; }} })." + attr, "12345"); |
}); |