blob: 2702b7c55e10d192144c6613e5c9c815fd969a90 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
<!--
Touch tests that involve the ontouchstart, ontouchmove, ontouchend or ontouchcancel callbacks
should be written in an asynchronous fashion so they can be run on mobile platforms like Android.
You will need to invoke isSuccessfullyParsed() in your test script when the test completes.
-->
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests support for the document.createTouch API.");
shouldBeTrue('"createTouch" in document');
var box = document.createElement("div");
box.id = "box";
box.style.width = "100px";
box.style.height = "100px";
document.body.appendChild(box);
var target = document.getElementById("box");
var touch = document.createTouch(window, target, 1, 100, 101, 102, 103, 5, 3, 10, 10);
shouldBeNonNull("touch");
shouldBe("touch.target", "box");
shouldBe("touch.identifier", "1");
shouldBe("touch.pageX", "100");
shouldBe("touch.pageY", "101");
shouldBe("touch.screenX", "102");
shouldBe("touch.screenY", "103");
shouldBe("touch.webkitRadiusX", "5");
shouldBe("touch.webkitRadiusY", "3");
shouldBe("touch.webkitRotationAngle", "10");
shouldBe("touch.webkitForce", "10");
var emptyTouch = document.createTouch();
shouldBeNonNull("emptyTouch");
shouldBeNull("emptyTouch.target");
shouldBe("emptyTouch.identifier", "0");
shouldBe("emptyTouch.pageX", "0");
shouldBe("emptyTouch.pageY", "0");
shouldBe("emptyTouch.screenX", "0");
shouldBe("emptyTouch.screenY", "0");
shouldBe("emptyTouch.webkitRadiusX", "0");
shouldBe("emptyTouch.webkitRadiusY", "0");
shouldBeNaN("emptyTouch.webkitRotationAngle");
shouldBeNaN("emptyTouch.webkitForce");
// Try invoking with incorrect parameter types.
shouldThrow(function() {
document.createTouch(function(x) { return x; }, 12, 'a', 'b', 'c', function(x) { return x; }, 104, 'a', 'b', 'c', 'd');
}, "\"TypeError: Argument 1 ('window') to Document.createTouch must be an instance of DOMWindow\"");
isSuccessfullyParsed();
</script>
</body>
</html>