OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Finds desktop browsers that can be controlled by telemetry.""" | 4 """Finds desktop browsers that can be controlled by telemetry.""" |
5 | 5 |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 | 9 |
10 import dependency_manager # pylint: disable=import-error | 10 import dependency_manager # pylint: disable=import-error |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 def Create(self, finder_options): | 53 def Create(self, finder_options): |
54 if self._flash_path and not os.path.exists(self._flash_path): | 54 if self._flash_path and not os.path.exists(self._flash_path): |
55 logging.warning( | 55 logging.warning( |
56 'Could not find Flash at %s. Continuing without Flash.\n' | 56 'Could not find Flash at %s. Continuing without Flash.\n' |
57 'To run with Flash, check it out via http://go/read-src-internal', | 57 'To run with Flash, check it out via http://go/read-src-internal', |
58 self._flash_path) | 58 self._flash_path) |
59 self._flash_path = None | 59 self._flash_path = None |
60 | 60 |
61 self._InitPlatformIfNeeded() | 61 self._InitPlatformIfNeeded() |
62 | 62 |
63 browser_backend = desktop_browser_backend.DesktopBrowserBackend( | 63 num_retries = 3 |
64 self._platform_backend, | 64 for x in range(0, num_retries): |
65 finder_options.browser_options, self._local_executable, | 65 returned_browser = None |
66 self._flash_path, self._is_content_shell, self._browser_directory) | 66 try: |
67 return browser.Browser( | 67 returned_browser = None |
68 browser_backend, self._platform_backend, self._credentials_path) | 68 |
69 browser_backend = desktop_browser_backend.DesktopBrowserBackend( | |
70 self._platform_backend, | |
71 finder_options.browser_options, self._local_executable, | |
72 self._flash_path, self._is_content_shell, self._browser_directory) | |
73 | |
74 returned_browser = browser.Browser( | |
75 browser_backend, self._platform_backend, self._credentials_path) | |
76 | |
77 # Try fetching the zeroth tab. If this works, then the browser | |
78 # appears to be working. | |
79 _ = returned_browser.tabs[0] | |
Ken Russell (switch to Gerrit)
2017/05/08 21:22:02
The fetching of the zeroth tab is causing DevTools
| |
80 | |
81 return returned_browser | |
82 except Exception: | |
83 logging.warning('Browser creation failed (attempt %d of %d), retrying' % | |
84 ((x + 1), num_retries)) | |
85 # Attempt to clean up things left over from the failed browser startup. | |
86 try: | |
87 if returned_browser: | |
88 returned_browser.Close() | |
89 except Exception: | |
90 pass | |
91 # Re-raise the exception the last time through. | |
92 if x == num_retries - 1: | |
93 raise | |
69 | 94 |
70 def SupportsOptions(self, browser_options): | 95 def SupportsOptions(self, browser_options): |
71 if ((len(browser_options.extensions_to_load) != 0) | 96 if ((len(browser_options.extensions_to_load) != 0) |
72 and self._is_content_shell): | 97 and self._is_content_shell): |
73 return False | 98 return False |
74 return True | 99 return True |
75 | 100 |
76 def UpdateExecutableIfNeeded(self): | 101 def UpdateExecutableIfNeeded(self): |
77 pass | 102 pass |
78 | 103 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 if "--ozone-platform" in arg: | 304 if "--ozone-platform" in arg: |
280 has_ozone_platform = True | 305 has_ozone_platform = True |
281 | 306 |
282 if len(browsers) and not has_x11_display and not has_ozone_platform: | 307 if len(browsers) and not has_x11_display and not has_ozone_platform: |
283 logging.warning( | 308 logging.warning( |
284 'Found (%s), but you do not have a DISPLAY environment set.' % | 309 'Found (%s), but you do not have a DISPLAY environment set.' % |
285 ','.join([b.browser_type for b in browsers])) | 310 ','.join([b.browser_type for b in browsers])) |
286 return [] | 311 return [] |
287 | 312 |
288 return browsers | 313 return browsers |
OLD | NEW |