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 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 ScrollAction(page_action.PageAction): | 9 class ScrollAction(page_action.PageAction): |
10 # TODO(chrishenry): Ignore attributes, to be deleted when usage in | 10 # TODO(chrishenry): Ignore attributes, to be deleted when usage in |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 done_callback = 'function() { window.__scrollActionDone = true; }' | 72 done_callback = 'function() { window.__scrollActionDone = true; }' |
73 tab.ExecuteJavaScript(""" | 73 tab.ExecuteJavaScript(""" |
74 window.__scrollActionDone = false; | 74 window.__scrollActionDone = false; |
75 window.__scrollAction = new __ScrollAction(%s, %s);""" | 75 window.__scrollAction = new __ScrollAction(%s, %s);""" |
76 % (done_callback, self._distance_func)) | 76 % (done_callback, self._distance_func)) |
77 | 77 |
78 def RunAction(self, tab): | 78 def RunAction(self, tab): |
79 if (self._selector is None and self._text is None and | 79 if (self._selector is None and self._text is None and |
80 self._element_function is None): | 80 self._element_function is None): |
81 self._element_function = 'document.body' | 81 self._element_function = 'document.scrollingElement' |
82 | 82 |
83 gesture_source_type = self._synthetic_gesture_source | 83 gesture_source_type = self._synthetic_gesture_source |
84 if self._use_touch: | 84 if self._use_touch: |
85 gesture_source_type = 'chrome.gpuBenchmarking.TOUCH_INPUT' | 85 gesture_source_type = 'chrome.gpuBenchmarking.TOUCH_INPUT' |
86 | 86 |
87 code = ''' | 87 code = ''' |
88 function(element, info) { | 88 function(element, info) { |
89 if (!element) { | 89 if (!element) { |
90 throw Error('Cannot find element: ' + info); | 90 throw Error('Cannot find element: ' + info); |
91 } | 91 } |
92 window.__scrollAction.start({ | 92 window.__scrollAction.start({ |
93 element: element, | 93 element: element, |
94 left_start_ratio: %s, | 94 left_start_ratio: %s, |
95 top_start_ratio: %s, | 95 top_start_ratio: %s, |
96 direction: '%s', | 96 direction: '%s', |
97 speed: %s, | 97 speed: %s, |
98 gesture_source_type: %s | 98 gesture_source_type: %s |
99 }); | 99 }); |
100 }''' % (self._left_start_ratio, | 100 }''' % (self._left_start_ratio, |
101 self._top_start_ratio, | 101 self._top_start_ratio, |
102 self._direction, | 102 self._direction, |
103 self._speed, | 103 self._speed, |
104 gesture_source_type) | 104 gesture_source_type) |
105 page_action.EvaluateCallbackWithElement( | 105 page_action.EvaluateCallbackWithElement( |
106 tab, code, selector=self._selector, text=self._text, | 106 tab, code, selector=self._selector, text=self._text, |
107 element_function=self._element_function) | 107 element_function=self._element_function) |
108 tab.WaitForJavaScriptExpression('window.__scrollActionDone', 60) | 108 tab.WaitForJavaScriptExpression('window.__scrollActionDone', 60) |
OLD | NEW |