Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <body onload=run()> | |
|
esprehn
2014/06/26 02:33:50
Remove <body>.
Rick Byers
2014/06/26 15:35:18
Done.
| |
| 3 <p id=description></p> | |
| 4 <div id='target' style='width: 10px; height: 10px'></div> | |
| 5 <iframe id='frame' style='width: 50px; height: 50px; margin-top: 50px' scrolli ng=no | |
| 6 src='data:text/html,<iframe width=100 height=100></iframe>'></iframe> | |
|
esprehn
2014/06/26 02:33:50
use srcdoc, did you really want scrolling=no too?
Rick Byers
2014/06/26 15:35:18
done
| |
| 7 <div id='console'></div> | |
|
esprehn
2014/06/26 02:33:50
The test runner will add console and description f
Rick Byers
2014/06/26 15:35:18
Done.
I added console explicitly so that I could
| |
| 8 <script src="../../resources/js-test.js"></script> | |
| 9 <script> | |
| 10 description("Count how many hit tests are required for various event scenarios. Hit tests can be expensive and it's often tempting to add more. These values s hould only ever be changed to go down, not up."); | |
| 11 | |
| 12 function logCounts(name, documents) | |
| 13 { | |
| 14 var msg = name + ':'; | |
| 15 for(var i = 0; i < documents.length; i++) | |
| 16 msg += ' ' + internals.hitTestCountDelta(documents[i]); | |
| 17 debug(msg); | |
| 18 } | |
| 19 | |
| 20 function clearCounts(documents) | |
| 21 { | |
| 22 for(var i = 0; i < documents.length; i++) | |
| 23 internals.hitTestCountDelta(documents[i]); | |
| 24 } | |
| 25 | |
| 26 function sendEvents(element, documents) | |
| 27 { | |
| 28 var targetRect = element.getBoundingClientRect(); | |
| 29 var targetX = targetRect.left + targetRect.width / 2; | |
| 30 var targetY = targetRect.top + targetRect.height / 2; | |
| 31 | |
| 32 logCounts('Initial', documents); | |
| 33 | |
| 34 eventSender.mouseMoveTo(targetX, targetY); | |
| 35 logCounts('MouseMove', documents); | |
| 36 | |
| 37 eventSender.mouseDown(); | |
| 38 logCounts('MouseDown', documents); | |
| 39 | |
| 40 eventSender.mouseUp(); | |
| 41 logCounts('MouseUp', documents); | |
| 42 | |
| 43 eventSender.mouseScrollBy(0, 5); | |
| 44 logCounts('Wheel', documents); | |
| 45 | |
| 46 eventSender.addTouchPoint(targetX, targetY); | |
| 47 eventSender.touchStart(); | |
| 48 logCounts('TouchStart', documents); | |
| 49 | |
| 50 eventSender.updateTouchPoint(0, targetX + 1, targetY); | |
| 51 eventSender.touchMove(); | |
| 52 logCounts('TouchMove', documents); | |
| 53 | |
| 54 eventSender.releaseTouchPoint(0); | |
| 55 eventSender.touchEnd(); | |
| 56 logCounts('TouchEnd', documents); | |
| 57 | |
| 58 eventSender.gestureTapDown(targetX, targetY, 30, 30); | |
| 59 logCounts('GestureTapDown', documents); | |
| 60 | |
| 61 eventSender.gestureShowPress(targetX, targetY, 30, 30); | |
| 62 logCounts('GestureShowPress', documents); | |
| 63 | |
| 64 eventSender.gestureTap(targetX, targetY); | |
| 65 logCounts('GestureTap', documents); | |
| 66 | |
| 67 eventSender.gestureTapDown(targetX, targetY, 30, 30); | |
| 68 clearCounts(documents); | |
| 69 eventSender.gestureScrollBegin(targetX, targetY); | |
| 70 logCounts('GestureScrollBegin', documents); | |
| 71 | |
| 72 eventSender.gestureTapCancel(targetX, targetY); | |
| 73 logCounts('GestureTapCancel', documents); | |
| 74 | |
| 75 eventSender.gestureScrollUpdate(0, 5); | |
| 76 logCounts('GestureScrollUpdate', documents); | |
| 77 | |
| 78 eventSender.gestureScrollEnd(); | |
| 79 logCounts('GestureScrollEnd', documents); | |
| 80 } | |
| 81 | |
| 82 function run() { | |
|
esprehn
2014/06/26 02:33:50
onload = function() {
Rick Byers
2014/06/26 15:35:18
Done.
| |
| 83 debug('Event on a simple div'); | |
| 84 debug('---------------------'); | |
| 85 sendEvents(document.getElementById('target'), [document]); | |
| 86 debug(''); | |
| 87 | |
| 88 debug('Event over one iframe nested in another'); | |
| 89 debug('---------------------'); | |
| 90 var frame = document.getElementById('frame'); | |
| 91 var doc2 = frame.contentDocument; | |
| 92 var doc3 = doc2.querySelector('iframe').contentDocument; | |
| 93 sendEvents(frame, [document, doc2, doc3]); | |
| 94 debug(''); | |
| 95 } | |
| 96 </script> | |
| 97 </body> | |
| OLD | NEW |