| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <meta name="viewport" content="width=device-width, initial-scale=1"> | 2 <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 3 <style> | 3 <style> |
| 4 html { | 4 html { |
| 5 font-family: Ahem; | 5 font-family: Ahem; |
| 6 font-size: 10px; | 6 font-size: 10px; |
| 7 } | 7 } |
| 8 #testArea { | 8 #testArea { |
| 9 position: absolute; | 9 position: absolute; |
| 10 right: 50px; | 10 right: 50px; |
| 11 top: 50px; | 11 top: 50px; |
| 12 } | 12 } |
| 13 #target { | 13 #target { |
| 14 width: 10px; | 14 width: 10px; |
| 15 height: 10px; | 15 height: 10px; |
| 16 } | 16 } |
| 17 #frame { | 17 #frame { |
| 18 width: 100px; | 18 width: 100px; |
| 19 height: 100px; | 19 height: 100px; |
| 20 margin-top: 30px; | 20 margin-top: 30px; |
| 21 } | 21 } |
| 22 </style> | 22 </style> |
| 23 <div id=testArea> | 23 <div id=testArea> |
| 24 <div id=target></div> | 24 <div id=target></div> |
| 25 <iframe id=frame srcdoc='<iframe width=75 height=75></iframe>'></iframe> | 25 <iframe id=frame srcdoc='<iframe width=75 height=75></iframe>'></iframe> |
| 26 </div> | 26 </div> |
| 27 <script src="../../resources/js-test.js"></script> | 27 <script src="../../resources/js-test.js"></script> |
| 28 <script> | 28 <script> |
| 29 setPrintTestResultsLazily(); |
| 29 if (window.internals) { | 30 if (window.internals) { |
| 30 window.internals.settings.setViewportEnabled(true); | 31 window.internals.settings.setViewportEnabled(true); |
| 31 window.internals.settings.setMockScrollbarsEnabled(true); | 32 window.internals.settings.setMockScrollbarsEnabled(true); |
| 32 } | 33 } |
| 33 | 34 |
| 34 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."); | 35 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."); |
| 35 | 36 |
| 36 function hitTestCountDelta(doc) | 37 function hitTestCountDelta(doc) |
| 37 { | 38 { |
| 38 var lastCount = 0; | 39 var lastCount = 0; |
| 39 if ('lastHitTestCount' in doc) | 40 if ('lastHitTestCount' in doc) |
| 40 lastCount = doc.lastHitTestCount; | 41 lastCount = doc.lastHitTestCount; |
| 41 var newCount = internals.hitTestCount(doc); | 42 var newCount = internals.hitTestCount(doc); |
| 42 doc.lastHitTestCount = newCount; | 43 doc.lastHitTestCount = newCount; |
| 43 return newCount - lastCount; | 44 return newCount - lastCount; |
| 44 } | 45 } |
| 45 | 46 |
| 47 function hitTestCacheHitsDelta(doc) |
| 48 { |
| 49 var lastCount = 0; |
| 50 if ('lastHitTestCacheHits' in doc) |
| 51 lastCount = doc.lastHitTestCacheHits; |
| 52 var newCount = internals.hitTestCacheHits(doc); |
| 53 doc.lastHitTestCacheHits = newCount; |
| 54 return newCount - lastCount; |
| 55 } |
| 56 |
| 46 function logCounts(label, documents, multiTapNotification, eventSenderFunction) | 57 function logCounts(label, documents, multiTapNotification, eventSenderFunction) |
| 47 { | 58 { |
| 48 if (eventSenderFunction) | 59 if (eventSenderFunction) |
| 49 eventSenderFunction(); | 60 eventSenderFunction(); |
| 50 | 61 |
| 51 var countStr = ''; | 62 var countStr = ''; |
| 52 for(var i = 0; i < documents.length; i++) | 63 for(var i = 0; i < documents.length; i++) { |
| 53 countStr += ' ' + hitTestCountDelta(documents[i]); | 64 var hits = hitTestCountDelta(documents[i]); |
| 65 var cacheHits = hitTestCacheHitsDelta(documents[i]); |
| 66 countStr += ' ' + (hits - cacheHits) + "+" + cacheHits; |
| 67 } |
| 54 | 68 |
| 55 if (multiTapNotification) { | 69 if (multiTapNotification) { |
| 56 debug(label + ':' + eventCounts[label] | 70 debug(label + ':' + eventCounts[label] |
| 57 + ((countStr == eventCounts[label])? '': ' [with multiTargetTapNotificat
ion:' + countStr + ']')); | 71 + ((countStr == eventCounts[label])? '': ' [with multiTargetTapNotificat
ion:' + countStr + ']')); |
| 58 } else { | 72 } else { |
| 59 // store the count for later; to be compared when the | 73 // store the count for later; to be compared when the |
| 60 // multiTapNotification test is run. | 74 // multiTapNotification test is run. |
| 61 eventCounts[label] = countStr; | 75 eventCounts[label] = countStr; |
| 62 } | 76 } |
| 63 } | 77 } |
| 64 | 78 |
| 65 function clearCounts(documents) | 79 function clearCounts(documents) |
| 66 { | 80 { |
| 67 for(var i = 0; i < documents.length; i++) | 81 for(var i = 0; i < documents.length; i++) { |
| 68 documents[i].lastHitTestCount = internals.hitTestCount(documents[i]); | 82 documents[i].lastHitTestCount = internals.hitTestCount(documents[i]); |
| 83 documents[i].lastHitTestCacheHits = internals.hitTestCacheHits(documents
[i]); |
| 84 } |
| 69 } | 85 } |
| 70 | 86 |
| 71 function sendEvents(targetX, targetY, documents, multiTapNotification) | 87 function sendEvents(targetX, targetY, documents, multiTapNotification) |
| 72 { | 88 { |
| 73 logCounts('Initial', documents, multiTapNotification); | 89 logCounts('Initial', documents, multiTapNotification); |
| 74 | 90 |
| 75 logCounts('MouseMove', documents, multiTapNotification, function() { | 91 logCounts('MouseMove', documents, multiTapNotification, function() { |
| 76 eventSender.mouseMoveTo(targetX, targetY); | 92 eventSender.mouseMoveTo(targetX, targetY); |
| 77 }); | 93 }); |
| 78 | 94 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 146 |
| 131 logCounts('GestureScrollEnd', documents, multiTapNotification, function() { | 147 logCounts('GestureScrollEnd', documents, multiTapNotification, function() { |
| 132 eventSender.gestureScrollEnd(0, 5); | 148 eventSender.gestureScrollEnd(0, 5); |
| 133 }); | 149 }); |
| 134 } | 150 } |
| 135 | 151 |
| 136 function runTestForDocuments(targetX, targetY, documents) | 152 function runTestForDocuments(targetX, targetY, documents) |
| 137 { | 153 { |
| 138 sendEvents(targetX, targetY, documents, false); | 154 sendEvents(targetX, targetY, documents, false); |
| 139 window.internals.settings.setMultiTargetTapNotificationEnabled(true); | 155 window.internals.settings.setMultiTargetTapNotificationEnabled(true); |
| 156 for(var i = 0; i < documents.length; i++) { |
| 157 internals.clearHitTestCache(documents[i]); |
| 158 } |
| 140 sendEvents(targetX, targetY, documents, true); | 159 sendEvents(targetX, targetY, documents, true); |
| 141 window.internals.settings.setMultiTargetTapNotificationEnabled(false); | 160 window.internals.settings.setMultiTargetTapNotificationEnabled(false); |
| 142 } | 161 } |
| 143 | 162 |
| 144 function centerOf(element) { | 163 function centerOf(element) { |
| 145 var targetRect = element.getBoundingClientRect(); | 164 var targetRect = element.getBoundingClientRect(); |
| 146 return { | 165 return { |
| 147 x: targetRect.left + targetRect.width / 2, | 166 x: targetRect.left + targetRect.width / 2, |
| 148 y: targetRect.top + targetRect.height / 2 | 167 y: targetRect.top + targetRect.height / 2 |
| 149 }; | 168 }; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 174 runTestForDocuments(rect.left + 3, rect.top + 3, [document, doc2, doc3]); | 193 runTestForDocuments(rect.left + 3, rect.top + 3, [document, doc2, doc3]); |
| 175 debug(''); | 194 debug(''); |
| 176 | 195 |
| 177 window.internals.settings.setViewportEnabled(false); | 196 window.internals.settings.setViewportEnabled(false); |
| 178 debug('Event on a simple div (desktop viewport)'); | 197 debug('Event on a simple div (desktop viewport)'); |
| 179 debug('---------------------'); | 198 debug('---------------------'); |
| 180 var point = centerOf(document.getElementById('target')); | 199 var point = centerOf(document.getElementById('target')); |
| 181 runTestForDocuments(point.x, point.y, [document]); | 200 runTestForDocuments(point.x, point.y, [document]); |
| 182 debug(''); | 201 debug(''); |
| 183 window.internals.settings.setViewportEnabled(true); | 202 window.internals.settings.setViewportEnabled(true); |
| 203 finishJSTest(); |
| 184 } | 204 } |
| 185 </script> | 205 </script> |
| OLD | NEW |