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

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

Issue 3013263002: Handle error code METHOD_NOT_FOUND_CODE in InspectorServiceWorker.StopAllWorkers() (Closed)
Patch Set: raise NotImplementedError 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 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 from telemetry.internal.backends.chrome_inspector import inspector_websocket
5 from telemetry.core import exceptions 6 from telemetry.core import exceptions
6 7
7
8 class InspectorServiceWorker(object): 8 class InspectorServiceWorker(object):
9 def __init__(self, inspector_websocket, timeout): 9 def __init__(self, inspector_socket, timeout):
10 self._websocket = inspector_websocket 10 self._websocket = inspector_socket
11 self._websocket.RegisterDomain('ServiceWorker', self._OnNotification) 11 self._websocket.RegisterDomain('ServiceWorker', self._OnNotification)
12 # ServiceWorker.enable RPC must be called before calling any other methods 12 # ServiceWorker.enable RPC must be called before calling any other methods
13 # in ServiceWorker domain. 13 # in ServiceWorker domain.
14 res = self._websocket.SyncRequest( 14 res = self._websocket.SyncRequest(
15 {'method': 'ServiceWorker.enable'}, timeout) 15 {'method': 'ServiceWorker.enable'}, timeout)
16 if 'error' in res: 16 if 'error' in res:
17 raise exceptions.StoryActionError(res['error']['message']) 17 raise exceptions.StoryActionError(res['error']['message'])
18 18
19 def _OnNotification(self, msg): 19 def _OnNotification(self, msg):
20 # TODO: track service worker events 20 # TODO: track service worker events
21 # (https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker/) 21 # (https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker/)
22 pass 22 pass
23 23
24 def StopAllWorkers(self, timeout): 24 def StopAllWorkers(self, timeout):
25 res = self._websocket.SyncRequest( 25 res = self._websocket.SyncRequest(
26 {'method': 'ServiceWorker.stopAllWorkers'}, timeout) 26 {'method': 'ServiceWorker.stopAllWorkers'}, timeout)
27 if 'error' in res: 27 if 'error' in res:
28 code = res['error']['code']
29 if code == inspector_websocket.InspectorWebsocket.METHOD_NOT_FOUND_CODE:
30 raise NotImplementedError(
31 'DevTools method ServiceWorker.stopAllWorkers is not supported by '
32 'this browser.')
28 raise exceptions.StoryActionError(res['error']['message']) 33 raise exceptions.StoryActionError(res['error']['message'])
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698