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 <script> | 5 <script> |
6 var radiusX; | 6 var radiusX; |
7 var radiusY; | 7 var radiusY; |
8 | 8 |
9 function touchHandler(e) { | 9 function touchHandler(e) { |
10 var touch = e.touches[0]; | 10 var touch = e.touches[0]; |
11 radiusX = touch.webkitRadiusX; | 11 radiusX = touch.webkitRadiusX; |
12 radiusY = touch.webkitRadiusY; | 12 radiusY = touch.webkitRadiusY; |
13 } | 13 } |
14 | 14 |
15 function endTest() | 15 function endTest() |
16 { | 16 { |
17 isSuccessfullyParsed(); | 17 isSuccessfullyParsed(); |
18 testRunner.notifyDone(); | 18 testRunner.notifyDone(); |
19 } | 19 } |
20 | 20 |
21 function sendTouchStart(x, y, radiusX, radiusY) | 21 function sendTouchStart(x, y, radiusX, radiusY) |
22 { | 22 { |
23 eventSender.clearTouchPoints(); | 23 eventSender.clearTouchPoints(); |
24 eventSender.addTouchPoint(x, y); | 24 eventSender.addTouchPoint(x, y, radiusX, radiusY); |
25 if (eventSender.setTouchPointRadius) | |
26 eventSender.setTouchPointRadius(0, radiusX, radiusY, false); | |
27 eventSender.touchStart(); | 25 eventSender.touchStart(); |
28 } | 26 } |
29 | 27 |
30 function runTest() { | 28 function runTest() { |
31 if (window.testRunner) | 29 if (window.testRunner) |
32 testRunner.waitUntilDone(); | 30 testRunner.waitUntilDone(); |
33 | 31 |
34 if (window.eventSender) { | 32 if (window.eventSender) { |
35 description("This tests makes sure the touch event's radius " | 33 description("This tests makes sure the touch event's radius " |
36 + "property is scaled to account for browser zoom."); | 34 + "property is scaled to account for browser zoom."); |
37 | 35 |
38 document.body.addEventListener("touchstart", touchHandler); | 36 document.body.addEventListener("touchstart", touchHandler); |
39 | 37 |
40 debug("===Initial Zoom==="); | 38 debug("===Initial Zoom==="); |
41 sendTouchStart(100, 100, 4, 10); | 39 sendTouchStart(100, 100, 4, 10); |
42 if (eventSender.setTouchPointRadius) { | 40 shouldBe("radiusX", "4"); |
43 shouldBe("radiusX", "4"); | 41 shouldBe("radiusY", "10"); |
44 shouldBe("radiusY", "10"); | |
45 } | |
46 | 42 |
47 window.internals.setZoomFactor(2.0); | 43 window.internals.setZoomFactor(2.0); |
48 | 44 |
49 debug("===Zoom 2X==="); | 45 debug("===Zoom 2X==="); |
50 sendTouchStart(100, 100, 4, 10); | 46 sendTouchStart(100, 100, 4, 10); |
51 if (eventSender.setTouchPointRadius) { | 47 shouldBe("radiusX", "2"); |
52 shouldBe("radiusX", "2"); | 48 shouldBe("radiusY", "5"); |
53 shouldBe("radiusY", "5"); | |
54 } | |
55 | 49 |
56 window.internals.setZoomFactor(0.5); | 50 window.internals.setZoomFactor(0.5); |
57 | 51 |
58 debug("===Zoom 0.5X==="); | 52 debug("===Zoom 0.5X==="); |
59 sendTouchStart(100, 100, 4, 10); | 53 sendTouchStart(100, 100, 4, 10); |
60 if (eventSender.setTouchPointRadius) { | 54 shouldBe("radiusX", "8"); |
61 shouldBe("radiusX", "8"); | 55 shouldBe("radiusY", "20"); |
62 shouldBe("radiusY", "20"); | |
63 } | |
64 | 56 |
65 | 57 |
66 endTest(); | 58 endTest(); |
67 } else { | 59 } else { |
68 debug("This test requires DumpRenderTree. Tap on the blue rect to l
og.") | 60 debug("This test requires DumpRenderTree. Tap on the blue rect to l
og.") |
69 } | 61 } |
70 } | 62 } |
71 </script> | 63 </script> |
72 </head> | 64 </head> |
73 | 65 |
74 <body onload="runTest()"> | 66 <body onload="runTest()"> |
75 <div id="console"></div> | 67 <div id="console"></div> |
76 </body> | 68 </body> |
77 </html> | 69 </html> |
OLD | NEW |