OLD | NEW |
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 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 ScrollAction(page_action.PageAction): | 10 class ScrollAction(page_action.PageAction): |
(...skipping 22 matching lines...) Expand all Loading... |
33 synthetic_gesture_source) | 33 synthetic_gesture_source) |
34 | 34 |
35 self._distance_func = js_template.RenderValue(None) | 35 self._distance_func = js_template.RenderValue(None) |
36 if distance: | 36 if distance: |
37 assert not distance_expr | 37 assert not distance_expr |
38 distance_expr = str(distance) | 38 distance_expr = str(distance) |
39 if distance_expr: | 39 if distance_expr: |
40 self._distance_func = js_template.Render( | 40 self._distance_func = js_template.Render( |
41 'function() { return 0 + {{ @expr }}; }', expr=distance_expr) | 41 'function() { return 0 + {{ @expr }}; }', expr=distance_expr) |
42 | 42 |
| 43 def SimulatesUserInput(self): |
| 44 return True |
| 45 |
43 def WillRunAction(self, tab): | 46 def WillRunAction(self, tab): |
44 if self._direction in ('downleft', 'downright', 'upleft', 'upright'): | 47 if self._direction in ('downleft', 'downright', 'upleft', 'upright'): |
45 # Diagonal scrolling support was added in Chrome branch number 2332. | 48 # Diagonal scrolling support was added in Chrome branch number 2332. |
46 branch_num = ( | 49 branch_num = ( |
47 tab.browser._browser_backend.devtools_client.GetChromeBranchNumber()) | 50 tab.browser._browser_backend.devtools_client.GetChromeBranchNumber()) |
48 if branch_num < 2332: | 51 if branch_num < 2332: |
49 raise ValueError('Diagonal scrolling requires Chrome branch number' | 52 raise ValueError('Diagonal scrolling requires Chrome branch number' |
50 ' 2332 or later. Found branch number %d' % | 53 ' 2332 or later. Found branch number %d' % |
51 branch_num) | 54 branch_num) |
52 utils.InjectJavaScript(tab, 'gesture_common.js') | 55 utils.InjectJavaScript(tab, 'gesture_common.js') |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 }''', | 104 }''', |
102 left_start_ratio=self._left_start_ratio, | 105 left_start_ratio=self._left_start_ratio, |
103 top_start_ratio=self._top_start_ratio, | 106 top_start_ratio=self._top_start_ratio, |
104 direction=self._direction, | 107 direction=self._direction, |
105 speed=self._speed, | 108 speed=self._speed, |
106 gesture_source_type=gesture_source_type) | 109 gesture_source_type=gesture_source_type) |
107 page_action.EvaluateCallbackWithElement( | 110 page_action.EvaluateCallbackWithElement( |
108 tab, code, selector=self._selector, text=self._text, | 111 tab, code, selector=self._selector, text=self._text, |
109 element_function=self._element_function) | 112 element_function=self._element_function) |
110 tab.WaitForJavaScriptCondition('window.__scrollActionDone', timeout=60) | 113 tab.WaitForJavaScriptCondition('window.__scrollActionDone', timeout=60) |
OLD | NEW |