summaryrefslogtreecommitdiffstats
path: root/devtools/client/fronts/worker
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/client/fronts/worker
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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.js63
4 files changed, 183 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..5c71065867
--- /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("devtools/shared/specs/worker/push-subscription");
+const {
+ FrontClassWithSpec,
+ registerFront,
+} = require("devtools/shared/protocol");
+
+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..6dbe836962
--- /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("devtools/shared/specs/worker/service-worker-registration");
+const {
+ FrontClassWithSpec,
+ registerFront,
+ types,
+} = require("devtools/shared/protocol");
+
+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..39480f95a3
--- /dev/null
+++ b/devtools/client/fronts/worker/service-worker.js
@@ -0,0 +1,63 @@
+/* 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("devtools/shared/specs/worker/service-worker");
+const {
+ FrontClassWithSpec,
+ registerFront,
+} = require("devtools/shared/protocol");
+const { Ci } = require("chrome");
+const { LocalizationHelper } = require("devtools/shared/l10n");
+
+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);