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

Unified Diff: telemetry/telemetry/internal/backends/chrome_inspector/inspector_serviceworker.py

Issue 3018603002: Add tab.StopAllServiceWorkers() (Closed)
Patch Set: call ServiceWorker.enable on initializing InspectorServiceWorker Created 3 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: telemetry/telemetry/internal/backends/chrome_inspector/inspector_serviceworker.py
diff --git a/telemetry/telemetry/internal/backends/chrome_inspector/inspector_serviceworker.py b/telemetry/telemetry/internal/backends/chrome_inspector/inspector_serviceworker.py
new file mode 100644
index 0000000000000000000000000000000000000000..8ad751ca1e72bc66f5b111713528643723f9fb69
--- /dev/null
+++ b/telemetry/telemetry/internal/backends/chrome_inspector/inspector_serviceworker.py
@@ -0,0 +1,28 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from telemetry.core import exceptions
+
+
+class InspectorServiceWorker(object):
+ def __init__(self, inspector_websocket, timeout):
+ self._websocket = inspector_websocket
+ self._websocket.RegisterDomain('ServiceWorker', self._OnNotification)
+ # This method must be called before calling any other methods in
kouhei (in TOK) 2017/09/25 04:59:32 s/This method/ServiceWorker.enable RPC/
yukiy 2017/09/25 06:31:36 Done.
+ # ServiceWorker domain.
+ res = self._websocket.SyncRequest(
+ {'method': 'ServiceWorker.enable'}, timeout)
+ if 'error' in res:
+ raise exceptions.StoryActionError(res['error']['message'])
+
+ def _OnNotification(self, msg):
+ # TODO: track service worker events
+ # (https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker/)
+ pass
+
+ def StopAllWorkers(self, timeout):
+ res = self._websocket.SyncRequest(
+ {'method': 'ServiceWorker.stopAllWorkers'}, timeout)
+ if 'error' in res:
+ raise exceptions.StoryActionError(res['error']['message'])

Powered by Google App Engine
This is Rietveld 408576698