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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/fast/events/hit-test-counts-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <style>
3 #testArea {
4 position: absolute;
5 right: 50px;
6 top: 50px;
7 }
8 #target {
9 width: 10px;
10 height: 10px;
11 }
12 #frame {
13 width: 100px;
14 height: 100px;
15 margin-top: 30px;
16 }
17 </style>
18 <div id=testArea>
19 <div id=target></div>
20 <iframe id=frame srcdoc='<iframe width=75 height=75></iframe>'></iframe>
21 </div>
22 <script src="../../resources/js-test.js"></script>
23 <script>
24 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.");
25
26 function hitTestCountDelta(doc)
27 {
28 var lastCount = 0;
29 if ('lastHitTestCount' in doc)
30 lastCount = doc.lastHitTestCount;
31 var newCount = internals.hitTestCount(doc);
32 doc.lastHitTestCount = newCount;
33 return newCount - lastCount;
34 }
35
36 function logCounts(name, documents)
37 {
38 var msg = name + ':';
39 for(var i = 0; i < documents.length; i++)
40 msg += ' ' + hitTestCountDelta(documents[i]);
41 debug(msg);
42 }
43
44 function clearCounts(documents)
45 {
46 for(var i = 0; i < documents.length; i++)
47 documents[i].lastHitTestCount = internals.hitTestCount(documents[i]);
48 }
49
50 function sendEvents(targetX, targetY, documents)
51 {
52 logCounts('Initial', documents);
53
54 eventSender.mouseMoveTo(targetX, targetY);
55 logCounts('MouseMove', documents);
56
57 eventSender.mouseDown();
58 logCounts('MouseDown', documents);
59
60 eventSender.mouseUp();
61 logCounts('MouseUp', documents);
62
63 eventSender.mouseScrollBy(0, 5);
64 logCounts('Wheel', documents);
65
66 eventSender.addTouchPoint(targetX, targetY);
67 eventSender.touchStart();
68 logCounts('TouchStart', documents);
69
70 eventSender.updateTouchPoint(0, targetX + 1, targetY);
71 eventSender.touchMove();
72 logCounts('TouchMove', documents);
73
74 eventSender.releaseTouchPoint(0);
75 eventSender.touchEnd();
76 logCounts('TouchEnd', documents);
77
78 eventSender.gestureTapDown(targetX, targetY, 30, 30);
79 logCounts('GestureTapDown', documents);
80
81 eventSender.gestureShowPress(targetX, targetY, 30, 30);
82 logCounts('GestureShowPress', documents);
83
84 eventSender.gestureTap(targetX, targetY);
85 logCounts('GestureTap', documents);
86
87 eventSender.gestureTapDown(targetX, targetY, 30, 30);
88 clearCounts(documents);
89 eventSender.gestureScrollBegin(targetX, targetY);
90 logCounts('GestureScrollBegin', documents);
91
92 eventSender.gestureTapCancel(targetX, targetY);
93 logCounts('GestureTapCancel', documents);
94
95 eventSender.gestureScrollUpdate(0, 5);
96 logCounts('GestureScrollUpdate', documents);
97
98 eventSender.gestureScrollEnd();
99 logCounts('GestureScrollEnd', documents);
100 }
101
102 function centerOf(element) {
103 var targetRect = element.getBoundingClientRect();
104 return {
105 x: targetRect.left + targetRect.width / 2,
106 y: targetRect.top + targetRect.height / 2
107 };
108 }
109
110 onload = function() {
111 debug('Event on a simple div');
112 debug('---------------------');
113 var point = centerOf(document.getElementById('target'));
114 sendEvents(point.x, point.y, [document]);
115 debug('');
116
117 debug('Event entirely over one iframe nested in another');
118 debug('---------------------');
119 var frame = document.getElementById('frame');
120 var doc2 = frame.contentDocument;
121 var doc3 = doc2.querySelector('iframe').contentDocument;
122 var point = centerOf(frame);
123 sendEvents(point.x, point.y, [document, doc2, doc3]);
124 debug('');
125
126 debug('Event near boundary of two iframes');
127 debug('---------------------');
128 var rect = frame.getBoundingClientRect();
129 sendEvents(rect.left + 3, rect.top + 3, [document, doc2, doc3]);
130 debug('');
131 }
132 </script>
OLDNEW
« 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