From 0d4837b9f29337fece61c229534fb0d58d38482b Mon Sep 17 00:00:00 2001 From: Cosmin Sabou Date: Thu, 27 Feb 2020 00:12:22 +0200 Subject: [PATCH] Backed out changeset 8f9a32288d2c (bug 1605329) for dt failures on browser_toolbox_remoteness_change.js. CLOSED TREE --HG-- extra : rebase_source : 089fcd86febdece7e450d1c03eaeee7dedebf2d8 --- devtools/client/framework/toolbox.js | 15 -------- .../client/webconsole/actions/autocomplete.js | 13 ++++--- devtools/client/webconsole/actions/input.js | 24 +++++++------ devtools/client/webconsole/actions/object.js | 6 ++-- devtools/client/webconsole/commands.js | 35 +++++-------------- devtools/client/webconsole/store.js | 4 +-- .../client/webconsole/test/node/helpers.js | 5 +-- devtools/client/webconsole/webconsole-ui.js | 17 +++------ .../client/webconsole/webconsole-wrapper.js | 2 +- devtools/shared/fronts/thread.js | 4 --- 10 files changed, 39 insertions(+), 86 deletions(-) diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js index af1aa971d901..3420e46a46ea 100644 --- a/devtools/client/framework/toolbox.js +++ b/devtools/client/framework/toolbox.js @@ -134,12 +134,6 @@ loader.lazyRequireGetter( "devtools/client/framework/toolbox-context-menu", true ); -loader.lazyRequireGetter( - this, - "getSelectedThread", - "devtools/client/framework/reducers/threads", - true -); loader.lazyRequireGetter( this, "remoteClientManager", @@ -599,15 +593,6 @@ Toolbox.prototype = { return this.hostType === Toolbox.HostType.BROWSERTOOLBOX; }, - getSelectedThreadFront: function() { - const thread = getSelectedThread(this.store.getState()); - if (!thread) { - return null; - } - - return this.target.client.getFrontByID(thread.actor); - }, - _onPausedState: function(packet, threadFront) { // Suppress interrupted events by default because the thread is // paused/resumed a lot for various actions. diff --git a/devtools/client/webconsole/actions/autocomplete.js b/devtools/client/webconsole/actions/autocomplete.js index c1fac82c081d..456501249f5d 100644 --- a/devtools/client/webconsole/actions/autocomplete.js +++ b/devtools/client/webconsole/actions/autocomplete.js @@ -21,14 +21,14 @@ const { * @param {Array} expressionVars: Array of the variables defined in the expression. */ function autocompleteUpdate(force, getterPath, expressionVars) { - return async ({ dispatch, getState, toolbox, webConsoleUI, hud }) => { + return async ({ dispatch, getState, webConsoleUI, hud }) => { if (hud.inputHasSelection()) { return dispatch(autocompleteClear()); } const inputValue = hud.getInputValue(); const frameActorId = await webConsoleUI.getFrameActor(); - const webconsoleFront = await webConsoleUI.getWebconsoleFront({ + const webConsoleFront = await webConsoleUI.getWebConsoleFront({ frameActorId, }); @@ -81,7 +81,7 @@ function autocompleteUpdate(force, getterPath, expressionVars) { autocompleteDataFetch({ input, frameActorId, - webconsoleFront, + webConsoleFront, authorizedEvaluations, force, expressionVars, @@ -134,16 +134,15 @@ function autocompleteDataFetch({ input, frameActorId, force, - webconsoleFront, + webConsoleFront, authorizedEvaluations, expressionVars, }) { - return async ({ dispatch, webConsoleUI }) => { + return ({ dispatch, webConsoleUI }) => { const selectedNodeActor = webConsoleUI.getSelectedNodeActor(); const id = generateRequestId(); dispatch({ type: AUTOCOMPLETE_PENDING_REQUEST, id }); - - webconsoleFront + webConsoleFront .autocomplete( input, undefined, diff --git a/devtools/client/webconsole/actions/input.js b/devtools/client/webconsole/actions/input.js index 45dbf4d76228..fe1601ad314c 100644 --- a/devtools/client/webconsole/actions/input.js +++ b/devtools/client/webconsole/actions/input.js @@ -57,7 +57,7 @@ async function getMappedExpression(hud, expression) { } function evaluateExpression(expression) { - return async ({ dispatch, toolbox, webConsoleUI, hud, client }) => { + return async ({ dispatch, webConsoleUI, hud, client }) => { if (!expression) { expression = hud.getInputSelection() || hud.getInputValue(); } @@ -84,8 +84,10 @@ function evaluateExpression(expression) { let mapped; ({ expression, mapped } = await getMappedExpression(hud, expression)); - const frameActor = await webConsoleUI.getFrameActor(); - const selectedThreadFront = toolbox && toolbox.getSelectedThreadFront(); + const frameActorId = await webConsoleUI.getFrameActor(); + const webConsoleFront = await webConsoleUI.getWebConsoleFront({ + frameActorId, + }); // Even if the evaluation fails, // we still need to pass the error response to onExpressionEvaluated. @@ -93,9 +95,9 @@ function evaluateExpression(expression) { const response = await client .evaluateJSAsync(expression, { - selectedThreadFront, - frameActor, + frameActor: frameActorId, selectedNodeFront: webConsoleUI.getSelectedNodeFront(), + webConsoleFront, mapped, }) .then(onSettled, onSettled); @@ -209,7 +211,7 @@ function setInputValue(value) { } function terminalInputChanged(expression) { - return async ({ dispatch, webConsoleUI, hud, toolbox, client, getState }) => { + return async ({ dispatch, webConsoleUI, hud, client, getState }) => { const prefs = getAllPrefs(getState()); if (!prefs.eagerEvaluation) { return; @@ -240,13 +242,15 @@ function terminalInputChanged(expression) { let mapped; ({ expression, mapped } = await getMappedExpression(hud, expression)); - const frameActor = await webConsoleUI.getFrameActor(); - const selectedThreadFront = toolbox && toolbox.getSelectedThreadFront(); + const frameActorId = await webConsoleUI.getFrameActor(); + const webConsoleFront = await webConsoleUI.getWebConsoleFront({ + frameActorId, + }); const response = await client.evaluateJSAsync(expression, { - frameActor, - selectedThreadFront, + frameActor: frameActorId, selectedNodeFront: webConsoleUI.getSelectedNodeFront(), + webConsoleFront, mapped, eager: true, }); diff --git a/devtools/client/webconsole/actions/object.js b/devtools/client/webconsole/actions/object.js index eb4a7f8fb768..6a46aa734ea6 100644 --- a/devtools/client/webconsole/actions/object.js +++ b/devtools/client/webconsole/actions/object.js @@ -21,9 +21,11 @@ function storeAsGlobal(actor) { "temp" + i; }`; - const res = await client.evaluateJSAsync(evalString, { + const options = { selectedObjectActor: actor, - }); + }; + + const res = await client.evaluateJSAsync(evalString, options); hud.focusInput(); hud.setInputValue(res.result); }; diff --git a/devtools/client/webconsole/commands.js b/devtools/client/webconsole/commands.js index c3adb76651cf..9034c9ad6b96 100644 --- a/devtools/client/webconsole/commands.js +++ b/devtools/client/webconsole/commands.js @@ -12,39 +12,20 @@ class ConsoleCommands { this.currentTarget = currentTarget; } - getFrontByID(id) { - return this.devToolsClient.getFrontByID(id); - } - async evaluateJSAsync(expression, options = {}) { - const { - selectedNodeFront, - selectedThreadFront, - frameActor, - selectedObjectActor, - } = options; + const { selectedNodeFront, webConsoleFront, selectedObjectActor } = options; let front = this.proxy.webConsoleFront; // Defer to the selected paused thread front - if (frameActor) { - const frameFront = this.getFrontByID(frameActor); - if (frameFront) { - front = await frameFront.targetFront.getFront("console"); - } + if (webConsoleFront) { + front = webConsoleFront; } - // NOTE: once we handle the other tasks in console evaluation, - // all of the implicit actions like pausing, selecting a frame in the inspector, - // etc will update the selected thread and we will no longer need to support these other - // cases. - if (selectedThreadFront) { - front = await selectedThreadFront.targetFront.getFront("console"); - - // If there's a selectedObjectActor option, this means the user intend to do a - // given action on a specific object, so it should take precedence over selected - // node front. - } else if (selectedObjectActor) { - const objectFront = this.getFrontByID(selectedObjectActor); + // If there's a selectedObjectActor option, this means the user intend to do a + // given action on a specific object, so it should take precedence over selected + // node front. + if (selectedObjectActor) { + const objectFront = this.devToolsClient.getFrontByID(selectedObjectActor); if (objectFront) { front = await objectFront.targetFront.getFront("console"); } diff --git a/devtools/client/webconsole/store.js b/devtools/client/webconsole/store.js index d88c98df4711..394167bed4fc 100644 --- a/devtools/client/webconsole/store.js +++ b/devtools/client/webconsole/store.js @@ -87,8 +87,6 @@ function configureStore(webConsoleUI, options = {}) { }), }; - const toolbox = options.thunkArgs.toolbox; - const sessionId = (toolbox && toolbox.sessionId) || -1; const middleware = applyMiddleware( ignore, thunkWithOptions.bind(null, { @@ -96,7 +94,7 @@ function configureStore(webConsoleUI, options = {}) { ...options.thunkArgs, }), historyPersistence, - eventTelemetry.bind(null, options.telemetry, sessionId) + eventTelemetry.bind(null, options.telemetry, options.sessionId) ); return createStore( diff --git a/devtools/client/webconsole/test/node/helpers.js b/devtools/client/webconsole/test/node/helpers.js index cc3929bda093..bfda1d698416 100644 --- a/devtools/client/webconsole/test/node/helpers.js +++ b/devtools/client/webconsole/test/node/helpers.js @@ -50,7 +50,7 @@ function setupStore( } const store = configureStore(webConsoleUI, { ...storeOptions, - thunkArgs: { toolbox: { sessionId: -1 } }, + sessionId: -1, telemetry: new Telemetry(), }); @@ -140,9 +140,6 @@ function getWebConsoleUiMock(hud, proxyOverrides) { releaseActor: proxy.releaseActor, getProxy: () => proxy, inspectObjectActor: () => {}, - toolbox: { - sessionId: 1, - }, }; } diff --git a/devtools/client/webconsole/webconsole-ui.js b/devtools/client/webconsole/webconsole-ui.js index 04a8591b98b9..d4d9e3e85eec 100644 --- a/devtools/client/webconsole/webconsole-ui.js +++ b/devtools/client/webconsole/webconsole-ui.js @@ -584,22 +584,13 @@ class WebConsoleUI { return frame.actor; } - getWebconsoleFront({ frameActorId } = {}) { - if (frameActorId) { - const frameFront = this.hud.getFrontByID(frameActorId); - return frameFront.getWebConsoleFront(); - } - - if (!this.hud.toolbox) { + getWebConsoleFront({ frameActorId } = {}) { + if (!frameActorId) { return this.webConsoleFront; } - const threadFront = this.hud.toolbox.getSelectedThreadFront(); - if (!threadFront) { - return this.webConsoleFront; - } - - return threadFront.getWebconsoleFront(); + const frameFront = this.hud.getFrontByID(frameActorId); + return frameFront.getWebConsoleFront(); } getSelectedNodeActor() { diff --git a/devtools/client/webconsole/webconsole-wrapper.js b/devtools/client/webconsole/webconsole-wrapper.js index c725edbce2e8..aaf13a72a7db 100644 --- a/devtools/client/webconsole/webconsole-wrapper.js +++ b/devtools/client/webconsole/webconsole-wrapper.js @@ -95,11 +95,11 @@ class WebConsoleWrapper { return new Promise(resolve => { store = configureStore(this.webConsoleUI, { // We may not have access to the toolbox (e.g. in the browser console). + sessionId: (this.toolbox && this.toolbox.sessionId) || -1, telemetry: this.telemetry, thunkArgs: { webConsoleUI, hud: this.hud, - toolbox: this.toolbox, client: this.webConsoleUI._commands, }, }); diff --git a/devtools/shared/fronts/thread.js b/devtools/shared/fronts/thread.js index 09939eb8fb67..e74c67567366 100644 --- a/devtools/shared/fronts/thread.js +++ b/devtools/shared/fronts/thread.js @@ -64,10 +64,6 @@ class ThreadFront extends FrontClassWithSpec(threadSpec) { return this.actorID; } - getWebconsoleFront() { - return this.targetFront.getFront("console"); - } - _assertPaused(command) { if (!this.paused) { throw Error(