Backed out changeset 185a33dcfa94 (bug 1605331) for devtools failures at browser_dbg-windowless-workers.js. CLOSED TREE

This commit is contained in:
Brindusan Cristian 2020-04-04 04:03:41 +03:00
parent af96555478
commit ed2dea237d
4 changed files with 16 additions and 54 deletions

View File

@ -3,7 +3,6 @@
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
const { LocalizationHelper } = require("devtools/shared/l10n");
loader.lazyRequireGetter(
this,
"openContentLink",
@ -16,16 +15,19 @@ loader.lazyRequireGetter(
"devtools/client/debugger/src/utils/prefs",
true
);
loader.lazyRequireGetter(
this,
"registerStoreObserver",
"devtools/client/shared/redux/subscriber",
true
);
const DBG_STRINGS_URI = "devtools/client/locales/debugger.properties";
const L10N = new LocalizationHelper(DBG_STRINGS_URI);
function registerStoreObserver(store, subscriber) {
let oldState = store.getState();
store.subscribe(() => {
const state = store.getState();
subscriber(state, oldState);
oldState = state;
});
}
async function getNodeFront(gripOrFront, toolbox) {
// Given a NodeFront
if ("actorID" in gripOrFront) {
@ -90,7 +92,7 @@ class DebuggerPanel {
const threadFront = this.toolbox.target.client.getFrontByID(
currentThreadActorID
);
this.toolbox.selectTarget(threadFront?.targetFront.actorID);
this.toolbox.selectTarget(threadFront?.targetFront?.actorID);
}
}
@ -201,10 +203,10 @@ class DebuggerPanel {
}
async selectWorker(workerTargetFront) {
const threadActorID = workerTargetFront.threadFront.actorID;
const threadId = workerTargetFront.threadFront.actorID;
const isThreadAvailable = this._selectors
.getThreads(this._getState())
.find(x => x.actor === threadActorID);
.find(x => x.actor === threadId);
if (!features.windowlessServiceWorkers) {
console.error(
@ -214,23 +216,19 @@ class DebuggerPanel {
}
if (!isThreadAvailable) {
console.error(`Worker ${threadActorID} is not available for debugging`);
console.error(`Worker ${threadId} is not available for debugging`);
return;
}
// select worker's thread
this.selectThread(threadActorID);
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);
}
selectThread(actorID) {
const cx = this._selectors.getContext(this._getState());
this._actions.selectThread(cx, actorID);
}
previewPausedLocation(location) {
return this._actions.previewPausedLocation(location);
}

View File

@ -47,12 +47,6 @@ const L10N = new LocalizationHelper(
"devtools/client/locales/toolbox.properties"
);
loader.lazyRequireGetter(
this,
"registerStoreObserver",
"devtools/client/shared/redux/subscriber",
true
);
loader.lazyRequireGetter(
this,
"createToolboxStore",
@ -408,7 +402,6 @@ Toolbox.prototype = {
get store() {
if (!this._store) {
this._store = createToolboxStore();
registerStoreObserver(this._store, this._onToolboxStateChange.bind(this));
}
return this._store;
},
@ -624,9 +617,7 @@ Toolbox.prototype = {
* @param {String} targetActorID: The actorID of the target we want to select.
*/
selectTarget(targetActorID) {
if (this.getSelectedTargetFront()?.actorID !== targetActorID) {
this.store.dispatch(selectTarget(targetActorID));
}
this.store.dispatch(selectTarget(targetActorID));
},
/**
@ -637,19 +628,9 @@ Toolbox.prototype = {
if (!selectedTarget) {
return null;
}
return this.target.client.getFrontByID(selectedTarget.actorID);
},
_onToolboxStateChange(state, oldState) {
if (getSelectedTarget(state) !== getSelectedTarget(oldState)) {
const dbg = this.getPanel("jsdebugger");
dbg?.selectThread(
getSelectedTarget(state)?._targetFront.threadFront.actorID
);
}
},
_onPausedState: function(packet, threadFront) {
// Suppress interrupted events by default because the thread is
// paused/resumed a lot for various actions.

View File

@ -11,6 +11,5 @@ DIRS += [
DevToolsModules(
'create-store.js',
'non-react-subscriber.js',
'subscriber.js',
'visibility-handler-connect.js',
)

View File

@ -1,16 +0,0 @@
/* 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";
function registerStoreObserver(store, subscriber) {
let oldState = store.getState();
store.subscribe(() => {
const state = store.getState();
subscriber(state, oldState);
oldState = state;
});
}
exports.registerStoreObserver = registerStoreObserver;