OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 time | 4 import time |
5 | 5 |
6 from telemetry import page_action | 6 from telemetry.core import util |
7 from telemetry import util | 7 from telemetry.page import page_action |
8 | 8 |
9 class WaitAction(page_action.PageAction): | 9 class WaitAction(page_action.PageAction): |
10 DEFAULT_TIMEOUT = 60 | 10 DEFAULT_TIMEOUT = 60 |
11 | 11 |
12 def __init__(self, attributes=None): | 12 def __init__(self, attributes=None): |
13 super(WaitAction, self).__init__(attributes) | 13 super(WaitAction, self).__init__(attributes) |
14 | 14 |
15 def RunsPreviousAction(self): | 15 def RunsPreviousAction(self): |
16 assert hasattr(self, 'condition') | 16 assert hasattr(self, 'condition') |
17 return self.condition == 'navigate' or self.condition == 'href_change' | 17 return self.condition == 'navigate' or self.condition == 'href_change' |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 tab, self.text, callback_code), self.DEFAULT_TIMEOUT) | 50 tab, self.text, callback_code), self.DEFAULT_TIMEOUT) |
51 elif self.selector: | 51 elif self.selector: |
52 util.WaitFor(lambda: tab.EvaluateJavaScript( | 52 util.WaitFor(lambda: tab.EvaluateJavaScript( |
53 'document.querySelector("%s") != null' % self.selector), | 53 'document.querySelector("%s") != null' % self.selector), |
54 self.DEFAULT_TIMEOUT) | 54 self.DEFAULT_TIMEOUT) |
55 | 55 |
56 elif self.condition == 'javascript': | 56 elif self.condition == 'javascript': |
57 assert hasattr(self, 'javascript') | 57 assert hasattr(self, 'javascript') |
58 util.WaitFor(lambda: tab.EvaluateJavaScript(self.javascript), | 58 util.WaitFor(lambda: tab.EvaluateJavaScript(self.javascript), |
59 self.DEFAULT_TIMEOUT) | 59 self.DEFAULT_TIMEOUT) |
OLD | NEW |