Bug 1605399 - Label service workers using their state, r=jdescottes.
authorBrian Hackett <bhackett1024@gmail.com>
Mon, 06 Jan 2020 17:22:47 +0000
changeset 508941 4a7523542f8f2a2e7a69ad41ea0f8040debb2da5
parent 508940 893227db52d9178fadb7bed8fef92f8feb10c041
child 508942 83c4915286181d1ceed0a65d5ac1ee50c9d71907
push id36986
push usernerli@mozilla.com
push dateMon, 06 Jan 2020 21:54:03 +0000
treeherdermozilla-central@e6427fac5ee8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1605399
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1605399 - Label service workers using their state, r=jdescottes. Differential Revision: https://phabricator.services.mozilla.com/D57998
devtools/client/debugger/src/client/firefox/targets.js
devtools/client/debugger/test/mochitest/browser_dbg-windowless-service-workers.js
devtools/shared/fronts/worker/service-worker.js
--- a/devtools/client/debugger/src/client/firefox/targets.js
+++ b/devtools/client/debugger/src/client/firefox/targets.js
@@ -102,33 +102,33 @@ async function listWorkerTargets(args: A
 
   for (const front of serviceWorkerRegistrations) {
     const {
       activeWorker,
       waitingWorker,
       installingWorker,
       evaluatingWorker,
     } = front;
-    await maybeMarkServiceWorker(activeWorker, "active");
-    await maybeMarkServiceWorker(waitingWorker, "waiting");
-    await maybeMarkServiceWorker(installingWorker, "installing");
-    await maybeMarkServiceWorker(evaluatingWorker, "evaluating");
+    await maybeMarkServiceWorker(activeWorker);
+    await maybeMarkServiceWorker(waitingWorker);
+    await maybeMarkServiceWorker(installingWorker);
+    await maybeMarkServiceWorker(evaluatingWorker);
   }
 
-  async function maybeMarkServiceWorker(info, status) {
+  async function maybeMarkServiceWorker(info) {
     if (!info) {
       return;
     }
 
     const worker = allWorkers.find(front => front && front.id == info.id);
     if (!worker) {
       return;
     }
 
-    worker.debuggerServiceWorkerStatus = status;
+    worker.debuggerServiceWorkerStatus = info.stateText;
     if (!workers.includes(worker)) {
       workers.push(worker);
     }
   }
 
   return workers;
 }
 
--- a/devtools/client/debugger/test/mochitest/browser_dbg-windowless-service-workers.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-windowless-service-workers.js
@@ -78,17 +78,17 @@ add_task(async function() {
 add_task(async function() {
   info("Subtest #3");
 
   const toolbox = await openNewTabAndToolbox(EXAMPLE_URL + "doc-service-workers.html", "jsdebugger");
   const dbg = createDebuggerContext(toolbox);
 
   invokeInTab("registerWorker");
   await checkWorkerThreads(dbg, 1);
-  await checkWorkerStatus(dbg, "active");
+  await checkWorkerStatus(dbg, "activated");
 
   const firstTab = gBrowser.selectedTab;
 
   await addTab(EXAMPLE_URL + "service-worker.sjs?setStatus=newServiceWorker");
   await removeTab(gBrowser.selectedTab);
 
   const secondTab = await addTab(EXAMPLE_URL + "doc-service-workers.html");
 
@@ -138,29 +138,29 @@ add_task(async function() {
   await checkWorkerThreads(dbg, 1);
 
   await waitForSource(dbg, "service-worker.sjs");
   const workerSource = findSource(dbg, "service-worker.sjs");
 
   await waitForBreakpointCount(dbg, 1);
   await waitForPaused(dbg);
   assertPausedAtSourceAndLine(dbg, workerSource.id, 2);
-  await checkWorkerStatus(dbg, "evaluating");
+  await checkWorkerStatus(dbg, "parsed");
 
   await addBreakpoint(dbg, "service-worker.sjs", 19);
   await resume(dbg);
   await waitForPaused(dbg);
   assertPausedAtSourceAndLine(dbg, workerSource.id, 19);
   await checkWorkerStatus(dbg, "installing");
 
   await addBreakpoint(dbg, "service-worker.sjs", 5);
   await resume(dbg);
   await waitForPaused(dbg);
   assertPausedAtSourceAndLine(dbg, workerSource.id, 5);
-  await checkWorkerStatus(dbg, "active");
+  await checkWorkerStatus(dbg, "activating");
 
   await resume(dbg);
   invokeInTab("unregisterWorker");
 
   await checkWorkerThreads(dbg, 0);
   await waitForRequestsToSettle(dbg);
   await removeTab(gBrowser.selectedTab);
 });
--- a/devtools/shared/fronts/worker/service-worker.js
+++ b/devtools/shared/fronts/worker/service-worker.js
@@ -5,30 +5,50 @@
 
 const {
   serviceWorkerSpec,
 } = require("devtools/shared/specs/worker/service-worker");
 const {
   FrontClassWithSpec,
   registerFront,
 } = require("devtools/shared/protocol");
+const { Ci } = require("chrome");
 
 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 "parsed";
+      case Ci.nsIServiceWorkerInfo.STATE_INSTALLING:
+        return "installing";
+      case Ci.nsIServiceWorkerInfo.STATE_INSTALLED:
+        return "installed";
+      case Ci.nsIServiceWorkerInfo.STATE_ACTIVATING:
+        return "activating";
+      case Ci.nsIServiceWorkerInfo.STATE_ACTIVATED:
+        return "activated";
+      case Ci.nsIServiceWorkerInfo.STATE_REDUNDANT:
+        return "redundant";
+      default:
+        return "unknown";
+    }
+  }
+
   get id() {
     return this._form.id;
   }
 
   form(form) {
     this.actorID = form.actor;
     this._form = form;
   }