Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / script-tests / document-create-touch-list.js
blobeb0de44785e5d75216c61ba7cd36514659e9e7bd
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.
14 try {
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) {
23 ts = 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");
32 });
34 document.body.dispatchEvent(evt);
35 } catch(e) {
36 testFailed("An exception was thrown: " + e.message);
39 // Test createTouchList with invalid arguments which throws exceptions.
40 try {
41 var tl = document.createTouchList(1, 2);
42 } catch(e) {
43 testPassed("An exception was thrown: " + e.message);
45 isSuccessfullyParsed();