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 inspect | 4 import inspect |
5 import logging | 5 import logging |
6 import os | 6 import os |
7 import urlparse | 7 import urlparse |
8 | 8 |
9 from telemetry import user_story | 9 from telemetry import user_story |
10 from telemetry.page import shared_page_state | 10 from telemetry.page import shared_page_state |
11 from telemetry.util import cloud_storage | 11 from telemetry.util import cloud_storage |
12 from telemetry.util import path | 12 from telemetry.util import path |
13 | 13 |
14 | 14 |
15 def _UpdateCredentials(credentials_path): | 15 def _UpdateCredentials(credentials_path): |
16 # Attempt to download the credentials file. | 16 # Attempt to download the credentials file. |
17 try: | 17 try: |
18 cloud_storage.GetIfChanged(credentials_path, cloud_storage.PUBLIC_BUCKET) | 18 cloud_storage.GetIfChanged(credentials_path, cloud_storage.PUBLIC_BUCKET) |
19 except (cloud_storage.CredentialsError, cloud_storage.PermissionError, | 19 except (cloud_storage.CredentialsError, cloud_storage.PermissionError, |
20 cloud_storage.CloudStorageError) as e: | 20 cloud_storage.CloudStorageError) as e: |
21 logging.warning('Cannot retrieve credential file %s due to cloud storage ' | 21 logging.warning('Cannot retrieve credential file %s due to cloud storage ' |
22 'error %s', credentials_path, str(e)) | 22 'error %s', credentials_path, str(e)) |
23 | 23 |
24 | 24 |
25 class Page(user_story.UserStory): | 25 class Page(user_story.UserStory): |
26 def __init__(self, url, page_set=None, base_dir=None, name='', | 26 def __init__(self, url, page_set=None, base_dir=None, name='', |
27 credentials_path=None, labels=None, startup_url=''): | 27 credentials_path=None, labels=None, startup_url='', |
| 28 make_javascript_deterministic=True): |
28 self._url = url | 29 self._url = url |
29 | 30 |
30 super(Page, self).__init__( | 31 super(Page, self).__init__( |
31 shared_page_state.SharedPageState, name=name, labels=labels, | 32 shared_page_state.SharedPageState, name=name, labels=labels, |
32 is_local=self._scheme in ['file', 'chrome', 'about']) | 33 is_local=self._scheme in ['file', 'chrome', 'about'], |
| 34 make_javascript_deterministic=make_javascript_deterministic) |
33 | 35 |
34 self._page_set = page_set | 36 self._page_set = page_set |
35 # Default value of base_dir is the directory of the file that defines the | 37 # Default value of base_dir is the directory of the file that defines the |
36 # class of this page instance. | 38 # class of this page instance. |
37 if base_dir is None: | 39 if base_dir is None: |
38 base_dir = os.path.dirname(inspect.getfile(self.__class__)) | 40 base_dir = os.path.dirname(inspect.getfile(self.__class__)) |
39 self._base_dir = base_dir | 41 self._base_dir = base_dir |
40 self._name = name | 42 self._name = name |
41 if credentials_path: | 43 if credentials_path: |
42 credentials_path = os.path.join(self._base_dir, credentials_path) | 44 credentials_path = os.path.join(self._base_dir, credentials_path) |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 194 |
193 @property | 195 @property |
194 def display_name(self): | 196 def display_name(self): |
195 if self.name: | 197 if self.name: |
196 return self.name | 198 return self.name |
197 if not self.is_file: | 199 if not self.is_file: |
198 return self.url | 200 return self.url |
199 all_urls = [p.url.rstrip('/') for p in self.page_set if p.is_file] | 201 all_urls = [p.url.rstrip('/') for p in self.page_set if p.is_file] |
200 common_prefix = os.path.dirname(os.path.commonprefix(all_urls)) | 202 common_prefix = os.path.dirname(os.path.commonprefix(all_urls)) |
201 return self.url[len(common_prefix):].strip('/') | 203 return self.url[len(common_prefix):].strip('/') |
OLD | NEW |