blob: 1ef225aad346e7728c9ea9c9e85535b66aa2b415 [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.
This template will generate an asynchronous style test by using the js-test-post-function script.
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.createTouchList and window.TouchEvent APIs.");
// To use TouchEvents use createEvent and initTouchEvent.
shouldBeTrue("'TouchEvent' in window");
shouldBeFalse("window.propertyIsEnumerable('TouchEvent')");
shouldThrow('new TouchEvent()');
shouldBeTrue('"createTouchList" in document');
// Test createTouchList with no arguments.
var touchList = document.createTouchList();
shouldBeNonNull("touchList");
shouldBe("touchList.length", "0");
shouldBeNull("touchList.item(0)");
shouldBeNull("touchList.item(1)");
// Test createTouchList with Touch objects as arguments.
try {
var t = document.createTouch(window, document.body, 12341, 60, 65, 100, 105);
var t2 = document.createTouch(window, document.body, 12342, 50, 55, 115, 120);
var tl = document.createTouchList(t, t2);
var evt = document.createEvent("TouchEvent");
evt.initTouchEvent("touchstart", false, false, window, 0, 0, 0, 0, 0, true, false, false, false, tl, tl, tl, 1, 0);
document.body.addEventListener("touchstart", function handleTouchStart(ev) {
ts = ev;
shouldBe("ts.touches.length", "2");
shouldBe("ts.touches[0].identifier", "12341");
shouldBe("ts.touches[0].clientX", "60");
shouldBe("ts.touches[1].screenY", "120");
shouldBe("ts.ctrlKey", "true");
});
document.body.dispatchEvent(evt);
} catch(e) {
testFailed("An exception was thrown: " + e.message);
}
// Test createTouchList with invalid arguments which throws exceptions.
shouldThrow("var tl = document.createTouchList(1, 2)");
successfullyParsed = true;
isSuccessfullyParsed();
</script>
</body>
</html>