| 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 from telemetry.page.actions import wait_until | 4 from telemetry.page.actions import wait_until |
| 5 | 5 |
| 6 class PageActionNotSupported(Exception): | 6 class PageActionNotSupported(Exception): |
| 7 pass | 7 pass |
| 8 | 8 |
| 9 class PageActionFailed(Exception): | 9 class PageActionFailed(Exception): |
| 10 pass | 10 pass |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 if self.wait_until: | 34 if self.wait_until: |
| 35 self.wait_until.RunActionAndWait(tab) | 35 self.wait_until.RunActionAndWait(tab) |
| 36 else: | 36 else: |
| 37 self.RunAction(tab) | 37 self.RunAction(tab) |
| 38 | 38 |
| 39 def RunAction(self, tab): | 39 def RunAction(self, tab): |
| 40 raise NotImplementedError() | 40 raise NotImplementedError() |
| 41 | 41 |
| 42 def CleanUp(self, tab): | 42 def CleanUp(self, tab): |
| 43 pass | 43 pass |
| 44 | |
| 45 def CanBeBound(self): | |
| 46 """If this class implements BindMeasurementJavaScript, override CanBeBound | |
| 47 to return True so that a test knows it can bind measurements.""" | |
| 48 return False | |
| 49 | |
| 50 def BindMeasurementJavaScript( | |
| 51 self, tab, start_js, stop_js): # pylint: disable=W0613 | |
| 52 """Let this action determine when measurements should start and stop. | |
| 53 | |
| 54 A measurement can call this method to provide the action | |
| 55 with JavaScript code that starts and stops measurements. The action | |
| 56 determines when to execute the provided JavaScript code, for more accurate | |
| 57 timings. | |
| 58 | |
| 59 Args: | |
| 60 tab: The tab to do everything on. | |
| 61 start_js: JavaScript code that starts measurements. | |
| 62 stop_js: JavaScript code that stops measurements. | |
| 63 """ | |
| 64 raise Exception('This action cannot be bound.') | |
| OLD | NEW |