1 description("This tests support for the document.createTouchList API.");
3 shouldBeTrue('"createTouchList" in document');
5 // Test createTouchList with no arguments.
6 var touchList
= document
.createTouchList();
7 shouldBeNonNull("touchList");
8 shouldBe("touchList.length", "0");
9 shouldBeNull("touchList.item(0)");
10 shouldBeNull("touchList.item(1)");
11 shouldThrow("touchList.item()");
13 // Test createTouchList with Touch objects as arguments.
15 var t
= document
.createTouch(window
, document
.body
, 12341, 60, 65, 100, 105);
16 var t2
= document
.createTouch(window
, document
.body
, 12342, 50, 55, 115, 120);
17 var tl
= document
.createTouchList(t
, t2
);
19 var evt
= document
.createEvent("TouchEvent");
20 evt
.initTouchEvent(tl
, tl
, tl
, "touchstart", window
, 0, 0, 0, 0, true, false, false, false);
22 document
.body
.addEventListener("touchstart", function handleTouchStart(ev
) {
24 shouldBeTrue("ts instanceof TouchEvent");
25 shouldBeTrue("ts.touches instanceof TouchList");
26 shouldBe("ts.touches.length", "2");
27 shouldBeTrue("ts.touches[0] instanceof Touch");
28 shouldBe("ts.touches[0].identifier", "12341");
29 shouldBe("ts.touches[0].clientX", "60");
30 shouldBe("ts.touches[1].screenY", "120");
31 shouldBe("ts.ctrlKey", "true");
34 document
.body
.dispatchEvent(evt
);
36 testFailed("An exception was thrown: " + e
.message
);
39 // Test createTouchList with invalid arguments which throws exceptions.
41 var tl
= document
.createTouchList(1, 2);
43 testPassed("An exception was thrown: " + e
.message
);
45 isSuccessfullyParsed();