8ca8316a2578d6ca51787c3bd824b7fa56a09d35
[WebKit-https.git] / LayoutTests / touchadjustment / plugin.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <title>Touch Adjustment : Plugin boundary - bug ????</title>
5     <script src="../resources/js-test-pre.js"></script>
6     <script src="resources/touchadjustment.js"></script>
7     <style>
8         #plugin {
9           height: 160px;
10           margin-left: 10px;
11           margin-top: 10px;
12           width: 320px;
13         }
14         #toolbar {
15           -webkit-box-align: stretch;
16           -webkit-box-orient: horizontal;
17           display: -webkit-box;
18           margin-left: 10px;
19         }
20     </style>
21 </head>
22 <body>
23
24 <div id=sandbox>
25     <embed id="plugin" type="Application/x-webkit-test-webplugin">
26     <div id="toolbar" onckick="function(){}">
27       <button id="button1">A</button>
28       <button id="button2">B</button>
29       <button id="button3">C</button>
30     </div>
31 </div>
32
33 <p id='description'></p>
34 <div id='console'></div>
35
36 <script>
37     // Set up shortcut access to elements
38     var ids = ['sandbox', 'plugin', 'toolbar', 'button1', 'button2', 'button3'];
39     var e = {};
40     ids.forEach(function(a) {
41         e[a] = document.getElementById(a);
42     });
43     var bounds = {};
44     ids.forEach(function(a) {
45         bounds[a] = findAbsoluteBounds(e[a]);
46     });
47
48     function testMidpoint(id)
49     {
50         var x = bounds[id].left + bounds[id].width / 2;
51         var y = bounds[id].top + bounds[id].height / 2;
52         testTouchPoint(touchPoint(x, y, 10), e[id]); 
53     }
54
55     function testBoundary(buttonId)
56     {
57       var x = bounds[buttonId].left + bounds[buttonId].width / 2;
58       var y = (bounds['plugin'].top + bounds['plugin'].height + bounds[buttonId].top) / 2;
59       testTouchPoint(touchPoint(x, y - 5, 10), e['plugin']); 
60       testTouchPoint(touchPoint(x, y + 5, 10), e[buttonId]);
61     }
62
63     function testDirectTouches()
64     {
65         debug('Test direct hits.');
66         testMidpoint('plugin');
67         testMidpoint('button1');
68         testMidpoint('button2');
69         testMidpoint('button3');
70     }
71
72     function testIndirectTouches()
73     {
74         debug('Test hits spanning the plugin boundary.');
75         testBoundary('button1');
76         testBoundary('button2');
77         testBoundary('button3');
78     }
79
80     function runTests()
81     {
82         if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestClickableNode) {
83             description('Tests touch-adjustment at a plugin boundary.');
84             testDirectTouches();
85             testIndirectTouches();
86             e['sandbox'].style.display = 'none';
87         }
88     }
89     runTests();
90 </script>
91 <script src="../resources/js-test-post.js"></script>
92 </body>
93 </html>