Added: trunk/LayoutTests/fast/events/touch/touch-constructor.html (0 => 206613)
--- trunk/LayoutTests/fast/events/touch/touch-constructor.html (rev 0)
+++ trunk/LayoutTests/fast/events/touch/touch-constructor.html 2016-09-29 21:13:33 UTC (rev 206613)
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description("Test the Touch constructor");
+
+// identifier and target members are required.
+shouldThrowErrorName("new Touch({ })", "TypeError");
+shouldThrowErrorName("new Touch({ identifier: 0 })", "TypeError");
+shouldThrowErrorName("new Touch({ target: document.body })", "TypeError");
+
+// target is not nullable.
+shouldThrowErrorName("new Touch({ identifier: 0, target: null })", "TypeError");
+
+function validateTouch(touch, dictionary)
+{
+ createdTouch = touch;
+ init = dictionary;
+ shouldBe("createdTouch.identifier", "init.identifier");
+ shouldBe("createdTouch.target", "init.target");
+ if (init.hasOwnProperty("screenX"))
+ shouldBe("createdTouch.screenX", "init.screenX");
+ else
+ shouldBe("createdTouch.screenX", "0");
+ if (init.hasOwnProperty("screenX"))
+ shouldBe("createdTouch.screenX", "init.screenX");
+ else
+ shouldBe("createdTouch.screenX", "0");
+ if (init.hasOwnProperty("screenX"))
+ shouldBe("createdTouch.screenX", "init.screenX");
+ else
+ shouldBe("createdTouch.screenX", "0");
+ if (init.hasOwnProperty("screenY"))
+ shouldBe("createdTouch.screenY", "init.screenY");
+ else
+ shouldBe("createdTouch.screenY", "0");
+ if (init.hasOwnProperty("pageX"))
+ shouldBe("createdTouch.pageX", "init.pageX");
+ else
+ shouldBe("createdTouch.pageX", "0");
+ if (init.hasOwnProperty("pageY"))
+ shouldBe("createdTouch.pageY", "init.pageY");
+ else
+ shouldBe("createdTouch.pageY", "0");
+ if (init.hasOwnProperty("force"))
+ shouldBe("createdTouch.force", "init.force");
+ else
+ shouldBe("createdTouch.force", "0");
+}
+
+debug("");
+shouldNotThrow("touch = new Touch({ identifier: 1, target: document.body })");
+validateTouch(touch, { identifier: 1, target: document.body });
+
+debug("");
+shouldNotThrow("touch = new Touch({ identifier: 1, target: document.body, clientX: 1, clientY: 2, screenX: 3, screenY: 4, pageX: 5, pageY: 6, force: 7 })");
+validateTouch(touch, { identifier: 1, target: document.body, clientX: 1, clientY: 2, screenX: 3, screenY: 4, pageX: 5, pageY: 6, force: 7 });
+
+debug("");
+shouldNotThrow("touch = new Touch({ identifier: 1, target: document.body, clientX: 1.5, clientY: 2.5, screenX: 3.5, screenY: 4.5, pageX: 5.5, pageY: 6.5, force: 7.5 })");
+validateTouch(touch, { identifier: 1, target: document.body, clientX: 1.5, clientY: 2.5, screenX: 3.5, screenY: 4.5, pageX: 5.5, pageY: 6.5, force: 7.5 });
+</script>
+<script src=""
+</body>
+</html>