def _UpdateDevToolsClient(self): if self._devtools_client is None: self._app_backend.platform_backend.ForwardHostToDevice( self._local_port, self._remote_devtools_port) if devtools_client_backend.IsDevToolsAgentAvailable(self._local_port): self._devtools_client = devtools_client_backend.DevToolsClientBackend( self._local_port, self._remote_devtools_port, self._app_backend)
def _InitDevtoolsClientBackend(self, remote_devtools_port=None): """ Initiate the devtool client backend which allow browser connection through browser' devtool. Args: remote_devtools_port: The remote devtools port, if any. Otherwise assumed to be the same as self._port. """ assert not self._devtools_client, ( 'Devtool client backend cannot be init twice') self._devtools_client = devtools_client_backend.DevToolsClientBackend( self._port, remote_devtools_port or self._port, self)
def _UpdateDevToolsClient(self): if self._devtools_client is None: platform_backend = self._app_backend.platform_backend self._forwarder = platform_backend.forwarder_factory.Create( forwarders.PortPair(0, self._remote_devtools_port), reverse=True) devtools_port = self._forwarder.port_pair.local_port if devtools_client_backend.IsDevToolsAgentAvailable( devtools_port, None, self._app_backend): self._devtools_client = devtools_client_backend.DevToolsClientBackend( devtools_port, None, self._remote_devtools_port, self._app_backend)
def _WaitForBrowserToComeUp(self, remote_devtools_port=None): """ Wait for browser to come up. Args: remote_devtools_port: The remote devtools port, if any. Otherwise assumed to be the same as self._port. """ try: timeout = self.browser_options.browser_startup_timeout py_utils.WaitFor(self.HasBrowserFinishedLaunching, timeout=timeout) except (py_utils.TimeoutException, exceptions.ProcessGoneException) as e: if not self.IsBrowserRunning(): raise exceptions.BrowserGoneException(self.browser, e) raise exceptions.BrowserConnectionGoneException(self.browser, e) self._devtools_client = devtools_client_backend.DevToolsClientBackend( self._port, self._browser_target, remote_devtools_port or self._port, self)
def _WaitForBrowserToComeUp(self, remote_devtools_port=None): """ Wait for browser to come up. Args: remote_devtools_port: The remote devtools port, if any. Otherwise assumed to be the same as self._port. """ if self._devtools_client: # In case we are launching a second browser instance (as is done by # the CrOS backend), ensure that the old devtools_client is closed, # otherwise re-creating it will fail. self._devtools_client.Close() self._devtools_client = None try: timeout = self.browser_options.browser_startup_timeout py_utils.WaitFor(self.HasBrowserFinishedLaunching, timeout=timeout) except (py_utils.TimeoutException, exceptions.ProcessGoneException) as e: if not self.IsBrowserRunning(): raise exceptions.BrowserGoneException(self.browser, e) raise exceptions.BrowserConnectionGoneException(self.browser, e) self._devtools_client = devtools_client_backend.DevToolsClientBackend( self._port, self._browser_target, remote_devtools_port or self._port, self)