| OLD | NEW |
| 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 import os | 4 import os |
| 5 | 5 |
| 6 from telemetry.internal.actions import page_action | 6 from telemetry.internal.actions import page_action |
| 7 | 7 |
| 8 | 8 |
| 9 class ScrollBounceAction(page_action.PageAction): | 9 class ScrollBounceAction(page_action.PageAction): |
| 10 def __init__(self, selector=None, text=None, element_function=None, | 10 def __init__(self, selector=None, text=None, element_function=None, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 self._overscroll = overscroll | 31 self._overscroll = overscroll |
| 32 # It's the transitions we really want to stress, make this big. | 32 # It's the transitions we really want to stress, make this big. |
| 33 self._repeat_count = repeat_count | 33 self._repeat_count = repeat_count |
| 34 # 7 pixels per frame should be plenty of frames. | 34 # 7 pixels per frame should be plenty of frames. |
| 35 self._speed = speed_in_pixels_per_second | 35 self._speed = speed_in_pixels_per_second |
| 36 self._synthetic_gesture_source = ('chrome.gpuBenchmarking.%s_INPUT' % | 36 self._synthetic_gesture_source = ('chrome.gpuBenchmarking.%s_INPUT' % |
| 37 synthetic_gesture_source) | 37 synthetic_gesture_source) |
| 38 | 38 |
| 39 if (self._selector is None and self._text is None and | 39 if (self._selector is None and self._text is None and |
| 40 self._element_function is None): | 40 self._element_function is None): |
| 41 self._element_function = 'document.body' | 41 self._element_function = 'document.scrollingElement' |
| 42 | 42 |
| 43 def WillRunAction(self, tab): | 43 def WillRunAction(self, tab): |
| 44 for js_file in ['gesture_common.js', 'scroll_bounce.js']: | 44 for js_file in ['gesture_common.js', 'scroll_bounce.js']: |
| 45 with open(os.path.join(os.path.dirname(__file__), js_file)) as f: | 45 with open(os.path.join(os.path.dirname(__file__), js_file)) as f: |
| 46 js = f.read() | 46 js = f.read() |
| 47 tab.ExecuteJavaScript(js) | 47 tab.ExecuteJavaScript(js) |
| 48 | 48 |
| 49 # Fail if browser doesn't support synthetic scroll bounce gestures. | 49 # Fail if browser doesn't support synthetic scroll bounce gestures. |
| 50 if not tab.EvaluateJavaScript( | 50 if not tab.EvaluateJavaScript( |
| 51 'window.__ScrollBounceAction_SupportedByBrowser()'): | 51 'window.__ScrollBounceAction_SupportedByBrowser()'): |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 self._top_start_ratio, | 89 self._top_start_ratio, |
| 90 self._direction, | 90 self._direction, |
| 91 self._distance, | 91 self._distance, |
| 92 self._overscroll, | 92 self._overscroll, |
| 93 self._repeat_count, | 93 self._repeat_count, |
| 94 self._speed) | 94 self._speed) |
| 95 page_action.EvaluateCallbackWithElement( | 95 page_action.EvaluateCallbackWithElement( |
| 96 tab, code, selector=self._selector, text=self._text, | 96 tab, code, selector=self._selector, text=self._text, |
| 97 element_function=self._element_function) | 97 element_function=self._element_function) |
| 98 tab.WaitForJavaScriptExpression('window.__scrollBounceActionDone', 60) | 98 tab.WaitForJavaScriptExpression('window.__scrollBounceActionDone', 60) |
| OLD | NEW |