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

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: Merge with trunk 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
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..1b2186ab017f188220f38a3dbbdf786af30ed74e
--- /dev/null
+++ b/LayoutTests/fast/events/hit-test-counts.html
@@ -0,0 +1,97 @@
+<!DOCTYPE html>
+<body onload=run()>
esprehn 2014/06/26 02:33:50 Remove <body>.
Rick Byers 2014/06/26 15:35:18 Done.
+ <p id=description></p>
+ <div id='target' style='width: 10px; height: 10px'></div>
+ <iframe id='frame' style='width: 50px; height: 50px; margin-top: 50px' scrolling=no
+ 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
+ <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
+ <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 logCounts(name, documents)
+{
+ var msg = name + ':';
+ for(var i = 0; i < documents.length; i++)
+ msg += ' ' + internals.hitTestCountDelta(documents[i]);
+ debug(msg);
+}
+
+function clearCounts(documents)
+{
+ for(var i = 0; i < documents.length; i++)
+ internals.hitTestCountDelta(documents[i]);
+}
+
+function sendEvents(element, documents)
+{
+ var targetRect = element.getBoundingClientRect();
+ var targetX = targetRect.left + targetRect.width / 2;
+ var targetY = targetRect.top + targetRect.height / 2;
+
+ 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 run() {
esprehn 2014/06/26 02:33:50 onload = function() {
Rick Byers 2014/06/26 15:35:18 Done.
+ debug('Event on a simple div');
+ debug('---------------------');
+ sendEvents(document.getElementById('target'), [document]);
+ debug('');
+
+ debug('Event over one iframe nested in another');
+ debug('---------------------');
+ var frame = document.getElementById('frame');
+ var doc2 = frame.contentDocument;
+ var doc3 = doc2.querySelector('iframe').contentDocument;
+ sendEvents(frame, [document, doc2, doc3]);
+ debug('');
+}
+</script>
+</body>
« no previous file with comments | « no previous file | LayoutTests/fast/events/hit-test-counts-expected.txt » ('j') | Source/core/rendering/RenderView.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698