Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: telemetry/telemetry/internal/backends/chrome_inspector/inspector_backend.py

Issue 3018603002: Add tab.StopAllServiceWorkers() (Closed)
Patch Set: edit comment Created 3 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | telemetry/telemetry/internal/backends/chrome_inspector/inspector_serviceworker.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4
5 import functools 5 import functools
6 import logging 6 import logging
7 import socket 7 import socket
8 import sys 8 import sys
9 9
10 from py_trace_event import trace_event 10 from py_trace_event import trace_event
11 11
12 from telemetry.core import exceptions 12 from telemetry.core import exceptions
13 from telemetry import decorators 13 from telemetry import decorators
14 from telemetry.internal.backends.chrome_inspector import devtools_http 14 from telemetry.internal.backends.chrome_inspector import devtools_http
15 from telemetry.internal.backends.chrome_inspector import inspector_console 15 from telemetry.internal.backends.chrome_inspector import inspector_console
16 from telemetry.internal.backends.chrome_inspector import inspector_memory 16 from telemetry.internal.backends.chrome_inspector import inspector_memory
17 from telemetry.internal.backends.chrome_inspector import inspector_page 17 from telemetry.internal.backends.chrome_inspector import inspector_page
18 from telemetry.internal.backends.chrome_inspector import inspector_runtime 18 from telemetry.internal.backends.chrome_inspector import inspector_runtime
19 from telemetry.internal.backends.chrome_inspector import inspector_serviceworker
19 from telemetry.internal.backends.chrome_inspector import inspector_storage 20 from telemetry.internal.backends.chrome_inspector import inspector_storage
20 from telemetry.internal.backends.chrome_inspector import inspector_websocket 21 from telemetry.internal.backends.chrome_inspector import inspector_websocket
21 from telemetry.internal.backends.chrome_inspector import websocket 22 from telemetry.internal.backends.chrome_inspector import websocket
22 from telemetry.util import js_template 23 from telemetry.util import js_template
23 24
24 import py_utils 25 import py_utils
25 26
26 27
27 def _HandleInspectorWebSocketExceptions(func): 28 def _HandleInspectorWebSocketExceptions(func):
28 """Decorator for converting inspector_websocket exceptions. 29 """Decorator for converting inspector_websocket exceptions.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 self._context = context 66 self._context = context
66 67
67 logging.debug('InspectorBackend._Connect() to %s', self.debugger_url) 68 logging.debug('InspectorBackend._Connect() to %s', self.debugger_url)
68 try: 69 try:
69 self._websocket.Connect(self.debugger_url, timeout) 70 self._websocket.Connect(self.debugger_url, timeout)
70 self._console = inspector_console.InspectorConsole(self._websocket) 71 self._console = inspector_console.InspectorConsole(self._websocket)
71 self._memory = inspector_memory.InspectorMemory(self._websocket) 72 self._memory = inspector_memory.InspectorMemory(self._websocket)
72 self._page = inspector_page.InspectorPage( 73 self._page = inspector_page.InspectorPage(
73 self._websocket, timeout=timeout) 74 self._websocket, timeout=timeout)
74 self._runtime = inspector_runtime.InspectorRuntime(self._websocket) 75 self._runtime = inspector_runtime.InspectorRuntime(self._websocket)
76 self._serviceworker = inspector_serviceworker.InspectorServiceWorker(
77 self._websocket, timeout=timeout)
75 self._storage = inspector_storage.InspectorStorage(self._websocket) 78 self._storage = inspector_storage.InspectorStorage(self._websocket)
76 except (websocket.WebSocketException, exceptions.TimeoutException, 79 except (websocket.WebSocketException, exceptions.TimeoutException,
77 py_utils.TimeoutException) as e: 80 py_utils.TimeoutException) as e:
78 self._ConvertExceptionFromInspectorWebsocket(e) 81 self._ConvertExceptionFromInspectorWebsocket(e)
79 82
80 def Disconnect(self): 83 def Disconnect(self):
81 """Disconnects the inspector websocket. 84 """Disconnects the inspector websocket.
82 85
83 This method intentionally leaves the self._websocket object around, so that 86 This method intentionally leaves the self._websocket object around, so that
84 future calls it to it will fail with a relevant error. 87 future calls it to it will fail with a relevant error.
(...skipping 18 matching lines...) Expand all
103 return self._devtools_client.GetUrl(self.id) 106 return self._devtools_client.GetUrl(self.id)
104 107
105 @property 108 @property
106 def id(self): # pylint: disable=invalid-name 109 def id(self): # pylint: disable=invalid-name
107 return self._context['id'] 110 return self._context['id']
108 111
109 @property 112 @property
110 def debugger_url(self): 113 def debugger_url(self):
111 return self._context['webSocketDebuggerUrl'] 114 return self._context['webSocketDebuggerUrl']
112 115
116 def StopAllServiceWorkers(self, timeout):
117 self._serviceworker.StopAllWorkers(timeout)
118
113 def ClearDataForOrigin(self, url, timeout): 119 def ClearDataForOrigin(self, url, timeout):
114 self._storage.ClearDataForOrigin(url, timeout) 120 self._storage.ClearDataForOrigin(url, timeout)
115 121
116 def GetWebviewInspectorBackends(self): 122 def GetWebviewInspectorBackends(self):
117 """Returns a list of InspectorBackend instances associated with webviews. 123 """Returns a list of InspectorBackend instances associated with webviews.
118 124
119 Raises: 125 Raises:
120 devtools_http.DevToolsClientConnectionError 126 devtools_http.DevToolsClientConnectionError
121 """ 127 """
122 inspector_backends = [] 128 inspector_backends = []
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 error.AddDebuggingMessage(msg) 513 error.AddDebuggingMessage(msg)
508 error.AddDebuggingMessage('Debugger url: %s' % self.debugger_url) 514 error.AddDebuggingMessage('Debugger url: %s' % self.debugger_url)
509 515
510 @_HandleInspectorWebSocketExceptions 516 @_HandleInspectorWebSocketExceptions
511 def _EvaluateJavaScript(self, expression, context_id, timeout): 517 def _EvaluateJavaScript(self, expression, context_id, timeout):
512 return self._runtime.Evaluate(expression, context_id, timeout) 518 return self._runtime.Evaluate(expression, context_id, timeout)
513 519
514 @_HandleInspectorWebSocketExceptions 520 @_HandleInspectorWebSocketExceptions
515 def CollectGarbage(self): 521 def CollectGarbage(self):
516 self._page.CollectGarbage() 522 self._page.CollectGarbage()
OLDNEW
« no previous file with comments | « no previous file | telemetry/telemetry/internal/backends/chrome_inspector/inspector_serviceworker.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698