OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 from telemetry.core import exceptions |
| 6 |
| 7 |
| 8 class InspectorServiceWorker(object): |
| 9 def __init__(self, inspector_websocket, timeout): |
| 10 self._websocket = inspector_websocket |
| 11 self._websocket.RegisterDomain('ServiceWorker', self._OnNotification) |
| 12 # ServiceWorker.enable RPC must be called before calling any other methods |
| 13 # in ServiceWorker domain. |
| 14 res = self._websocket.SyncRequest( |
| 15 {'method': 'ServiceWorker.enable'}, timeout) |
| 16 if 'error' in res: |
| 17 raise exceptions.StoryActionError(res['error']['message']) |
| 18 |
| 19 def _OnNotification(self, msg): |
| 20 # TODO: track service worker events |
| 21 # (https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker/) |
| 22 pass |
| 23 |
| 24 def StopAllWorkers(self, timeout): |
| 25 res = self._websocket.SyncRequest( |
| 26 {'method': 'ServiceWorker.stopAllWorkers'}, timeout) |
| 27 if 'error' in res: |
| 28 raise exceptions.StoryActionError(res['error']['message']) |
OLD | NEW |