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 os | 4 import os |
5 import re | 5 import re |
6 import time | 6 import time |
7 import urlparse | 7 import urlparse |
8 | 8 |
9 from telemetry import util | 9 from telemetry.core import util |
10 | 10 |
11 class Page(object): | 11 class Page(object): |
12 def __init__(self, url, page_set, attributes=None, base_dir=None): | 12 def __init__(self, url, page_set, attributes=None, base_dir=None): |
13 parsed_url = urlparse.urlparse(url) | 13 parsed_url = urlparse.urlparse(url) |
14 if not parsed_url.scheme: | 14 if not parsed_url.scheme: |
15 abspath = os.path.abspath(os.path.join(base_dir, parsed_url.path)) | 15 abspath = os.path.abspath(os.path.join(base_dir, parsed_url.path)) |
16 if os.path.exists(abspath): | 16 if os.path.exists(abspath): |
17 url = 'file://%s' % os.path.abspath(os.path.join(base_dir, url)) | 17 url = 'file://%s' % os.path.abspath(os.path.join(base_dir, url)) |
18 else: | 18 else: |
19 raise Exception('URLs must be fully qualified: %s' % url) | 19 raise Exception('URLs must be fully qualified: %s' % url) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 tab, obj.wait_for_element_with_text, callback_code), | 87 tab, obj.wait_for_element_with_text, callback_code), |
88 timeout, poll_interval) | 88 timeout, poll_interval) |
89 if hasattr(obj, 'wait_for_element_with_selector'): | 89 if hasattr(obj, 'wait_for_element_with_selector'): |
90 util.WaitFor(lambda: tab.EvaluateJavaScript( | 90 util.WaitFor(lambda: tab.EvaluateJavaScript( |
91 'document.querySelector(\'' + obj.wait_for_element_with_selector + | 91 'document.querySelector(\'' + obj.wait_for_element_with_selector + |
92 '\') != null'), timeout, poll_interval) | 92 '\') != null'), timeout, poll_interval) |
93 if hasattr(obj, 'wait_for_javascript_expression'): | 93 if hasattr(obj, 'wait_for_javascript_expression'): |
94 util.WaitFor( | 94 util.WaitFor( |
95 lambda: tab.EvaluateJavaScript(obj.wait_for_javascript_expression), | 95 lambda: tab.EvaluateJavaScript(obj.wait_for_javascript_expression), |
96 timeout, poll_interval) | 96 timeout, poll_interval) |
OLD | NEW |