OLD | NEW |
| (Empty) |
1 description("This tests support for the document.createTouch API."); | |
2 | |
3 shouldBeTrue('"createTouch" in document'); | |
4 | |
5 var box = document.createElement("div"); | |
6 box.id = "box"; | |
7 box.style.width = "100px"; | |
8 box.style.height = "100px"; | |
9 document.body.appendChild(box); | |
10 | |
11 var target = document.getElementById("box"); | |
12 var touch = document.createTouch(window, target, 1, 100, 101, 102, 103, 5, 3, 10
, 10); | |
13 shouldBeNonNull("touch"); | |
14 shouldBe("touch.target", "box"); | |
15 shouldBe("touch.identifier", "1"); | |
16 shouldBe("touch.pageX", "100"); | |
17 shouldBe("touch.pageY", "101"); | |
18 shouldBe("touch.screenX", "102"); | |
19 shouldBe("touch.screenY", "103"); | |
20 shouldBe("touch.radiusX", "5"); | |
21 shouldBe("touch.radiusY", "3"); | |
22 shouldBe("touch.force", "10"); | |
23 shouldBe("touch.webkitRadiusX", "5"); | |
24 shouldBe("touch.webkitRadiusY", "3"); | |
25 shouldBe("touch.webkitRotationAngle", "10"); | |
26 shouldBe("touch.webkitForce", "10"); | |
27 | |
28 var emptyTouch = document.createTouch(); | |
29 shouldBeNonNull("emptyTouch"); | |
30 shouldBeNull("emptyTouch.target"); | |
31 shouldBe("emptyTouch.identifier", "0"); | |
32 shouldBe("emptyTouch.pageX", "0"); | |
33 shouldBe("emptyTouch.pageY", "0"); | |
34 shouldBe("emptyTouch.screenX", "0"); | |
35 shouldBe("emptyTouch.screenY", "0"); | |
36 shouldBe("emptyTouch.radiusX", "0"); | |
37 shouldBe("emptyTouch.radiusY", "0"); | |
38 shouldBeNaN("emptyTouch.force"); | |
39 shouldBe("emptyTouch.webkitRadiusX", "0"); | |
40 shouldBe("emptyTouch.webkitRadiusY", "0"); | |
41 shouldBeNaN("emptyTouch.webkitRotationAngle"); | |
42 shouldBeNaN("emptyTouch.webkitForce"); | |
43 | |
44 // Try invoking with incorrect parameter types. | |
45 var badParamsTouch = document.createTouch(function(x) { return x; }, 12, 'a', 'b
', 'c', function(x) { return x; }, 104, 'a', 'b', 'c', 'd'); | |
46 shouldBeNonNull("badParamsTouch"); | |
47 shouldBeNull("badParamsTouch.target"); | |
48 shouldBe("badParamsTouch.identifier", "0"); | |
49 shouldBe("badParamsTouch.pageX", "0"); | |
50 shouldBe("badParamsTouch.pageY", "0"); | |
51 shouldBe("badParamsTouch.screenX", "0"); | |
52 shouldBe("badParamsTouch.screenY", "104"); | |
53 shouldBe("badParamsTouch.radiusX", "0"); | |
54 shouldBe("badParamsTouch.radiusY", "0"); | |
55 shouldBeNaN("badParamsTouch.force"); | |
56 shouldBe("badParamsTouch.webkitRadiusX", "0"); | |
57 shouldBe("badParamsTouch.webkitRadiusY", "0"); | |
58 shouldBeNaN("badParamsTouch.webkitRotationAngle"); | |
59 shouldBeNaN("badParamsTouch.webkitForce"); | |
60 | |
61 // Should not crash when invoked on a detached Document. | |
62 var detachedTouch; | |
63 shouldBeNonNull("detachedTouch = document.implementation.createDocument('a', 'b'
).createTouch()"); | |
64 shouldBeNull("detachedTouch.target"); | |
65 shouldBe("detachedTouch.identifier", "0"); | |
66 shouldBe("detachedTouch.pageX", "0"); | |
67 shouldBe("detachedTouch.pageY", "0"); | |
68 shouldBe("detachedTouch.screenX", "0"); | |
69 shouldBe("detachedTouch.screenY", "0"); | |
70 shouldBe("detachedTouch.radiusX", "0"); | |
71 shouldBe("detachedTouch.radiusY", "0"); | |
72 shouldBeNaN("detachedTouch.force"); | |
73 shouldBe("detachedTouch.webkitRadiusX", "0"); | |
74 shouldBe("detachedTouch.webkitRadiusY", "0"); | |
75 shouldBeNaN("detachedTouch.webkitRotationAngle"); | |
76 shouldBeNaN("detachedTouch.webkitForce"); | |
77 | |
78 isSuccessfullyParsed(); | |
OLD | NEW |