def _HandleError(self, elapsed_time): if self._IsInspectable(): raise exceptions.DevtoolsTargetCrashException(self.app, 'Received a socket error in the browser connection and the tab ' 'still exists, assuming it timed out. ' 'Elapsed=%ds Error=%s' % (elapsed_time, sys.exc_info()[1])) raise exceptions.DevtoolsTargetCrashException(self.app, 'Received a socket error in the browser connection and the tab no ' 'longer exists, assuming it crashed. Error=%s' % sys.exc_info()[1])
def _ConvertExceptionFromInspectorWebsocket(self, error): """Converts an Exception from inspector_websocket. This method always raises a Telemetry exception. It appends debugging information. The exact exception raised depends on |error|. Args: error: An instance of socket.error or websocket.WebSocketException. Raises: exceptions.TimeoutException: A timeout occurred. exceptions.DevtoolsTargetCrashException: On any other error, the most likely explanation is that the devtool's target crashed. """ if isinstance(error, websocket.WebSocketTimeoutException): new_error = exceptions.TimeoutException() new_error.AddDebuggingMessage( exceptions.AppCrashException(self.app, 'The app is probably crashed:\n')) else: new_error = exceptions.DevtoolsTargetCrashException(self.app) original_error_msg = 'Original exception:\n' + str(error) new_error.AddDebuggingMessage(original_error_msg) self._AddDebuggingInformation(new_error) raise new_error, None, sys.exc_info()[2]
def _HandleDevToolsConnectionError(self, err_msg): if not self._browser_backend.IsAppRunning(): raise exceptions.BrowserGoneException(self.app, err_msg) elif not self._browser_backend.HasBrowserFinishedLaunching(): raise exceptions.BrowserConnectionGoneException(self.app, err_msg) else: raise exceptions.DevtoolsTargetCrashException(self.app, err_msg)
def __init__(self, browser_backend, context, timeout=60): super(InspectorBackend, self).__init__(self._HandleError) self.RegisterDomain('Inspector', self._HandleInspectorDomainNotification) self._browser_backend = browser_backend self._context = context logging.debug('InspectorBackend._Connect() to %s', self.debugger_url) try: self.Connect(self.debugger_url) except (websocket.WebSocketException, util.TimeoutException): err_msg = sys.exc_info()[1] if not self._browser_backend.IsAppRunning(): raise exceptions.BrowserGoneException(self.app, err_msg) elif not self._browser_backend.HasBrowserFinishedLaunching(): raise exceptions.BrowserConnectionGoneException(self.app, err_msg) else: raise exceptions.DevtoolsTargetCrashException(self.app, err_msg) self._console = inspector_console.InspectorConsole(self) self._memory = inspector_memory.InspectorMemory(self) self._page = inspector_page.InspectorPage(self, timeout=timeout) self._runtime = inspector_runtime.InspectorRuntime(self) self._timeline = inspector_timeline.InspectorTimeline(self) self._network = inspector_network.InspectorNetwork(self) self._timeline_model = None
def _HandleInspectorDomainNotification(self, res): if (res['method'] == 'Inspector.detached' and res.get('params', {}).get('reason', '') == 'replaced_with_devtools'): self._WaitForInspectorToGoAwayAndReconnect() return if res['method'] == 'Inspector.targetCrashed': raise exceptions.DevtoolsTargetCrashException(self.app)
def _HandleDevToolsConnectionError(self, err_msg): """Call when handling errors in connecting to the DevTools websocket. This can be overwritten by sub-classes to further specify the exceptions which should be thrown. """ raise exceptions.DevtoolsTargetCrashException(self.app, err_msg)
def _WaitForInspectorToGoAway(self): self._websocket.Disconnect() raw_input('The connection to Chrome was lost to the inspector ui.\n' 'Please close the inspector and press enter to resume ' 'Telemetry run...') raise exceptions.DevtoolsTargetCrashException( self.app, 'Devtool connection with the browser was interrupted due to ' 'the opening of an inspector.')
def __getitem__(self, index): self._Update() if index >= len(self._filtered_context_ids): raise exceptions.DevtoolsTargetCrashException( self.app, 'Web content with index %s may have crashed. ' 'filtered_context_ids = %s' % (index, repr(self._filtered_context_ids))) context_id = self._filtered_context_ids[index] return self.GetBackendFromContextId(context_id)
def __init__(self, benchmark, name, manager_mock=None): super(CrashingPage, self).__init__(benchmark, name, manager_mock=manager_mock) self.RunNavigateSteps.side_effect = ( exceptions.DevtoolsTargetCrashException(None))