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

Side by Side Diff: telemetry/telemetry/internal/actions/scroll_bounce.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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 ScrollBounceAction(page_action.PageAction): 10 class ScrollBounceAction(page_action.PageAction):
(...skipping 23 matching lines...) Expand all
34 self._repeat_count = repeat_count 34 self._repeat_count = repeat_count
35 # 7 pixels per frame should be plenty of frames. 35 # 7 pixels per frame should be plenty of frames.
36 self._speed = speed_in_pixels_per_second 36 self._speed = speed_in_pixels_per_second
37 self._synthetic_gesture_source = ('chrome.gpuBenchmarking.%s_INPUT' % 37 self._synthetic_gesture_source = ('chrome.gpuBenchmarking.%s_INPUT' %
38 synthetic_gesture_source) 38 synthetic_gesture_source)
39 39
40 if (self._selector is None and self._text is None and 40 if (self._selector is None and self._text is None and
41 self._element_function is None): 41 self._element_function is None):
42 self._element_function = '(document.scrollingElement || document.body)' 42 self._element_function = '(document.scrollingElement || document.body)'
43 43
44 def SimulatesUserInput(self):
45 return True
46
44 def WillRunAction(self, tab): 47 def WillRunAction(self, tab):
45 utils.InjectJavaScript(tab, 'gesture_common.js') 48 utils.InjectJavaScript(tab, 'gesture_common.js')
46 utils.InjectJavaScript(tab, 'scroll_bounce.js') 49 utils.InjectJavaScript(tab, 'scroll_bounce.js')
47 50
48 # Fail if browser doesn't support synthetic scroll bounce gestures. 51 # Fail if browser doesn't support synthetic scroll bounce gestures.
49 if not tab.EvaluateJavaScript( 52 if not tab.EvaluateJavaScript(
50 'window.__ScrollBounceAction_SupportedByBrowser()'): 53 'window.__ScrollBounceAction_SupportedByBrowser()'):
51 raise page_action.PageActionNotSupported( 54 raise page_action.PageActionNotSupported(
52 'Synthetic scroll bounce not supported for this browser') 55 'Synthetic scroll bounce not supported for this browser')
53 56
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 direction=self._direction, 92 direction=self._direction,
90 distance=self._distance, 93 distance=self._distance,
91 overscroll=self._overscroll, 94 overscroll=self._overscroll,
92 repeat_count=self._repeat_count, 95 repeat_count=self._repeat_count,
93 speed=self._speed) 96 speed=self._speed)
94 page_action.EvaluateCallbackWithElement( 97 page_action.EvaluateCallbackWithElement(
95 tab, code, selector=self._selector, text=self._text, 98 tab, code, selector=self._selector, text=self._text,
96 element_function=self._element_function) 99 element_function=self._element_function)
97 tab.WaitForJavaScriptCondition( 100 tab.WaitForJavaScriptCondition(
98 'window.__scrollBounceActionDone', timeout=60) 101 'window.__scrollBounceActionDone', timeout=60)
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/actions/scroll.py ('k') | telemetry/telemetry/internal/actions/scroll_to_element.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698