| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../../../resources/js-test.js"></script> |
| <!-- |
| Touch tests that involve the ontouchstart, ontouchmove, ontouchend or ontouchcancel callbacks |
| should be written in an asynchronous fashion so they can be run on mobile platforms like Android. |
| You will need to invoke isSuccessfullyParsed() in your test script when the test completes. |
| --> |
| </head> |
| <body> |
| <p id="description"></p> |
| <div id="console"></div> |
| <script> |
| description("This tests support for the document.createTouch API."); |
| |
| shouldBeTrue('"createTouch" in document'); |
| |
| var box = document.createElement("div"); |
| box.id = "box"; |
| box.style.width = "100px"; |
| box.style.height = "100px"; |
| document.body.appendChild(box); |
| |
| var target = document.getElementById("box"); |
| var touch = document.createTouch(window, target, 1, 100, 101, 102, 103, 5, 3, 10, 10); |
| shouldBeNonNull("touch"); |
| shouldBe("touch.target", "box"); |
| shouldBe("touch.identifier", "1"); |
| shouldBe("touch.pageX", "100"); |
| shouldBe("touch.pageY", "101"); |
| shouldBe("touch.screenX", "102"); |
| shouldBe("touch.screenY", "103"); |
| shouldBe("touch.radiusX", "5"); |
| shouldBe("touch.radiusY", "3"); |
| shouldBe("touch.rotationAngle", "10"); |
| shouldBe("touch.force", "10"); |
| |
| shouldThrow("document.createTouch()", '"TypeError: Failed to execute \'createTouch\' on \'Document\': 7 arguments required, but only 0 present."'); |
| |
| var incompleteTouch = document.createTouch(window, target, 1, 100, 101, 102, 103); |
| shouldBeNonNull("incompleteTouch"); |
| shouldBeNonNull("incompleteTouch.target"); |
| shouldBe("incompleteTouch.identifier", "1"); |
| shouldBe("incompleteTouch.pageX", "100"); |
| shouldBe("incompleteTouch.pageY", "101"); |
| shouldBe("incompleteTouch.screenX", "102"); |
| shouldBe("incompleteTouch.screenY", "103"); |
| shouldBe("incompleteTouch.radiusX", "0"); |
| shouldBe("incompleteTouch.radiusY", "0"); |
| shouldBe("incompleteTouch.rotationAngle", "0"); |
| shouldBe("incompleteTouch.force", "0"); |
| |
| shouldThrow("document.createTouch(window, target, 1, 'b', 101, 102, 103, 0, 0, 0, 0)", '"TypeError: Failed to execute \'createTouch\' on \'Document\': The provided double value is non-finite."'); |
| |
| // Try invoking with incorrect parameter types. |
| var badParamsTouch = document.createTouch(function(x) { return x; }, 12, 'a', 0, 0, 0, 104, function(x) { return x; }, 'a', 'b', 'c'); |
| shouldBeNonNull("badParamsTouch"); |
| shouldBeNull("badParamsTouch.target"); |
| shouldBe("badParamsTouch.identifier", "0"); |
| shouldBe("badParamsTouch.pageX", "0"); |
| shouldBe("badParamsTouch.pageY", "0"); |
| shouldBe("badParamsTouch.screenX", "0"); |
| shouldBe("badParamsTouch.screenY", "104"); |
| shouldBe("badParamsTouch.radiusX", "0"); |
| shouldBe("badParamsTouch.radiusY", "0"); |
| shouldBe("badParamsTouch.rotationAngle", "0"); |
| shouldBe("badParamsTouch.force", "0"); |
| |
| // Should not crash when invoked on a detached Document. |
| var detachedTouch; |
| shouldBeNonNull("detachedTouch = document.implementation.createDocument('a', 'b').createTouch(window, null, 0, 0, 0, 0, 0)"); |
| shouldBeNull("detachedTouch.target"); |
| shouldBe("detachedTouch.identifier", "0"); |
| shouldBe("detachedTouch.pageX", "0"); |
| shouldBe("detachedTouch.pageY", "0"); |
| shouldBe("detachedTouch.screenX", "0"); |
| shouldBe("detachedTouch.screenY", "0"); |
| shouldBe("detachedTouch.radiusX", "0"); |
| shouldBe("detachedTouch.radiusY", "0"); |
| shouldBe("detachedTouch.rotationAngle", "0"); |
| shouldBe("detachedTouch.force", "0"); |
| |
| isSuccessfullyParsed(); |
| |
| </script> |
| </body> |
| </html> |