1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<html>
<head>
<script src="../resources/js-test.js"></script>
<style>
#div0 { position: absolute; left: 50px; top: 50px; width: 300px; height: 300px; box-sizing: border-box; }
#div1 { position: absolute; left: 50px; top: 50px; width: 200px; height: 100px; box-sizing: border-box; }
#div2 { position: absolute; left: 50px; top: 150px; width: 200px; height: 100px; padding: 10px; box-sizing: border-box; }
</style>
</head>
<body onload="runTests()">
<div id=div0>
<div id=div1></div>
<div id=div2></div>
</div>
<p id='description'></p>
<div id='console'></div>
<script>
function testRoundTouch(x, y, radius)
{
var x = x - radius;
var y = y - radius;
var width = radius * 2;
var height = radius * 2;
var zoomableRect = internals.bestZoomableAreaForTouchPoint(x, y, width, height, document);
return zoomableRect;
}
function testDirectTouches()
{
zoomableArea = testRoundTouch(130, 130, 10);
shouldEvaluateTo('zoomableArea.top', 100);
shouldEvaluateTo('zoomableArea.left', 100);
shouldEvaluateTo('zoomableArea.width', 200);
shouldEvaluateTo('zoomableArea.height', 100);
zoomableArea = testRoundTouch(130, 230, 10);
shouldEvaluateTo('zoomableArea.top', 210);
shouldEvaluateTo('zoomableArea.left', 110);
shouldEvaluateTo('zoomableArea.width', 180);
shouldEvaluateTo('zoomableArea.height', 80);
zoomableArea = testRoundTouch(120, 220, 20);
shouldEvaluateTo('zoomableArea.top', 200);
shouldEvaluateTo('zoomableArea.left', 100);
shouldEvaluateTo('zoomableArea.width', 200);
shouldEvaluateTo('zoomableArea.height', 100);
zoomableArea = testRoundTouch(80, 100, 20);
shouldEvaluateTo('zoomableArea.top', 50);
shouldEvaluateTo('zoomableArea.left', 50);
shouldEvaluateTo('zoomableArea.width', 300);
shouldEvaluateTo('zoomableArea.height',300);
}
function runTests()
{
if (window.testRunner && window.internals && internals.bestZoomableAreaForTouchPoint) {
description('Test basic cases of tap-to-zoom mechanics.');
testRunner.dumpAsText();
testRunner.waitUntilDone();
testDirectTouches();
isSuccessfullyParsed();
testRunner.notifyDone();
}
}
</script>
</body>
</html>
|