summaryrefslogtreecommitdiffstats
path: root/devtools/client/fronts/worker
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/fronts/worker')
-rw-r--r--devtools/client/fronts/worker/moz.build11
-rw-r--r--devtools/client/fronts/worker/push-subscription.js30
-rw-r--r--devtools/client/fronts/worker/service-worker-registration.js79
-rw-r--r--devtools/client/fronts/worker/service-worker.js62
4 files changed, 182 insertions, 0 deletions
diff --git a/devtools/client/fronts/worker/moz.build b/devtools/client/fronts/worker/moz.build
new file mode 100644
index 0000000000..dae0e2d606
--- /dev/null
+++ b/devtools/client/fronts/worker/moz.build
@@ -0,0 +1,11 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+DevToolsModules(
+ "push-subscription.js",
+ "service-worker-registration.js",
+ "service-worker.js",
+)
diff --git a/devtools/client/fronts/worker/push-subscription.js b/devtools/client/fronts/worker/push-subscription.js
new file mode 100644
index 0000000000..790b32350e
--- /dev/null
+++ b/devtools/client/fronts/worker/push-subscription.js
@@ -0,0 +1,30 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const {
+ pushSubscriptionSpec,
+} = require("resource://devtools/shared/specs/worker/push-subscription.js");
+const {
+ FrontClassWithSpec,
+ registerFront,
+} = require("resource://devtools/shared/protocol.js");
+
+class PushSubscriptionFront extends FrontClassWithSpec(pushSubscriptionSpec) {
+ get endpoint() {
+ return this._form.endpoint;
+ }
+
+ get quota() {
+ return this._form.quota;
+ }
+
+ form(form) {
+ this.actorID = form.actor;
+ this._form = form;
+ }
+}
+
+exports.PushSubscriptionFront = PushSubscriptionFront;
+registerFront(PushSubscriptionFront);
diff --git a/devtools/client/fronts/worker/service-worker-registration.js b/devtools/client/fronts/worker/service-worker-registration.js
new file mode 100644
index 0000000000..57e2bc400b
--- /dev/null
+++ b/devtools/client/fronts/worker/service-worker-registration.js
@@ -0,0 +1,79 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const {
+ serviceWorkerRegistrationSpec,
+} = require("resource://devtools/shared/specs/worker/service-worker-registration.js");
+const {
+ FrontClassWithSpec,
+ registerFront,
+ types,
+} = require("resource://devtools/shared/protocol.js");
+
+class ServiceWorkerRegistrationFront extends FrontClassWithSpec(
+ serviceWorkerRegistrationSpec
+) {
+ get active() {
+ return this._form.active;
+ }
+
+ get fetch() {
+ return this._form.fetch;
+ }
+
+ get id() {
+ return this.url;
+ }
+
+ get lastUpdateTime() {
+ return this._form.lastUpdateTime;
+ }
+
+ get scope() {
+ return this._form.scope;
+ }
+
+ get type() {
+ return this._form.type;
+ }
+
+ get url() {
+ return this._form.url;
+ }
+
+ get evaluatingWorker() {
+ return this._getServiceWorker("evaluatingWorker");
+ }
+
+ get activeWorker() {
+ return this._getServiceWorker("activeWorker");
+ }
+
+ get installingWorker() {
+ return this._getServiceWorker("installingWorker");
+ }
+
+ get waitingWorker() {
+ return this._getServiceWorker("waitingWorker");
+ }
+
+ _getServiceWorker(type) {
+ const workerForm = this._form[type];
+ if (!workerForm) {
+ return null;
+ }
+ return types.getType("serviceWorker").read(workerForm, this);
+ }
+
+ form(form) {
+ this.actorID = form.actor;
+ this._form = form;
+ // @backward-compat { version 70 } ServiceWorkerRegistration actor now exposes traits
+ this.traits = form.traits || {};
+ }
+}
+
+exports.ServiceWorkerRegistrationFront = ServiceWorkerRegistrationFront;
+registerFront(ServiceWorkerRegistrationFront);
diff --git a/devtools/client/fronts/worker/service-worker.js b/devtools/client/fronts/worker/service-worker.js
new file mode 100644
index 0000000000..604eb388e5
--- /dev/null
+++ b/devtools/client/fronts/worker/service-worker.js
@@ -0,0 +1,62 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const {
+ serviceWorkerSpec,
+} = require("resource://devtools/shared/specs/worker/service-worker.js");
+const {
+ FrontClassWithSpec,
+ registerFront,
+} = require("resource://devtools/shared/protocol.js");
+const { LocalizationHelper } = require("resource://devtools/shared/l10n.js");
+
+const L10N = new LocalizationHelper(
+ "devtools/client/locales/debugger.properties"
+);
+
+class ServiceWorkerFront extends FrontClassWithSpec(serviceWorkerSpec) {
+ get fetch() {
+ return this._form.fetch;
+ }
+
+ get url() {
+ return this._form.url;
+ }
+
+ get state() {
+ return this._form.state;
+ }
+
+ get stateText() {
+ switch (this.state) {
+ case Ci.nsIServiceWorkerInfo.STATE_PARSED:
+ return L10N.getStr("serviceWorkerInfo.parsed");
+ case Ci.nsIServiceWorkerInfo.STATE_INSTALLING:
+ return L10N.getStr("serviceWorkerInfo.installing");
+ case Ci.nsIServiceWorkerInfo.STATE_INSTALLED:
+ return L10N.getStr("serviceWorkerInfo.installed");
+ case Ci.nsIServiceWorkerInfo.STATE_ACTIVATING:
+ return L10N.getStr("serviceWorkerInfo.activating");
+ case Ci.nsIServiceWorkerInfo.STATE_ACTIVATED:
+ return L10N.getStr("serviceWorkerInfo.activated");
+ case Ci.nsIServiceWorkerInfo.STATE_REDUNDANT:
+ return L10N.getStr("serviceWorkerInfo.redundant");
+ default:
+ return L10N.getStr("serviceWorkerInfo.unknown");
+ }
+ }
+
+ get id() {
+ return this._form.id;
+ }
+
+ form(form) {
+ this.actorID = form.actor;
+ this._form = form;
+ }
+}
+
+exports.ServiceWorkerFront = ServiceWorkerFront;
+registerFront(ServiceWorkerFront);