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

Side by Side Diff: telemetry/telemetry/internal/actions/tap.py

Issue 2876843002: Simulate interactivity boost for simulated user input events
Patch Set: Created 3 years, 7 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from telemetry.internal.actions import page_action 5 from telemetry.internal.actions import page_action
6 from telemetry.internal.actions import utils 6 from telemetry.internal.actions import utils
7 from telemetry.util import js_template 7 from telemetry.util import js_template
8 8
9 9
10 class TapAction(page_action.PageAction): 10 class TapAction(page_action.PageAction):
11 def __init__(self, selector=None, text=None, element_function=None, 11 def __init__(self, selector=None, text=None, element_function=None,
12 left_position_percentage=0.5, top_position_percentage=0.5, 12 left_position_percentage=0.5, top_position_percentage=0.5,
13 duration_ms=50, 13 duration_ms=50,
14 synthetic_gesture_source=page_action.GESTURE_SOURCE_DEFAULT): 14 synthetic_gesture_source=page_action.GESTURE_SOURCE_DEFAULT):
15 super(TapAction, self).__init__() 15 super(TapAction, self).__init__()
16 self.selector = selector 16 self.selector = selector
17 self.text = text 17 self.text = text
18 self.element_function = element_function 18 self.element_function = element_function
19 self.left_position_percentage = left_position_percentage 19 self.left_position_percentage = left_position_percentage
20 self.top_position_percentage = top_position_percentage 20 self.top_position_percentage = top_position_percentage
21 self.duration_ms = duration_ms 21 self.duration_ms = duration_ms
22 self._synthetic_gesture_source = ('chrome.gpuBenchmarking.%s_INPUT' % 22 self._synthetic_gesture_source = ('chrome.gpuBenchmarking.%s_INPUT' %
23 synthetic_gesture_source) 23 synthetic_gesture_source)
24 24
25 def SimulatesUserInput(self):
26 return True
27
25 def WillRunAction(self, tab): 28 def WillRunAction(self, tab):
26 utils.InjectJavaScript(tab, 'gesture_common.js') 29 utils.InjectJavaScript(tab, 'gesture_common.js')
27 utils.InjectJavaScript(tab, 'tap.js') 30 utils.InjectJavaScript(tab, 'tap.js')
28 31
29 # Fail if browser doesn't support synthetic tap gestures. 32 # Fail if browser doesn't support synthetic tap gestures.
30 if not tab.EvaluateJavaScript('window.__TapAction_SupportedByBrowser()'): 33 if not tab.EvaluateJavaScript('window.__TapAction_SupportedByBrowser()'):
31 raise page_action.PageActionNotSupported( 34 raise page_action.PageActionNotSupported(
32 'Synthetic tap not supported for this browser') 35 'Synthetic tap not supported for this browser')
33 36
34 tab.ExecuteJavaScript(""" 37 tab.ExecuteJavaScript("""
(...skipping 30 matching lines...) Expand all
65 68
66 page_action.EvaluateCallbackWithElement( 69 page_action.EvaluateCallbackWithElement(
67 tab, code, selector=self.selector, text=self.text, 70 tab, code, selector=self.selector, text=self.text,
68 element_function=self.element_function) 71 element_function=self.element_function)
69 # The second disjunct handles the case where the tap action leads to an 72 # The second disjunct handles the case where the tap action leads to an
70 # immediate navigation (in which case the expression below might already be 73 # immediate navigation (in which case the expression below might already be
71 # evaluated on the new page). 74 # evaluated on the new page).
72 tab.WaitForJavaScriptCondition( 75 tab.WaitForJavaScriptCondition(
73 'window.__tapActionDone || window.__tapAction === undefined', 76 'window.__tapActionDone || window.__tapAction === undefined',
74 timeout=60) 77 timeout=60)
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/actions/swipe.py ('k') | telemetry/telemetry/internal/browser/browser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698