OLD | NEW |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
5 <!-- | 5 <!-- |
6 Touch tests that involve the ontouchstart, ontouchmove, ontouchend or ontouchc
ancel callbacks | 6 Touch tests that involve the ontouchstart, ontouchmove, ontouchend or ontouchc
ancel callbacks |
7 should be written in an asynchronous fashion so they can be run on mobile plat
forms like Android. | 7 should be written in an asynchronous fashion so they can be run on mobile plat
forms like Android. |
8 You will need to invoke isSuccessfullyParsed() in your test script when the te
st completes. | 8 You will need to invoke isSuccessfullyParsed() in your test script when the te
st completes. |
9 --> | 9 --> |
10 </head> | 10 </head> |
11 <body> | 11 <body> |
12 <p id="description"></p> | 12 <p id="description"></p> |
13 <div id="console"></div> | 13 <div id="console"></div> |
14 <script src="script-tests/document-create-touch.js"></script> | 14 <script> |
| 15 description("This tests support for the document.createTouch API."); |
| 16 |
| 17 shouldBeTrue('"createTouch" in document'); |
| 18 |
| 19 var box = document.createElement("div"); |
| 20 box.id = "box"; |
| 21 box.style.width = "100px"; |
| 22 box.style.height = "100px"; |
| 23 document.body.appendChild(box); |
| 24 |
| 25 var target = document.getElementById("box"); |
| 26 var touch = document.createTouch(window, target, 1, 100, 101, 102, 103, 5, 3, 10
, 10); |
| 27 shouldBeNonNull("touch"); |
| 28 shouldBe("touch.target", "box"); |
| 29 shouldBe("touch.identifier", "1"); |
| 30 shouldBe("touch.pageX", "100"); |
| 31 shouldBe("touch.pageY", "101"); |
| 32 shouldBe("touch.screenX", "102"); |
| 33 shouldBe("touch.screenY", "103"); |
| 34 shouldBe("touch.radiusX", "5"); |
| 35 shouldBe("touch.radiusY", "3"); |
| 36 shouldBe("touch.rotationAngle", "10"); |
| 37 shouldBe("touch.force", "10"); |
| 38 shouldBe("touch.webkitRadiusX", "5"); |
| 39 shouldBe("touch.webkitRadiusY", "3"); |
| 40 shouldBe("touch.webkitRotationAngle", "10"); |
| 41 shouldBe("touch.webkitForce", "10"); |
| 42 |
| 43 var emptyTouch = document.createTouch(); |
| 44 shouldBeNonNull("emptyTouch"); |
| 45 shouldBeNull("emptyTouch.target"); |
| 46 shouldBe("emptyTouch.identifier", "0"); |
| 47 shouldBe("emptyTouch.pageX", "0"); |
| 48 shouldBe("emptyTouch.pageY", "0"); |
| 49 shouldBe("emptyTouch.screenX", "0"); |
| 50 shouldBe("emptyTouch.screenY", "0"); |
| 51 shouldBe("emptyTouch.radiusX", "0"); |
| 52 shouldBe("emptyTouch.radiusY", "0"); |
| 53 shouldBe("emptyTouch.rotationAngle", "0"); |
| 54 shouldBe("emptyTouch.force", "0"); |
| 55 shouldBe("emptyTouch.webkitRadiusX", "0"); |
| 56 shouldBe("emptyTouch.webkitRadiusY", "0"); |
| 57 shouldBe("emptyTouch.webkitRotationAngle", "0"); |
| 58 shouldBe("emptyTouch.webkitForce", "0"); |
| 59 |
| 60 // Try invoking with incorrect parameter types. |
| 61 var badParamsTouch = document.createTouch(function(x) { return x; }, 12, 'a', 'b
', 'c', function(x) { return x; }, 104, 'a', 'b', 'c', 'd'); |
| 62 shouldBeNonNull("badParamsTouch"); |
| 63 shouldBeNull("badParamsTouch.target"); |
| 64 shouldBe("badParamsTouch.identifier", "0"); |
| 65 shouldBe("badParamsTouch.pageX", "0"); |
| 66 shouldBe("badParamsTouch.pageY", "0"); |
| 67 shouldBe("badParamsTouch.screenX", "0"); |
| 68 shouldBe("badParamsTouch.screenY", "104"); |
| 69 shouldBe("badParamsTouch.radiusX", "0"); |
| 70 shouldBe("badParamsTouch.radiusY", "0"); |
| 71 shouldBe("badParamsTouch.rotationAngle", "0"); |
| 72 shouldBe("badParamsTouch.force", "0"); |
| 73 shouldBe("badParamsTouch.webkitRadiusX", "0"); |
| 74 shouldBe("badParamsTouch.webkitRadiusY", "0"); |
| 75 shouldBe("badParamsTouch.webkitRotationAngle", "0"); |
| 76 shouldBe("badParamsTouch.webkitForce", "0"); |
| 77 |
| 78 // Should not crash when invoked on a detached Document. |
| 79 var detachedTouch; |
| 80 shouldBeNonNull("detachedTouch = document.implementation.createDocument('a', 'b'
).createTouch()"); |
| 81 shouldBeNull("detachedTouch.target"); |
| 82 shouldBe("detachedTouch.identifier", "0"); |
| 83 shouldBe("detachedTouch.pageX", "0"); |
| 84 shouldBe("detachedTouch.pageY", "0"); |
| 85 shouldBe("detachedTouch.screenX", "0"); |
| 86 shouldBe("detachedTouch.screenY", "0"); |
| 87 shouldBe("detachedTouch.radiusX", "0"); |
| 88 shouldBe("detachedTouch.radiusY", "0"); |
| 89 shouldBe("detachedTouch.rotationAngle", "0"); |
| 90 shouldBe("detachedTouch.force", "0"); |
| 91 shouldBe("detachedTouch.webkitRadiusX", "0"); |
| 92 shouldBe("detachedTouch.webkitRadiusY", "0"); |
| 93 shouldBe("detachedTouch.webkitRotationAngle", "0"); |
| 94 shouldBe("detachedTouch.webkitForce", "0"); |
| 95 |
| 96 isSuccessfullyParsed(); |
| 97 </script> |
15 </body> | 98 </body> |
16 </html> | 99 </html> |
OLD | NEW |