Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: LayoutTests/fast/events/hit-test-counts.html

Issue 354613002: Add test to track the number of hit tests on various events (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Apply CR feedback Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/events/hit-test-counts-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/events/hit-test-counts.html
diff --git a/LayoutTests/fast/events/hit-test-counts.html b/LayoutTests/fast/events/hit-test-counts.html
new file mode 100644
index 0000000000000000000000000000000000000000..9a2be382172f14ce7e2a88282914bdb366db8553
--- /dev/null
+++ b/LayoutTests/fast/events/hit-test-counts.html
@@ -0,0 +1,132 @@
+<!DOCTYPE html>
+<style>
+#testArea {
+ position: absolute;
+ right: 50px;
+ top: 50px;
+}
+#target {
+ width: 10px;
+ height: 10px;
+}
+#frame {
+ width: 100px;
+ height: 100px;
+ margin-top: 30px;
+}
+</style>
+<div id=testArea>
+ <div id=target></div>
+ <iframe id=frame srcdoc='<iframe width=75 height=75></iframe>'></iframe>
+</div>
+<script src="../../resources/js-test.js"></script>
+<script>
+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 should only ever be changed to go down, not up.");
+
+function hitTestCountDelta(doc)
+{
+ var lastCount = 0;
+ if ('lastHitTestCount' in doc)
+ lastCount = doc.lastHitTestCount;
+ var newCount = internals.hitTestCount(doc);
+ doc.lastHitTestCount = newCount;
+ return newCount - lastCount;
+}
+
+function logCounts(name, documents)
+{
+ var msg = name + ':';
+ for(var i = 0; i < documents.length; i++)
+ msg += ' ' + hitTestCountDelta(documents[i]);
+ debug(msg);
+}
+
+function clearCounts(documents)
+{
+ for(var i = 0; i < documents.length; i++)
+ documents[i].lastHitTestCount = internals.hitTestCount(documents[i]);
+}
+
+function sendEvents(targetX, targetY, documents)
+{
+ logCounts('Initial', documents);
+
+ eventSender.mouseMoveTo(targetX, targetY);
+ logCounts('MouseMove', documents);
+
+ eventSender.mouseDown();
+ logCounts('MouseDown', documents);
+
+ eventSender.mouseUp();
+ logCounts('MouseUp', documents);
+
+ eventSender.mouseScrollBy(0, 5);
+ logCounts('Wheel', documents);
+
+ eventSender.addTouchPoint(targetX, targetY);
+ eventSender.touchStart();
+ logCounts('TouchStart', documents);
+
+ eventSender.updateTouchPoint(0, targetX + 1, targetY);
+ eventSender.touchMove();
+ logCounts('TouchMove', documents);
+
+ eventSender.releaseTouchPoint(0);
+ eventSender.touchEnd();
+ logCounts('TouchEnd', documents);
+
+ eventSender.gestureTapDown(targetX, targetY, 30, 30);
+ logCounts('GestureTapDown', documents);
+
+ eventSender.gestureShowPress(targetX, targetY, 30, 30);
+ logCounts('GestureShowPress', documents);
+
+ eventSender.gestureTap(targetX, targetY);
+ logCounts('GestureTap', documents);
+
+ eventSender.gestureTapDown(targetX, targetY, 30, 30);
+ clearCounts(documents);
+ eventSender.gestureScrollBegin(targetX, targetY);
+ logCounts('GestureScrollBegin', documents);
+
+ eventSender.gestureTapCancel(targetX, targetY);
+ logCounts('GestureTapCancel', documents);
+
+ eventSender.gestureScrollUpdate(0, 5);
+ logCounts('GestureScrollUpdate', documents);
+
+ eventSender.gestureScrollEnd();
+ logCounts('GestureScrollEnd', documents);
+}
+
+function centerOf(element) {
+ var targetRect = element.getBoundingClientRect();
+ return {
+ x: targetRect.left + targetRect.width / 2,
+ y: targetRect.top + targetRect.height / 2
+ };
+}
+
+onload = function() {
+ debug('Event on a simple div');
+ debug('---------------------');
+ var point = centerOf(document.getElementById('target'));
+ sendEvents(point.x, point.y, [document]);
+ debug('');
+
+ debug('Event entirely over one iframe nested in another');
+ debug('---------------------');
+ var frame = document.getElementById('frame');
+ var doc2 = frame.contentDocument;
+ var doc3 = doc2.querySelector('iframe').contentDocument;
+ var point = centerOf(frame);
+ sendEvents(point.x, point.y, [document, doc2, doc3]);
+ debug('');
+
+ debug('Event near boundary of two iframes');
+ debug('---------------------');
+ var rect = frame.getBoundingClientRect();
+ sendEvents(rect.left + 3, rect.top + 3, [document, doc2, doc3]);
+ debug('');
+}
+</script>
« no previous file with comments | « no previous file | LayoutTests/fast/events/hit-test-counts-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698