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