diff --git a/devtools/client/application/initializer.js b/devtools/client/application/initializer.js index 96e9a47321fc..0e0bfe9788a2 100644 --- a/devtools/client/application/initializer.js +++ b/devtools/client/application/initializer.js @@ -28,7 +28,7 @@ const actions = require("./src/actions/index"); const { WorkersListener } = require("devtools/client/shared/workers-listener"); -const { services } = require("./src/modules/application-services"); +const { services } = require("./src/modules/services"); const App = createFactory(require("./src/components/App")); @@ -49,6 +49,7 @@ window.Application = { this.store = configureStore(); this.actions = bindActionCreators(actions, this.store.dispatch); + this.serviceWorkerRegistrationFronts = []; services.init(this.toolbox); @@ -103,9 +104,7 @@ window.Application = { ? (await this.deviceFront.getDescription()).canDebugServiceWorkers : false; - this.actions.updateCanDebugWorkers( - canDebugWorkers && services.features.doesDebuggerSupportWorkers - ); + this.actions.updateCanDebugWorkers(canDebugWorkers); }, destroy() { diff --git a/devtools/client/application/src/actions/manifest.js b/devtools/client/application/src/actions/manifest.js index 3ae3d5396d53..0ff90c3b028e 100644 --- a/devtools/client/application/src/actions/manifest.js +++ b/devtools/client/application/src/actions/manifest.js @@ -6,10 +6,7 @@ const { l10n } = require("../modules/l10n"); -const { - services, - ManifestDevToolsError, -} = require("../modules/application-services"); +const { services, ManifestDevToolsError } = require("../modules/services"); const { FETCH_MANIFEST_FAILURE, FETCH_MANIFEST_START, diff --git a/devtools/client/application/src/components/service-workers/Worker.js b/devtools/client/application/src/components/service-workers/Worker.js index 3760f320e197..f99205028d62 100644 --- a/devtools/client/application/src/components/service-workers/Worker.js +++ b/devtools/client/application/src/components/service-workers/Worker.js @@ -31,11 +31,17 @@ const { const FluentReact = require("devtools/client/shared/vendor/fluent-react"); const Localized = createFactory(FluentReact.Localized); -const { services } = require("../../modules/application-services"); const Types = require("../../types/index"); const UIButton = createFactory(require("../ui/UIButton")); +loader.lazyRequireGetter( + this, + "gDevToolsBrowser", + "devtools/client/framework/devtools-browser", + true +); + /** * This component is dedicated to display a worker, more accurately a service worker, in * the list of workers displayed in the application panel. It displays information about @@ -64,7 +70,8 @@ class Worker extends PureComponent { return; } - services.openWorkerInDebugger(this.props.worker.workerTargetFront); + const { workerTargetFront } = this.props.worker; + gDevToolsBrowser.openWorkerToolbox(workerTargetFront); } start() { diff --git a/devtools/client/application/src/components/service-workers/WorkerListEmpty.js b/devtools/client/application/src/components/service-workers/WorkerListEmpty.js index 648c769bbb49..da39ce71f863 100644 --- a/devtools/client/application/src/components/service-workers/WorkerListEmpty.js +++ b/devtools/client/application/src/components/service-workers/WorkerListEmpty.js @@ -21,7 +21,7 @@ const { const FluentReact = require("devtools/client/shared/vendor/fluent-react"); const Localized = createFactory(FluentReact.Localized); -const { services } = require("../../modules/application-services"); +const { services } = require("../../modules/services"); const DOC_URL = "https://developer.mozilla.org/docs/Web/API/Service_Worker_API/Using_Service_Workers" + diff --git a/devtools/client/application/src/modules/moz.build b/devtools/client/application/src/modules/moz.build index af4edb800952..f4b8f4cb1146 100644 --- a/devtools/client/application/src/modules/moz.build +++ b/devtools/client/application/src/modules/moz.build @@ -3,6 +3,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. DevToolsModules( - 'application-services.js', 'l10n.js', + 'services.js', ) diff --git a/devtools/client/application/src/modules/application-services.js b/devtools/client/application/src/modules/services.js similarity index 73% rename from devtools/client/application/src/modules/application-services.js rename to devtools/client/application/src/modules/services.js index 0931ddf7bf18..f4cf050f5059 100644 --- a/devtools/client/application/src/modules/application-services.js +++ b/devtools/client/application/src/modules/services.js @@ -4,8 +4,6 @@ "use strict"; -const Services = require("Services"); - class ManifestDevToolsError extends Error { constructor(...params) { super(...params); @@ -14,16 +12,9 @@ class ManifestDevToolsError extends Error { } } -class ApplicationServices { +class Services { init(toolbox) { this._toolbox = toolbox; - - this.features = { - doesDebuggerSupportWorkers: Services.prefs.getBoolPref( - "devtools.debugger.features.windowless-service-workers", - false - ), - }; } selectTool(toolId) { @@ -31,11 +22,6 @@ class ApplicationServices { return this._toolbox.selectTool(toolId); } - async openWorkerInDebugger(workerTargetFront) { - const debuggerPanel = await this.selectTool("jsdebugger"); - debuggerPanel.selectWorker(workerTargetFront); - } - async fetchManifest() { let response; @@ -68,5 +54,5 @@ class ApplicationServices { module.exports = { ManifestDevToolsError, // exports a singleton, which will be used across all application panel modules - services: new ApplicationServices(), + services: new Services(), }; diff --git a/devtools/client/application/test/browser/browser.ini b/devtools/client/application/test/browser/browser.ini index 526b9629571a..2c5fc2930408 100644 --- a/devtools/client/application/test/browser/browser.ini +++ b/devtools/client/application/test/browser/browser.ini @@ -30,7 +30,7 @@ support-files = [browser_application_panel_debug-service-worker.js] skip-if = debug || asan # Bug 1559591, 1575578 [browser_application_panel_disable-start-service-worker.js] -skip-if = (os == 'linux' && asan) || debug # Bug 1559487, 1559591 +skip-if = (os == 'linux' && asan) || debug || serviceworker_e10s # Bug 1559487, 1559591, 1447197 [browser_application_panel_list-domain-workers.js] skip-if = debug # Bug 1559591 [browser_application_panel_list-several-workers.js] @@ -49,4 +49,4 @@ skip-if = true # Bug 1467256, 1559591 [browser_application_panel_unregister-worker.js] skip-if = debug # Bug 1559591 [browser_application_panel_start-service-worker.js] -skip-if = (os == 'linux' && asan) || debug # Bug 1559487, 1559591 +skip-if = (os == 'linux' && asan) || debug # Bug 1559487, 1559591, 1447197 diff --git a/devtools/client/application/test/browser/browser_application_panel_debug-service-worker.js b/devtools/client/application/test/browser/browser_application_panel_debug-service-worker.js index 05fa62042aad..1e13e0ce9a53 100644 --- a/devtools/client/application/test/browser/browser_application_panel_debug-service-worker.js +++ b/devtools/client/application/test/browser/browser_application_panel_debug-service-worker.js @@ -20,10 +20,7 @@ const TAB_URL = URL_ROOT + "resources/service-workers/debug.html"; add_task(async function() { await enableApplicationPanel(); - const { panel, tab, target, toolbox } = await openNewTabAndApplicationPanel( - TAB_URL - ); - + const { panel, tab, target } = await openNewTabAndApplicationPanel(TAB_URL); const doc = panel.panelWin.document; selectPage(panel, "service-workers"); @@ -38,28 +35,39 @@ add_task(async function() { return button && !button.disabled; }); - info("Click on the debug button and wait for debugger to be ready"); + info("Click on the debug button and wait for the new toolbox to be ready"); + const onToolboxReady = gDevTools.once("toolbox-ready"); + const debugButton = container.querySelector(".js-debug-button"); debugButton.click(); - await waitFor(() => toolbox.getPanel("jsdebugger")); - // add a breakpoint at line 11 - const debuggerContext = createDebuggerContext(toolbox); + const serviceWorkerToolbox = await onToolboxReady; + await serviceWorkerToolbox.selectTool("jsdebugger"); + const debuggerContext = createDebuggerContext(serviceWorkerToolbox); + + await waitForSources(debuggerContext, "debug-sw.js"); + await selectSource(debuggerContext, "debug-sw.js"); await waitForLoadedSource(debuggerContext, "debug-sw.js"); - await addBreakpoint(debuggerContext, "debug-sw.js", 11); - // force a pause at the breakpoint - info("Invoke fetch, expect the service worker script to pause on line 11"); - await ContentTask.spawn(tab.linkedBrowser, {}, async function() { - content.wrappedJSObject.fetchFromWorker(); - }); + await addBreakpoint(debuggerContext, "debug-sw.js", 8); + + info( + "Reload the main tab, expect the service worker script to pause on line 8" + ); + tab.linkedBrowser.reload(); + await waitForPaused(debuggerContext); assertPausedLocation(debuggerContext); await resume(debuggerContext); - // remove breakpoint const workerScript = findSource(debuggerContext, "debug-sw.js"); - await removeBreakpoint(debuggerContext, workerScript.id, 11); + await removeBreakpoint(debuggerContext, workerScript.id, 8); + + info("Destroy the worker toolbox"); + await serviceWorkerToolbox.destroy(); + + info("Wait until the focus goes back to the main window"); + await waitUntil(() => gBrowser.selectedBrowser === tab.linkedBrowser); await unregisterAllWorkers(target.client); }); diff --git a/devtools/client/application/test/browser/browser_application_panel_disable-start-service-worker.js b/devtools/client/application/test/browser/browser_application_panel_disable-start-service-worker.js index d8ee16ab76ce..a9c51a2be679 100644 --- a/devtools/client/application/test/browser/browser_application_panel_disable-start-service-worker.js +++ b/devtools/client/application/test/browser/browser_application_panel_disable-start-service-worker.js @@ -11,19 +11,9 @@ const TAB_URL = URL_ROOT + "resources/service-workers/simple.html"; 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 + // disable sw debugging by increasing the # of processes and thus multi-e10s kicking in info("Disable service worker debugging"); - await pushPref( - "devtools.debugger.features.windowless-service-workers", - false - ); + await pushPref("dom.ipc.processCount", 8); const { panel, tab, target } = await openNewTabAndApplicationPanel(TAB_URL); const doc = panel.panelWin.document; diff --git a/devtools/client/application/test/browser/head.js b/devtools/client/application/test/browser/head.js index 2c3f74f73af9..b0efff7ef2bb 100644 --- a/devtools/client/application/test/browser/head.js +++ b/devtools/client/application/test/browser/head.js @@ -25,9 +25,6 @@ async function enableServiceWorkerDebugging() { // SW debugging in multi-e10s. await pushPref("dom.ipc.processCount", 1); - // Enable service workers in the debugger - await pushPref("devtools.debugger.features.windowless-service-workers", true); - // Wait for dom.ipc.processCount to be updated before releasing processes. Services.ppmm.releaseCachedProcesses(); } diff --git a/devtools/client/application/test/browser/resources/service-workers/debug-sw.js b/devtools/client/application/test/browser/resources/service-workers/debug-sw.js index 7acf2545de6c..d3bb313e29f3 100644 --- a/devtools/client/application/test/browser/resources/service-workers/debug-sw.js +++ b/devtools/client/application/test/browser/resources/service-workers/debug-sw.js @@ -3,16 +3,8 @@ "use strict"; -self.addEventListener("activate", event => { - event.waitUntil(self.clients.claim()); -}); - +// Bug 1328293 self.onfetch = function(event) { - const url = event.request.url; - - const response = url.endsWith("test") - ? new Response("lorem ipsum", { statusText: "OK" }) - : fetch(event.request); - - event.respondWith(response); + const a = 5; + console.log(a); }; diff --git a/devtools/client/application/test/browser/resources/service-workers/debug.html b/devtools/client/application/test/browser/resources/service-workers/debug.html index f0f16858fd57..da70ab66efca 100644 --- a/devtools/client/application/test/browser/resources/service-workers/debug.html +++ b/devtools/client/application/test/browser/resources/service-workers/debug.html @@ -11,15 +11,6 @@ - -

This page has a fetchFromWorker() function.

diff --git a/devtools/client/application/test/node/actions/actions_application_panel-manifest.test.js b/devtools/client/application/test/node/actions/actions_application_panel-manifest.test.js index 4e6f3450676a..1dc819e9b15d 100644 --- a/devtools/client/application/test/node/actions/actions_application_panel-manifest.test.js +++ b/devtools/client/application/test/node/actions/actions_application_panel-manifest.test.js @@ -12,7 +12,7 @@ const { setupStore } = require("devtools/client/application/test/node/helpers"); const { ManifestDevToolsError, services, -} = require("devtools/client/application/src/modules/application-services"); +} = require("devtools/client/application/src/modules/services"); const { FETCH_MANIFEST_FAILURE, diff --git a/devtools/client/debugger/panel.js b/devtools/client/debugger/panel.js index 702c6bcf692e..cbce63a7b837 100644 --- a/devtools/client/debugger/panel.js +++ b/devtools/client/debugger/panel.js @@ -9,12 +9,6 @@ loader.lazyRequireGetter( "devtools/client/shared/link", true ); -loader.lazyRequireGetter( - this, - "features", - "devtools/client/debugger/src/utils/prefs", - true -); const DBG_STRINGS_URI = "devtools/client/locales/debugger.properties"; const L10N = new LocalizationHelper(DBG_STRINGS_URI); @@ -177,29 +171,6 @@ DebuggerPanel.prototype = { return this._actions.selectSourceURL(cx, url, { line, column }); }, - async selectWorker(workerTargetFront) { - const threadId = workerTargetFront.threadFront.actorID; - const isThreadAvailable = this._selectors - .getThreads(this._getState()) - .find(x => x.actor === threadId); - - if (!features.windowlessServiceWorkers) { - console.error( - "Selecting a worker needs the pref debugger.features.windowless-service-workers set to true" - ); - } else if (!isThreadAvailable) { - console.error(`Worker ${threadId} is not available for debugging`); - } else { - // select worker's thread - const cx = this._selectors.getContext(this._getState()); - this._actions.selectThread(cx, threadId); - - // select worker's source - const source = this.getSourceByURL(workerTargetFront._url); - await this.selectSource(source.id, 1, 1); - } - }, - previewPausedLocation(location) { return this._actions.previewPausedLocation(location); },