Bug 1651630 - Part 1: Allow start button to work regardless of debugger pref r=jdescottes,fluent-reviewers
authorBelén Albeza <balbeza@mozilla.com>
Thu, 16 Jul 2020 13:13:40 +0000
changeset 541209 81ecc309914f18f30b2b98f9883929e698584dd8
parent 541208 c69a7f114fbf213a7b4b017c301494f79dad1a25
child 541210 f0b1929a924b5ed4aa9904a077900f9a3ec04852
push id37619
push userapavel@mozilla.com
push dateMon, 20 Jul 2020 21:42:26 +0000
treeherdermozilla-central@2f2cb7c9bcce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes, fluent-reviewers
bugs1651630
milestone80.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 1651630 - Part 1: Allow start button to work regardless of debugger pref r=jdescottes,fluent-reviewers Differential Revision: https://phabricator.services.mozilla.com/D83482
devtools/client/application/src/components/service-workers/Worker.js
devtools/client/application/test/browser/browser.ini
devtools/client/application/test/browser/browser_application_panel_disable-start-service-worker.js
devtools/client/application/test/node/components/service-workers/__snapshots__/components_application_panel-Worker.test.js.snap
devtools/client/application/test/node/components/service-workers/components_application_panel-Worker.test.js
devtools/client/locales/en-US/application.ftl
--- a/devtools/client/application/src/components/service-workers/Worker.js
+++ b/devtools/client/application/src/components/service-workers/Worker.js
@@ -69,21 +69,16 @@ class Worker extends PureComponent {
       console.log("Service workers cannot be debugged if they are not running");
       return;
     }
 
     services.openWorkerInDebugger(this.props.worker.workerTargetFront);
   }
 
   start() {
-    if (!this.props.isDebugEnabled) {
-      console.log("Service workers cannot be started in multi-e10s");
-      return;
-    }
-
     if (!this.isActive() || this.isRunning()) {
       console.log("Running or inactive service workers cannot be started");
       return;
     }
 
     this.props.dispatch(startWorker(this.props.worker));
   }
 
