Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 from telemetry.core import util | |
| 5 from telemetry.core.webdriver import webdriver_tab_list_backend | |
| 6 | |
| 7 class WebDriverBrowserBackend(object): | |
| 8 """The webdriver-based backend for controlling a locally-executed browser | |
| 9 instance, on Linux, Mac, and Windows. | |
| 10 """ | |
| 11 | |
| 12 WEBPAGEREPLAY_HOST = '127.0.0.1' | |
|
tonyg
2013/07/30 19:35:34
Is this unused? If not, can we share it with the s
chrisgao (Use stgao instead)
2013/07/31 19:05:41
Found chrome backend and webdriver backend share a
| |
| 13 | |
| 14 def __init__(self, webdriver, supports_extensions, options): | |
| 15 self.browser_type = options.browser_type | |
| 16 self.webdriver_based = True | |
| 17 self._driver = webdriver | |
| 18 self._supports_extensions = supports_extensions | |
| 19 self.options = options | |
| 20 self._browser = None | |
| 21 self.webpagereplay_local_http_port = 80 | |
| 22 self.webpagereplay_local_https_port = 443 | |
| 23 self.webpagereplay_remote_http_port = self.webpagereplay_local_http_port | |
| 24 self.webpagereplay_remote_https_port = self.webpagereplay_local_https_port | |
| 25 self._tab_list_backend = \ | |
| 26 webdriver_tab_list_backend.WebDriverTabListBackend(self) | |
| 27 | |
| 28 def SetBrowser(self, browser): | |
| 29 self._browser = browser | |
| 30 self._tab_list_backend.Init() | |
| 31 | |
| 32 @property | |
| 33 def driver(self): | |
| 34 return self._driver | |
| 35 | |
| 36 @property | |
| 37 def browser(self): | |
| 38 return self._browser | |
| 39 | |
| 40 @property | |
| 41 def is_content_shell(self): | |
| 42 return False | |
| 43 | |
| 44 @property | |
| 45 def supports_extensions(self): | |
| 46 return self._supports_extensions | |
| 47 | |
| 48 @property | |
| 49 def tab_list_backend(self): | |
| 50 return self._tab_list_backend | |
| 51 | |
| 52 @property | |
| 53 def supports_tab_control(self): | |
| 54 # Based on webdriver protocol API, only closing a tab is supported while | |
| 55 # activating or creating a tab is not. Thus, tab control is not supported. | |
| 56 return False | |
| 57 | |
| 58 @property | |
| 59 def wpr_mode(self): | |
| 60 return self.options.wpr_mode | |
| 61 | |
| 62 @property | |
| 63 def supports_tracing(self): | |
| 64 # Tracing is not available in IE/Firefox yet and not supported through | |
| 65 # webdriver API. | |
| 66 return False | |
| 67 | |
| 68 def StartTracing(self, _): | |
| 69 raise NotImplementedError() | |
| 70 | |
| 71 def StopTracing(self): | |
| 72 raise NotImplementedError() | |
| 73 | |
| 74 def GetTraceResultAndReset(self): | |
| 75 raise NotImplementedError() | |
| 76 | |
| 77 def GetProcessName(self, _): | |
| 78 # Leave implementation details to subclass as process name depends on the | |
| 79 # type of browser. | |
| 80 raise NotImplementedError() | |
| 81 | |
| 82 def GetRemotePort(self, _): | |
| 83 return util.GetAvailableLocalPort() | |
| 84 | |
| 85 def Close(self): | |
| 86 self._driver.quit() | |
| 87 self._driver = None | |
| 88 | |
| 89 def CreateForwarder(self, *port_pairs): | |
| 90 return util.DoNothingForwarder(*port_pairs) | |
| 91 | |
| 92 def IsBrowserRunning(self): | |
| 93 # Assume the browser is running if not explicitly closed. | |
| 94 return self._driver is not None | |
| 95 | |
| 96 def GetStandardOutput(self): | |
| 97 # TODO: Double check whether there is a way for python client to get stdout. | |
| 98 return '' | |
| 99 | |
| 100 def __del__(self): | |
| 101 self.Close() | |
| OLD | NEW |