81 lines
3.3 KiB
HTML
81 lines
3.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="../../../resources/js-test-pre.js"></script>
|
|
</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("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("clientX"))
|
|
shouldBe("createdTouch.clientX", "init.clientX");
|
|
else
|
|
shouldBe("createdTouch.clientX", "0");
|
|
if (init.hasOwnProperty("clientY"))
|
|
shouldBe("createdTouch.clientY", "init.clientY");
|
|
else
|
|
shouldBe("createdTouch.clientY", "0");
|
|
if (init.hasOwnProperty("radiusX"))
|
|
shouldBe("createdTouch.radiusX", "init.radiusX");
|
|
else
|
|
shouldBe("createdTouch.radiusX", "0");
|
|
if (init.hasOwnProperty("radiusY"))
|
|
shouldBe("createdTouch.radiusY", "init.radiusY");
|
|
else
|
|
shouldBe("createdTouch.radiusY", "0");
|
|
if (init.hasOwnProperty("rotationAngle"))
|
|
shouldBe("createdTouch.rotationAngle", "init.rotationAngle");
|
|
else
|
|
shouldBe("createdTouch.rotationAngle", "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, radiusX: 8, radiusY: 9, rotationAngle: 10 })");
|
|
validateTouch(touch, { identifier: 1, target: document.body, clientX: 1, clientY: 2, screenX: 3, screenY: 4, pageX: 5, pageY: 6, force: 7, radiusX: 8, radiusY: 9, rotationAngle: 10 });
|
|
|
|
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, radiusX: 8.5, radiusY: 9.5, rotationAngle: 10.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, radiusX: 8.5, radiusY: 9.5, rotationAngle: 10.5 });
|
|
</script>
|
|
<script src="../../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|