Backed out 2 changesets (bug 1598629) for causing a high devtools failure rate in browser_application_panel_debug-service-worker.js

Backed out changeset 472f8d632630 (bug 1598629)
Backed out changeset 70bde5ea35f6 (bug 1598629)

--HG--
rename : devtools/client/application/src/modules/application-services.js => devtools/client/application/src/modules/services.js
extra : rebase_source : 86e1193b04ea009195075d59c723a48443f23857
This commit is contained in:
Mihai Alexandru Michis 2019-11-29 19:11:35 +02:00
Родитель cdbba16564
Коммит a6ddb4b9b8
14 изменённых файлов: 49 добавлений и 111 удалений

Просмотреть файл

@ -28,7 +28,7 @@ const actions = require("./src/actions/index");
const { WorkersListener } = require("devtools/client/shared/workers-listener"); 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")); const App = createFactory(require("./src/components/App"));
@ -49,6 +49,7 @@ window.Application = {
this.store = configureStore(); this.store = configureStore();
this.actions = bindActionCreators(actions, this.store.dispatch); this.actions = bindActionCreators(actions, this.store.dispatch);
this.serviceWorkerRegistrationFronts = [];
services.init(this.toolbox); services.init(this.toolbox);
@ -103,9 +104,7 @@ window.Application = {
? (await this.deviceFront.getDescription()).canDebugServiceWorkers ? (await this.deviceFront.getDescription()).canDebugServiceWorkers
: false; : false;
this.actions.updateCanDebugWorkers( this.actions.updateCanDebugWorkers(canDebugWorkers);
canDebugWorkers && services.features.doesDebuggerSupportWorkers
);
}, },
destroy() { destroy() {

Просмотреть файл

@ -6,10 +6,7 @@
const { l10n } = require("../modules/l10n"); const { l10n } = require("../modules/l10n");
const { const { services, ManifestDevToolsError } = require("../modules/services");
services,
ManifestDevToolsError,
} = require("../modules/application-services");
const { const {
FETCH_MANIFEST_FAILURE, FETCH_MANIFEST_FAILURE,
FETCH_MANIFEST_START, FETCH_MANIFEST_START,

Просмотреть файл

@ -31,11 +31,17 @@ const {
const FluentReact = require("devtools/client/shared/vendor/fluent-react"); const FluentReact = require("devtools/client/shared/vendor/fluent-react");
const Localized = createFactory(FluentReact.Localized); const Localized = createFactory(FluentReact.Localized);
const { services } = require("../../modules/application-services");
const Types = require("../../types/index"); const Types = require("../../types/index");
const UIButton = createFactory(require("../ui/UIButton")); 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 * 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 * the list of workers displayed in the application panel. It displays information about
@ -64,7 +70,8 @@ class Worker extends PureComponent {
return; return;
} }
services.openWorkerInDebugger(this.props.worker.workerTargetFront); const { workerTargetFront } = this.props.worker;
gDevToolsBrowser.openWorkerToolbox(workerTargetFront);
} }
start() { start() {

Просмотреть файл

@ -21,7 +21,7 @@ const {
const FluentReact = require("devtools/client/shared/vendor/fluent-react"); const FluentReact = require("devtools/client/shared/vendor/fluent-react");
const Localized = createFactory(FluentReact.Localized); const Localized = createFactory(FluentReact.Localized);
const { services } = require("../../modules/application-services"); const { services } = require("../../modules/services");
const DOC_URL = const DOC_URL =
"https://developer.mozilla.org/docs/Web/API/Service_Worker_API/Using_Service_Workers" + "https://developer.mozilla.org/docs/Web/API/Service_Worker_API/Using_Service_Workers" +

Просмотреть файл

@ -3,6 +3,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
DevToolsModules( DevToolsModules(
'application-services.js',
'l10n.js', 'l10n.js',
'services.js',
) )

Просмотреть файл

@ -4,8 +4,6 @@
"use strict"; "use strict";
const Services = require("Services");
class ManifestDevToolsError extends Error { class ManifestDevToolsError extends Error {
constructor(...params) { constructor(...params) {
super(...params); super(...params);
@ -14,16 +12,9 @@ class ManifestDevToolsError extends Error {
} }
} }
class ApplicationServices { class Services {
init(toolbox) { init(toolbox) {
this._toolbox = toolbox; this._toolbox = toolbox;
this.features = {
doesDebuggerSupportWorkers: Services.prefs.getBoolPref(
"devtools.debugger.features.windowless-service-workers",
false
),
};
} }
selectTool(toolId) { selectTool(toolId) {
@ -31,11 +22,6 @@ class ApplicationServices {
return this._toolbox.selectTool(toolId); return this._toolbox.selectTool(toolId);
} }
async openWorkerInDebugger(workerTargetFront) {
const debuggerPanel = await this.selectTool("jsdebugger");
debuggerPanel.selectWorker(workerTargetFront);
}
async fetchManifest() { async fetchManifest() {
let response; let response;
@ -68,5 +54,5 @@ class ApplicationServices {
module.exports = { module.exports = {
ManifestDevToolsError, ManifestDevToolsError,
// exports a singleton, which will be used across all application panel modules // exports a singleton, which will be used across all application panel modules
services: new ApplicationServices(), services: new Services(),
}; };

Просмотреть файл

@ -30,7 +30,7 @@ support-files =
[browser_application_panel_debug-service-worker.js] [browser_application_panel_debug-service-worker.js]
skip-if = debug || asan # Bug 1559591, 1575578 skip-if = debug || asan # Bug 1559591, 1575578
[browser_application_panel_disable-start-service-worker.js] [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] [browser_application_panel_list-domain-workers.js]
skip-if = debug # Bug 1559591 skip-if = debug # Bug 1559591
[browser_application_panel_list-several-workers.js] [browser_application_panel_list-several-workers.js]
@ -49,4 +49,4 @@ skip-if = true # Bug 1467256, 1559591
[browser_application_panel_unregister-worker.js] [browser_application_panel_unregister-worker.js]
skip-if = debug # Bug 1559591 skip-if = debug # Bug 1559591
[browser_application_panel_start-service-worker.js] [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

Просмотреть файл

@ -20,10 +20,7 @@ const TAB_URL = URL_ROOT + "resources/service-workers/debug.html";
add_task(async function() { add_task(async function() {
await enableApplicationPanel(); await enableApplicationPanel();
const { panel, tab, target, toolbox } = await openNewTabAndApplicationPanel( const { panel, tab, target } = await openNewTabAndApplicationPanel(TAB_URL);
TAB_URL
);
const doc = panel.panelWin.document; const doc = panel.panelWin.document;
selectPage(panel, "service-workers"); selectPage(panel, "service-workers");
@ -38,28 +35,39 @@ add_task(async function() {
return button && !button.disabled; 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"); const debugButton = container.querySelector(".js-debug-button");
debugButton.click(); debugButton.click();
await waitFor(() => toolbox.getPanel("jsdebugger"));
// add a breakpoint at line 11 const serviceWorkerToolbox = await onToolboxReady;
const debuggerContext = createDebuggerContext(toolbox); 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 waitForLoadedSource(debuggerContext, "debug-sw.js");
await addBreakpoint(debuggerContext, "debug-sw.js", 11);
// force a pause at the breakpoint await addBreakpoint(debuggerContext, "debug-sw.js", 8);
info("Invoke fetch, expect the service worker script to pause on line 11");
await ContentTask.spawn(tab.linkedBrowser, {}, async function() { info(
content.wrappedJSObject.fetchFromWorker(); "Reload the main tab, expect the service worker script to pause on line 8"
}); );
tab.linkedBrowser.reload();
await waitForPaused(debuggerContext); await waitForPaused(debuggerContext);
assertPausedLocation(debuggerContext); assertPausedLocation(debuggerContext);
await resume(debuggerContext); await resume(debuggerContext);
// remove breakpoint
const workerScript = findSource(debuggerContext, "debug-sw.js"); 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); await unregisterAllWorkers(target.client);
}); });

Просмотреть файл

@ -11,19 +11,9 @@ const TAB_URL = URL_ROOT + "resources/service-workers/simple.html";
add_task(async function() { add_task(async function() {
await enableApplicationPanel(); await enableApplicationPanel();
// Setting a low idle_timeout and idle_extended_timeout will allow the service worker // disable sw debugging by increasing the # of processes and thus multi-e10s kicking in
// 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"); info("Disable service worker debugging");
await pushPref( await pushPref("dom.ipc.processCount", 8);
"devtools.debugger.features.windowless-service-workers",
false
);
const { panel, tab, target } = await openNewTabAndApplicationPanel(TAB_URL); const { panel, tab, target } = await openNewTabAndApplicationPanel(TAB_URL);
const doc = panel.panelWin.document; const doc = panel.panelWin.document;

Просмотреть файл

@ -25,9 +25,6 @@ async function enableServiceWorkerDebugging() {
// SW debugging in multi-e10s. // SW debugging in multi-e10s.
await pushPref("dom.ipc.processCount", 1); 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. // Wait for dom.ipc.processCount to be updated before releasing processes.
Services.ppmm.releaseCachedProcesses(); Services.ppmm.releaseCachedProcesses();
} }

Просмотреть файл

@ -3,16 +3,8 @@
"use strict"; "use strict";
self.addEventListener("activate", event => { // Bug 1328293
event.waitUntil(self.clients.claim());
});
self.onfetch = function(event) { self.onfetch = function(event) {
const url = event.request.url; const a = 5;
console.log(a);
const response = url.endsWith("test")
? new Response("lorem ipsum", { statusText: "OK" })
: fetch(event.request);
event.respondWith(response);
}; };

Просмотреть файл

@ -11,15 +11,6 @@
<script type="text/javascript"> <script type="text/javascript">
"use strict"; "use strict";
window.sw = navigator.serviceWorker.register("debug-sw.js"); window.sw = navigator.serviceWorker.register("debug-sw.js");
/* exported fetchFromWorker */
async function fetchFromWorker() {
const response = await fetch("test");
const text = await response.text();
console.log(`Response from worker: ${text}`);
}
</script> </script>
<p>This page has a <code>fetchFromWorker()</code> function.</p>
</body> </body>
</html> </html>

Просмотреть файл

@ -12,7 +12,7 @@ const { setupStore } = require("devtools/client/application/test/node/helpers");
const { const {
ManifestDevToolsError, ManifestDevToolsError,
services, services,
} = require("devtools/client/application/src/modules/application-services"); } = require("devtools/client/application/src/modules/services");
const { const {
FETCH_MANIFEST_FAILURE, FETCH_MANIFEST_FAILURE,

Просмотреть файл

@ -9,12 +9,6 @@ loader.lazyRequireGetter(
"devtools/client/shared/link", "devtools/client/shared/link",
true true
); );
loader.lazyRequireGetter(
this,
"features",
"devtools/client/debugger/src/utils/prefs",
true
);
const DBG_STRINGS_URI = "devtools/client/locales/debugger.properties"; const DBG_STRINGS_URI = "devtools/client/locales/debugger.properties";
const L10N = new LocalizationHelper(DBG_STRINGS_URI); const L10N = new LocalizationHelper(DBG_STRINGS_URI);
@ -177,29 +171,6 @@ DebuggerPanel.prototype = {
return this._actions.selectSourceURL(cx, url, { line, column }); 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) { previewPausedLocation(location) {
return this._actions.previewPausedLocation(location); return this._actions.previewPausedLocation(location);
}, },