summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/events/touch/script-tests/document-create-touch-list.js
blob: 526badc79b8b2ba0cdc86810986409690f32f62b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
description("This tests support for the document.createTouchList API.");

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(tl, tl, tl, "touchstart", window, 0, 0, 0, 0, true, false, false, false);

    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.
try {
    var tl = document.createTouchList(1, 2);
} catch(e) {
    testFailed("An exception was thrown: " + e.message);
}

successfullyParsed = true;
isSuccessfullyParsed();