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
3 # found in the LICENSE file.
5 from telemetry.core import util
6 from telemetry.core.backends import browser_backend
7 from telemetry.core.backends.webdriver import webdriver_tab_list_backend
9 class WebDriverBrowserBackend(browser_backend.BrowserBackend):
10 """The webdriver-based backend for controlling a locally-executed browser
11 instance, on Linux, Mac, and Windows.
14 def __init__(self, driver_creator, supports_extensions, browser_options):
15 super(WebDriverBrowserBackend, self).__init__(
16 is_content_shell=False,
17 supports_extensions=supports_extensions,
18 browser_options=browser_options,
19 tab_list_backend=webdriver_tab_list_backend.WebDriverTabListBackend)
21 self._driver_creator = driver_creator
23 self.wpr_http_port_pair = util.PortPair(80, 80)
24 self.wpr_https_port_pair = util.PortPair(443, 443)
27 assert not self._driver
28 self._driver = self._driver_creator()
36 def supports_tab_control(self):
37 # Based on webdriver protocol API, only closing a tab is supported while
38 # activating or creating a tab is not. Thus, tab control is not supported.
42 def supports_tracing(self):
43 # Tracing is not available in IE/Firefox yet and not supported through
47 def GetProcessName(self, cmd_line):
48 # Leave implementation details to subclass as process name depends on the
50 raise NotImplementedError()
57 def CreateForwarder(self, *port_pairs):
58 return browser_backend.DoNothingForwarder(*port_pairs)
60 def IsBrowserRunning(self):
61 # Assume the browser is running if not explicitly closed.
62 return self._driver is not None