@@ -151,37 +146,27 @@ class Worker extends PureComponent {
         className: `js-debug-button`,
         disabled: isDisabled,
         size: "micro",
       })
     );
   }
 
   renderStartButton() {
-    const { isDebugEnabled } = this.props;
-
     // avoid rendering the button at all for workers that are either running,
     // or in a state that prevents them from starting (like waiting)
     if (this.isRunning() || !this.isActive()) {
       return null;
     }
 
-    const isDisabled = !isDebugEnabled;
     return Localized(
-      {
-        id: "serviceworker-worker-start2",
-        // The localized title is only displayed if the debug link is disabled.
-        attrs: {
-          title: !isDisabled,
-        },
-      },
+      { id: "serviceworker-worker-start3" },
       UIButton({
         onClick: this.start,
         className: `js-start-button`,
-        disabled: isDisabled,
         size: "micro",
       })
     );
   }
 
   render() {
     const { worker } = this.props;
     const statusText = this.getLocalizedStatus();
--- a/devtools/client/application/test/browser/browser.ini
+++ b/devtools/client/application/test/browser/browser.ini
@@ -26,18 +26,16 @@ support-files =
   !/devtools/client/debugger/test/mochitest/helpers/context.js
   !/devtools/client/shared/test/frame-script-utils.js
   !/devtools/client/shared/test/shared-head.js
   !/devtools/client/shared/test/telemetry-test-helpers.js
 
 # Worker-related tests
 [browser_application_panel_debug-service-worker.js]
 skip-if = debug || asan || !serviceworker_e10s # Bug 1559591, 1575578, 1588154
-[browser_application_panel_disable-start-service-worker.js]
-skip-if = (os == 'linux' && asan) || debug # Bug 1559487, 1559591
 [browser_application_panel_list-domain-workers.js]
 skip-if = debug # Bug 1559591
 [browser_application_panel_list-multiple-workers-same-registration.js]
 skip-if = debug # Bug 1559591
 [browser_application_panel_list-several-workers.js]
 skip-if = debug # Bug 1559591
 [browser_application_panel_list-single-worker.js]
 skip-if = debug # Bug 1559591
deleted file mode 100644
--- a/devtools/client/application/test/browser/browser_application_panel_disable-start-service-worker.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const TAB_URL = URL_ROOT + "resources/service-workers/simple.html";
-
-/**
- * Tests that Start button is disabled for service workers, when they cannot be debugged
- */
-add_task(async function() {
-  await enableApplicationPanel();
-
-  // Setting a low idle_timeout and idle_extended_timeout will allow the service worker
-  // to reach the STOPPED state quickly, which will allow us to test the start button.
-  // The default value is 30000 milliseconds.
-  info("Set a low service worker idle timeout");
-  await pushPref("dom.serviceWorkers.idle_timeout", 1000);
-  await pushPref("dom.serviceWorkers.idle_extended_timeout", 1000);
-
-  // disable sw debugging
-  info("Disable service worker debugging");
-  await pushPref(
-    "devtools.debugger.features.windowless-service-workers",
-    false
-  );
-
-  const { panel, tab, target } = await openNewTabAndApplicationPanel(TAB_URL);
-  const doc = panel.panelWin.document;
-
-  selectPage(panel, "service-workers");
-
-  await waitForWorkerRegistration(tab);
-
-  info("Wait until the service worker appears in the application panel");
-  await waitUntil(() => getWorkerContainers(doc).length === 1);
-
-  info("Wait until the start button is displayed");
-  const container = getWorkerContainers(doc)[0];
-  await waitUntil(() => container.querySelector(".js-start-button"));
-  ok(
-    container.querySelector(".js-start-button").disabled,
-    "Start button is disabled"
-  );
-
-  await unregisterAllWorkers(target.client, doc);
-
-  // close the tab
-  info("Closing the tab.");
-  await BrowserTestUtils.removeTab(tab);
-});
--- a/devtools/client/application/test/node/components/service-workers/__snapshots__/components_application_panel-Worker.test.js.snap
+++ b/devtools/client/application/test/node/components/service-workers/__snapshots__/components_application_panel-Worker.test.js.snap
@@ -162,26 +162,20 @@ exports[`Worker Renders the expected sna
     <dd>
       <span
         className="js-worker-status worker__status worker__status--active"
       >
         serviceworker-worker-status-stopped
       </span>
        
       <Localized
-        attrs={
-          Object {
-            "title": true,
-          }
-        }
-        id="serviceworker-worker-start2"
+        id="serviceworker-worker-start3"
       >
         <UIButton
           className="js-start-button"
-          disabled={false}
           onClick={[Function]}
           size="micro"
         />
       </Localized>
     </dd>
   </dl>
 </section>
 `;
--- a/devtools/client/application/test/node/components/service-workers/components_application_panel-Worker.test.js
+++ b/devtools/client/application/test/node/components/service-workers/components_application_panel-Worker.test.js
@@ -51,22 +51,41 @@ describe("Worker", () => {
         store,
       })
     ).dive();
 
     // ensure proper status
     expect(wrapper.find(".js-worker-status").text()).toBe(
       "serviceworker-worker-status-stopped"
     );
-    // check that Start button is not available
+    // check that Start button is available
     expect(wrapper.find(".js-start-button")).toHaveLength(1);
 
     expect(wrapper).toMatchSnapshot();
   });
 
+  it("Renders the start button even if debugging workers is disabled", () => {
+    const store = setupStore({});
+
+    const wrapper = shallow(
+      Worker({
+        isDebugEnabled: false,
+        worker: WORKER_STOPPED,
+        store,
+      })
+    ).dive();
+
+    // ensure proper status
+    expect(wrapper.find(".js-worker-status").text()).toBe(
+      "serviceworker-worker-status-stopped"
+    );
+    // check that Start button is available
+    expect(wrapper.find(".js-start-button")).toHaveLength(1);
+  });
+
   it("Renders the expected snapshot for a non-active worker", () => {
     const store = setupStore({});
 
     const wrapper = shallow(
       Worker({
         isDebugEnabled: true,
         worker: WORKER_WAITING,
         store,
--- a/devtools/client/locales/en-US/application.ftl
+++ b/devtools/client/locales/en-US/application.ftl
@@ -28,18 +28,17 @@ serviceworker-worker-debug = Debug
 
 # Text for the debug link displayed for an already started Service Worker, when we
 # are in multi e10s mode, which effectively disables this link.
 serviceworker-worker-debug-forbidden = Debug
   .title = Can only debug service workers if multi e10s is disabled
 
 # Text for the start link displayed for a registered but not running Service Worker.
 # Clicking on the link will attempt to start the service worker.
-serviceworker-worker-start2 = Start
-  .title = Can only start service workers if multi e10s is disabled
+serviceworker-worker-start3 = Start
 
 # Text displayed for the updated time of the service worker. The <time> element will
 # display the last update time of the service worker script.
 serviceworker-worker-updated = Updated <time>{ DATETIME($date, month: "long", year: "numeric", day: "numeric", hour: "numeric", minute: "numeric", second: "numeric") }</time>
 
 # Text displayed next to the URL for the source of the service worker (e-g. "Source my/path/to/worker-js")
 serviceworker-worker-source = Source