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