зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1657389 - Rename target actor mock 'window' property to 'workerGlobal'. r=ochameau.
Not having the window property anymore, we have to change the `window` getter in WebConsoleActor to retrieve `workerGlobal`. And since the getter name wasn't reflecting what it was holding (it can be a window, a worker global or a sandbox), we rename it to `global` (and `evalWindow` to `evalGlobal`). We remove the `globalDebugObject` getter on the thread actor that wasn't used anywhere in the code. Differential Revision: https://phabricator.services.mozilla.com/D86035
This commit is contained in:
Родитель
5b26ec0846
Коммит
7ee8cd576d
|
@ -75,8 +75,6 @@ const proto = {
|
||||||
* Increment the actor's grip depth
|
* Increment the actor's grip depth
|
||||||
* - decrementGripDepth
|
* - decrementGripDepth
|
||||||
* Decrement the actor's grip depth
|
* Decrement the actor's grip depth
|
||||||
* - globalDebugObject
|
|
||||||
* The Debuggee Global Object as given by the ThreadActor
|
|
||||||
*/
|
*/
|
||||||
initialize(
|
initialize(
|
||||||
obj,
|
obj,
|
||||||
|
|
|
@ -64,11 +64,10 @@ class ConsoleMessageWatcher {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
listener.init();
|
listener.init();
|
||||||
|
|
||||||
// See `window` definition. It isn't always a DOM Window.
|
// It can happen that the targetActor does not have a window reference (e.g. in worker
|
||||||
|
// thread, targetActor exposes a workerGlobal property)
|
||||||
const winStartTime =
|
const winStartTime =
|
||||||
targetActor.window && targetActor.window.performance
|
targetActor.window?.performance?.timing?.navigationStart || 0;
|
||||||
? targetActor.window.performance.timing.navigationStart
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
const cachedMessages = listener.getCachedMessages(!targetActor.isRootActor);
|
const cachedMessages = listener.getCachedMessages(!targetActor.isRootActor);
|
||||||
const messages = [];
|
const messages = [];
|
||||||
|
|
|
@ -244,13 +244,6 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
|
||||||
return this._dbg;
|
return this._dbg;
|
||||||
},
|
},
|
||||||
|
|
||||||
get globalDebugObject() {
|
|
||||||
if (!this._parent.window) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return this.dbg.makeGlobalObjectReference(this._parent.window);
|
|
||||||
},
|
|
||||||
|
|
||||||
get state() {
|
get state() {
|
||||||
return this._state;
|
return this._state;
|
||||||
},
|
},
|
||||||
|
@ -506,13 +499,18 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
|
||||||
return highlighter;
|
return highlighter;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_canShowOverlay() {
|
||||||
|
// Accept only browsing context target, which expose a `window` attribute,
|
||||||
|
// but ignore privileged document (top level window, special about:* pages, …)
|
||||||
|
return this._parent.window && !this._parent.window.isChromeWindow;
|
||||||
|
},
|
||||||
|
|
||||||
async showOverlay() {
|
async showOverlay() {
|
||||||
if (
|
if (
|
||||||
this._options.shouldShowOverlay &&
|
this._options.shouldShowOverlay &&
|
||||||
this.isPaused() &&
|
this.isPaused() &&
|
||||||
|
this._canShowOverlay() &&
|
||||||
this._parent.on &&
|
this._parent.on &&
|
||||||
this._parent.window.document &&
|
|
||||||
!this._parent.window.isChromeWindow &&
|
|
||||||
this.pauseOverlay
|
this.pauseOverlay
|
||||||
) {
|
) {
|
||||||
const reason = this._priorPause.why.type;
|
const reason = this._priorPause.why.type;
|
||||||
|
@ -521,13 +519,8 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hideOverlay(msg) {
|
hideOverlay() {
|
||||||
if (
|
if (this._canShowOverlay() && this._pauseOverlay) {
|
||||||
this._parent.window.document &&
|
|
||||||
this._parent.on &&
|
|
||||||
!this._parent.window.isChromeWindow &&
|
|
||||||
this._pauseOverlay
|
|
||||||
) {
|
|
||||||
this.pauseOverlay.hide();
|
this.pauseOverlay.hide();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/* global XPCNativeWrapper evalWithDebugger */
|
/* global XPCNativeWrapper */
|
||||||
const { ActorClassWithSpec, Actor } = require("devtools/shared/protocol");
|
const { ActorClassWithSpec, Actor } = require("devtools/shared/protocol");
|
||||||
const { webconsoleSpec } = require("devtools/shared/specs/webconsole");
|
const { webconsoleSpec } = require("devtools/shared/specs/webconsole");
|
||||||
|
|
||||||
|
@ -244,18 +244,16 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
traits: null,
|
traits: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The window or sandbox we work with.
|
* The global we work with (this can be a Window, a Worker global or even a Sandbox
|
||||||
* Note that even if it is named `window` it refers to the current
|
* for processes and addons).
|
||||||
* global we are debugging, which can be a Sandbox for addons
|
|
||||||
* or browser content toolbox.
|
|
||||||
*
|
*
|
||||||
* @type nsIDOMWindow or Sandbox
|
* @type nsIDOMWindow, WorkerGlobalScope or Sandbox
|
||||||
*/
|
*/
|
||||||
get window() {
|
get global() {
|
||||||
if (this.parentActor.isRootActor) {
|
if (this.parentActor.isRootActor) {
|
||||||
return this._getWindowForBrowserConsole();
|
return this._getWindowForBrowserConsole();
|
||||||
}
|
}
|
||||||
return this.parentActor.window;
|
return this.parentActor.window || this.parentActor.workerGlobal;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -325,14 +323,14 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
*/
|
*/
|
||||||
_lastChromeWindow: null,
|
_lastChromeWindow: null,
|
||||||
|
|
||||||
// The evalWindow is used at the scope for JS evaluation.
|
// The evalGlobal is used at the scope for JS evaluation.
|
||||||
_evalWindow: null,
|
_evalGlobal: null,
|
||||||
get evalWindow() {
|
get evalGlobal() {
|
||||||
return this._evalWindow || this.window;
|
return this._evalGlobal || this.global;
|
||||||
},
|
},
|
||||||
|
|
||||||
set evalWindow(window) {
|
set evalGlobal(global) {
|
||||||
this._evalWindow = window;
|
this._evalGlobal = global;
|
||||||
|
|
||||||
if (!this._progressListenerActive) {
|
if (!this._progressListenerActive) {
|
||||||
EventEmitter.on(this.parentActor, "will-navigate", this._onWillNavigate);
|
EventEmitter.on(this.parentActor, "will-navigate", this._onWillNavigate);
|
||||||
|
@ -343,7 +341,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
/**
|
/**
|
||||||
* Flag used to track if we are listening for events from the progress
|
* Flag used to track if we are listening for events from the progress
|
||||||
* listener of the target actor. We use the progress listener to clear
|
* listener of the target actor. We use the progress listener to clear
|
||||||
* this.evalWindow on page navigation.
|
* this.evalGlobal on page navigation.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @type boolean
|
* @type boolean
|
||||||
|
@ -431,7 +429,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
|
|
||||||
this._webConsoleCommandsCache = null;
|
this._webConsoleCommandsCache = null;
|
||||||
this._lastConsoleInputEvaluation = null;
|
this._lastConsoleInputEvaluation = null;
|
||||||
this._evalWindow = null;
|
this._evalGlobal = null;
|
||||||
this.dbg = null;
|
this.dbg = null;
|
||||||
this.conn = null;
|
this.conn = null;
|
||||||
},
|
},
|
||||||
|
@ -480,7 +478,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
* The value you want to get a debuggee value for.
|
* The value you want to get a debuggee value for.
|
||||||
* @param boolean useObjectGlobal
|
* @param boolean useObjectGlobal
|
||||||
* If |true| the object global is determined and added as a debuggee,
|
* If |true| the object global is determined and added as a debuggee,
|
||||||
* otherwise |this.window| is used when makeDebuggeeValue() is invoked.
|
* otherwise |this.global| is used when makeDebuggeeValue() is invoked.
|
||||||
* @return object
|
* @return object
|
||||||
* Debuggee value for |value|.
|
* Debuggee value for |value|.
|
||||||
*/
|
*/
|
||||||
|
@ -495,7 +493,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
// or 'Object in compartment marked as invisible to Debugger'
|
// or 'Object in compartment marked as invisible to Debugger'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const dbgGlobal = this.dbg.makeGlobalObjectReference(this.window);
|
const dbgGlobal = this.dbg.makeGlobalObjectReference(this.global);
|
||||||
return dbgGlobal.makeDebuggeeValue(value);
|
return dbgGlobal.makeDebuggeeValue(value);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -621,7 +619,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
// eslint-disable-next-line complexity
|
// eslint-disable-next-line complexity
|
||||||
startListeners: async function(listeners) {
|
startListeners: async function(listeners) {
|
||||||
const startedListeners = [];
|
const startedListeners = [];
|
||||||
const window = !this.parentActor.isRootActor ? this.window : null;
|
const global = !this.parentActor.isRootActor ? this.global : null;
|
||||||
|
|
||||||
for (const event of listeners) {
|
for (const event of listeners) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
@ -632,7 +630,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
}
|
}
|
||||||
if (!this.consoleServiceListener) {
|
if (!this.consoleServiceListener) {
|
||||||
this.consoleServiceListener = new ConsoleServiceListener(
|
this.consoleServiceListener = new ConsoleServiceListener(
|
||||||
window,
|
global,
|
||||||
this.onConsoleServiceMessage
|
this.onConsoleServiceMessage
|
||||||
);
|
);
|
||||||
this.consoleServiceListener.init();
|
this.consoleServiceListener.init();
|
||||||
|
@ -644,7 +642,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
// Create the consoleAPIListener
|
// Create the consoleAPIListener
|
||||||
// (and apply the filtering options defined in the parent actor).
|
// (and apply the filtering options defined in the parent actor).
|
||||||
this.consoleAPIListener = new ConsoleAPIListener(
|
this.consoleAPIListener = new ConsoleAPIListener(
|
||||||
window,
|
global,
|
||||||
this.onConsoleAPICall,
|
this.onConsoleAPICall,
|
||||||
this.parentActor.consoleAPIListenerOptions
|
this.parentActor.consoleAPIListenerOptions
|
||||||
);
|
);
|
||||||
|
@ -703,7 +701,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
// service workers requests)
|
// service workers requests)
|
||||||
new NetworkMonitorActor(
|
new NetworkMonitorActor(
|
||||||
this.conn,
|
this.conn,
|
||||||
{ window },
|
{ window: global },
|
||||||
this.actorID,
|
this.actorID,
|
||||||
mmMockParent
|
mmMockParent
|
||||||
);
|
);
|
||||||
|
@ -718,7 +716,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
// requests, as well with the NetworkMonitorActor running in the parent
|
// requests, as well with the NetworkMonitorActor running in the parent
|
||||||
// process. It will communicate via message manager for this one.
|
// process. It will communicate via message manager for this one.
|
||||||
this.stackTraceCollector = new StackTraceCollector(
|
this.stackTraceCollector = new StackTraceCollector(
|
||||||
{ window },
|
{ window: global },
|
||||||
this.netmonitors
|
this.netmonitors
|
||||||
);
|
);
|
||||||
this.stackTraceCollector.init();
|
this.stackTraceCollector.init();
|
||||||
|
@ -730,10 +728,10 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
if (isWorker) {
|
if (isWorker) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.window instanceof Ci.nsIDOMWindow) {
|
if (this.global instanceof Ci.nsIDOMWindow) {
|
||||||
if (!this.consoleFileActivityListener) {
|
if (!this.consoleFileActivityListener) {
|
||||||
this.consoleFileActivityListener = new ConsoleFileActivityListener(
|
this.consoleFileActivityListener = new ConsoleFileActivityListener(
|
||||||
this.window,
|
this.global,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -748,7 +746,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
}
|
}
|
||||||
if (!this.consoleReflowListener) {
|
if (!this.consoleReflowListener) {
|
||||||
this.consoleReflowListener = new ConsoleReflowListener(
|
this.consoleReflowListener = new ConsoleReflowListener(
|
||||||
this.window,
|
this.global,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -788,7 +786,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
startedListeners: startedListeners,
|
startedListeners: startedListeners,
|
||||||
nativeConsoleAPI: this.hasNativeConsoleAPI(this.window),
|
nativeConsoleAPI: this.hasNativeConsoleAPI(this.global),
|
||||||
traits: this.traits,
|
traits: this.traits,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -919,11 +917,10 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// See `window` definition. It isn't always a DOM Window.
|
// this.global might not be a window (can be a worker global or a Sandbox),
|
||||||
const winStartTime =
|
// and in such case performance isn't defined
|
||||||
this.window && this.window.performance
|
const winStartTime = this.global?.performance?.timing
|
||||||
? this.window.performance.timing.navigationStart
|
?.navigationStart;
|
||||||
: 0;
|
|
||||||
|
|
||||||
const cache = this.consoleAPIListener.getCachedMessages(
|
const cache = this.consoleAPIListener.getCachedMessages(
|
||||||
!this.parentActor.isRootActor
|
!this.parentActor.isRootActor
|
||||||
|
@ -1031,7 +1028,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const message = `Encountered error while waiting for Helper Result: ${e}`;
|
const message = `Encountered error while waiting for Helper Result: ${e}\n${e.stack}`;
|
||||||
DevToolsUtils.reportException("evaluateJSAsync", Error(message));
|
DevToolsUtils.reportException("evaluateJSAsync", Error(message));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1355,7 +1352,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dbgObject = this.dbg.addDebuggee(this.evalWindow);
|
dbgObject = this.dbg.addDebuggee(this.evalGlobal);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = JSPropertyProvider({
|
const result = JSPropertyProvider({
|
||||||
|
@ -1444,7 +1441,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
*/
|
*/
|
||||||
clearMessagesCache: function() {
|
clearMessagesCache: function() {
|
||||||
const windowId = !this.parentActor.isRootActor
|
const windowId = !this.parentActor.isRootActor
|
||||||
? WebConsoleUtils.getInnerWindowId(this.window)
|
? WebConsoleUtils.getInnerWindowId(this.global)
|
||||||
: null;
|
: null;
|
||||||
const ConsoleAPIStorage = Cc[
|
const ConsoleAPIStorage = Cc[
|
||||||
"@mozilla.org/consoleAPI-storage;1"
|
"@mozilla.org/consoleAPI-storage;1"
|
||||||
|
@ -1531,8 +1528,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
*/
|
*/
|
||||||
_getWebConsoleCommands: function(debuggerGlobal) {
|
_getWebConsoleCommands: function(debuggerGlobal) {
|
||||||
const helpers = {
|
const helpers = {
|
||||||
window: this.evalWindow,
|
window: this.evalGlobal,
|
||||||
chromeWindow: this.chromeWindow.bind(this),
|
|
||||||
makeDebuggeeValue: debuggerGlobal.makeDebuggeeValue.bind(debuggerGlobal),
|
makeDebuggeeValue: debuggerGlobal.makeDebuggeeValue.bind(debuggerGlobal),
|
||||||
createValueGrip: this.createValueGrip.bind(this),
|
createValueGrip: this.createValueGrip.bind(this),
|
||||||
preprocessDebuggerObject: this.preprocessDebuggerObject.bind(this),
|
preprocessDebuggerObject: this.preprocessDebuggerObject.bind(this),
|
||||||
|
@ -1542,7 +1538,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
};
|
};
|
||||||
addWebConsoleCommands(helpers);
|
addWebConsoleCommands(helpers);
|
||||||
|
|
||||||
const evalWindow = this.evalWindow;
|
const evalGlobal = this.evalGlobal;
|
||||||
function maybeExport(obj, name) {
|
function maybeExport(obj, name) {
|
||||||
if (typeof obj[name] != "function") {
|
if (typeof obj[name] != "function") {
|
||||||
return;
|
return;
|
||||||
|
@ -1554,7 +1550,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
// helpers like cd(), where we users sometimes want to pass a cross-origin
|
// helpers like cd(), where we users sometimes want to pass a cross-origin
|
||||||
// window. To circumvent this restriction, we use exportFunction along
|
// window. To circumvent this restriction, we use exportFunction along
|
||||||
// with a special option designed for this purpose. See bug 1051224.
|
// with a special option designed for this purpose. See bug 1051224.
|
||||||
obj[name] = Cu.exportFunction(obj[name], evalWindow, {
|
obj[name] = Cu.exportFunction(obj[name], evalGlobal, {
|
||||||
allowCrossOriginArguments: true,
|
allowCrossOriginArguments: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1780,7 +1776,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
const { url, method, headers, body, cause } = request;
|
const { url, method, headers, body, cause } = request;
|
||||||
// Set the loadingNode and loadGroup to the target document - otherwise the
|
// Set the loadingNode and loadGroup to the target document - otherwise the
|
||||||
// request won't show up in the opened netmonitor.
|
// request won't show up in the opened netmonitor.
|
||||||
const doc = this.window.document;
|
const doc = this.global.document;
|
||||||
|
|
||||||
const channel = NetUtil.newChannel({
|
const channel = NetUtil.newChannel({
|
||||||
uri: NetUtil.newURI(url),
|
uri: NetUtil.newURI(url),
|
||||||
|
@ -1988,7 +1984,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
* The original message received from console-api-log-event.
|
* The original message received from console-api-log-event.
|
||||||
* @param boolean aUseObjectGlobal
|
* @param boolean aUseObjectGlobal
|
||||||
* If |true| the object global is determined and added as a debuggee,
|
* If |true| the object global is determined and added as a debuggee,
|
||||||
* otherwise |this.window| is used when makeDebuggeeValue() is invoked.
|
* otherwise |this.global| is used when makeDebuggeeValue() is invoked.
|
||||||
* @return object
|
* @return object
|
||||||
* The object that can be sent to the remote client.
|
* The object that can be sent to the remote client.
|
||||||
*/
|
*/
|
||||||
|
@ -2109,24 +2105,6 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
return ownProperties;
|
return ownProperties;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Find the XUL window that owns the content window.
|
|
||||||
*
|
|
||||||
* @return Window
|
|
||||||
* The XUL window that owns the content window.
|
|
||||||
*/
|
|
||||||
chromeWindow: function() {
|
|
||||||
let window = null;
|
|
||||||
try {
|
|
||||||
window = this.window.docShell.chromeEventHandler.ownerGlobal;
|
|
||||||
} catch (ex) {
|
|
||||||
// The above can fail because chromeEventHandler is not available for all
|
|
||||||
// kinds of |this.window|.
|
|
||||||
}
|
|
||||||
|
|
||||||
return window;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notification observer for the "last-pb-context-exited" topic.
|
* Notification observer for the "last-pb-context-exited" topic.
|
||||||
*
|
*
|
||||||
|
@ -2149,7 +2127,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
*/
|
*/
|
||||||
_onWillNavigate: function({ window, isTopLevel }) {
|
_onWillNavigate: function({ window, isTopLevel }) {
|
||||||
if (isTopLevel) {
|
if (isTopLevel) {
|
||||||
this._evalWindow = null;
|
this._evalGlobal = null;
|
||||||
EventEmitter.off(this.parentActor, "will-navigate", this._onWillNavigate);
|
EventEmitter.off(this.parentActor, "will-navigate", this._onWillNavigate);
|
||||||
this._progressListenerActive = false;
|
this._progressListenerActive = false;
|
||||||
}
|
}
|
||||||
|
@ -2167,8 +2145,8 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
// (pass a copy of the array as it will shift from it)
|
// (pass a copy of the array as it will shift from it)
|
||||||
this.stopListeners(listeners.slice());
|
this.stopListeners(listeners.slice());
|
||||||
|
|
||||||
// This method is called after this.window is changed,
|
// This method is called after this.global is changed,
|
||||||
// so we register new listener on this new window
|
// so we register new listener on this new global
|
||||||
this.startListeners(listeners);
|
this.startListeners(listeners);
|
||||||
|
|
||||||
// Also reset the cached top level chrome window being targeted
|
// Also reset the cached top level chrome window being targeted
|
||||||
|
|
|
@ -112,8 +112,7 @@ function isObject(value) {
|
||||||
* An object that holds the following properties:
|
* An object that holds the following properties:
|
||||||
* - dbg: the debugger where the string was evaluated.
|
* - dbg: the debugger where the string was evaluated.
|
||||||
* - frame: (optional) the frame where the string was evaluated.
|
* - frame: (optional) the frame where the string was evaluated.
|
||||||
* - window: the Debugger.Object for the global where the string was
|
* - global: the Debugger.Object for the global where the string was evaluated in.
|
||||||
* evaluated.
|
|
||||||
* - result: the result of the evaluation.
|
* - result: the result of the evaluation.
|
||||||
* - helperResult: any result coming from a Web Console commands
|
* - helperResult: any result coming from a Web Console commands
|
||||||
* function.
|
* function.
|
||||||
|
@ -128,11 +127,11 @@ exports.evalWithDebugger = function(string, options = {}, webConsole) {
|
||||||
const evalString = getEvalInput(string);
|
const evalString = getEvalInput(string);
|
||||||
const { frame, dbg } = getFrameDbg(options, webConsole);
|
const { frame, dbg } = getFrameDbg(options, webConsole);
|
||||||
|
|
||||||
const { dbgWindow, bindSelf } = getDbgWindow(options, dbg, webConsole);
|
const { dbgGlobal, bindSelf } = getDbgGlobal(options, dbg, webConsole);
|
||||||
const helpers = getHelpers(dbgWindow, options, webConsole);
|
const helpers = getHelpers(dbgGlobal, options, webConsole);
|
||||||
let { bindings, helperCache } = bindCommands(
|
let { bindings, helperCache } = bindCommands(
|
||||||
isCommand(string),
|
isCommand(string),
|
||||||
dbgWindow,
|
dbgGlobal,
|
||||||
bindSelf,
|
bindSelf,
|
||||||
frame,
|
frame,
|
||||||
helpers
|
helpers
|
||||||
|
@ -156,7 +155,7 @@ exports.evalWithDebugger = function(string, options = {}, webConsole) {
|
||||||
evalOptions.lineNumber = options.lineNumber;
|
evalOptions.lineNumber = options.lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateConsoleInputEvaluation(dbg, dbgWindow, webConsole);
|
updateConsoleInputEvaluation(dbg, webConsole);
|
||||||
|
|
||||||
let noSideEffectDebugger = null;
|
let noSideEffectDebugger = null;
|
||||||
if (options.eager) {
|
if (options.eager) {
|
||||||
|
@ -171,7 +170,7 @@ exports.evalWithDebugger = function(string, options = {}, webConsole) {
|
||||||
evalOptions,
|
evalOptions,
|
||||||
bindings,
|
bindings,
|
||||||
frame,
|
frame,
|
||||||
dbgWindow,
|
dbgGlobal,
|
||||||
noSideEffectDebugger
|
noSideEffectDebugger
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -187,7 +186,7 @@ exports.evalWithDebugger = function(string, options = {}, webConsole) {
|
||||||
// since they may now be stuck in an "initializing" state due to the
|
// since they may now be stuck in an "initializing" state due to the
|
||||||
// error. Already-initialized bindings will be ignored.
|
// error. Already-initialized bindings will be ignored.
|
||||||
if (!frame && result && "throw" in result) {
|
if (!frame && result && "throw" in result) {
|
||||||
parseErrorOutput(dbgWindow, string);
|
parseErrorOutput(dbgGlobal, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { helperResult } = helpers;
|
const { helperResult } = helpers;
|
||||||
|
@ -203,7 +202,7 @@ exports.evalWithDebugger = function(string, options = {}, webConsole) {
|
||||||
helperResult,
|
helperResult,
|
||||||
dbg,
|
dbg,
|
||||||
frame,
|
frame,
|
||||||
window: dbgWindow,
|
dbgGlobal,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -213,14 +212,14 @@ function getEvalResult(
|
||||||
evalOptions,
|
evalOptions,
|
||||||
bindings,
|
bindings,
|
||||||
frame,
|
frame,
|
||||||
dbgWindow,
|
dbgGlobal,
|
||||||
noSideEffectDebugger
|
noSideEffectDebugger
|
||||||
) {
|
) {
|
||||||
if (noSideEffectDebugger) {
|
if (noSideEffectDebugger) {
|
||||||
// Bug 1637883 demonstrated an issue where dbgWindow was somehow in the
|
// Bug 1637883 demonstrated an issue where dbgGlobal was somehow in the
|
||||||
// same compartment as the Debugger, meaning it could not be debugged
|
// same compartment as the Debugger, meaning it could not be debugged
|
||||||
// and thus cannot handle eager evaluation. In that case we skip execution.
|
// and thus cannot handle eager evaluation. In that case we skip execution.
|
||||||
if (!noSideEffectDebugger.hasDebuggee(dbgWindow.unsafeDereference())) {
|
if (!noSideEffectDebugger.hasDebuggee(dbgGlobal.unsafeDereference())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +227,7 @@ function getEvalResult(
|
||||||
// in the context of that debugger in order for the side-effect tracking
|
// in the context of that debugger in order for the side-effect tracking
|
||||||
// to apply.
|
// to apply.
|
||||||
frame = frame ? noSideEffectDebugger.adoptFrame(frame) : null;
|
frame = frame ? noSideEffectDebugger.adoptFrame(frame) : null;
|
||||||
dbgWindow = noSideEffectDebugger.adoptDebuggeeValue(dbgWindow);
|
dbgGlobal = noSideEffectDebugger.adoptDebuggeeValue(dbgGlobal);
|
||||||
if (bindings) {
|
if (bindings) {
|
||||||
bindings = Object.keys(bindings).reduce((acc, key) => {
|
bindings = Object.keys(bindings).reduce((acc, key) => {
|
||||||
acc[key] = noSideEffectDebugger.adoptDebuggeeValue(bindings[key]);
|
acc[key] = noSideEffectDebugger.adoptDebuggeeValue(bindings[key]);
|
||||||
|
@ -241,7 +240,7 @@ function getEvalResult(
|
||||||
if (frame) {
|
if (frame) {
|
||||||
result = frame.evalWithBindings(string, bindings, evalOptions);
|
result = frame.evalWithBindings(string, bindings, evalOptions);
|
||||||
} else {
|
} else {
|
||||||
result = dbgWindow.executeInGlobalWithBindings(
|
result = dbgGlobal.executeInGlobalWithBindings(
|
||||||
string,
|
string,
|
||||||
bindings,
|
bindings,
|
||||||
evalOptions
|
evalOptions
|
||||||
|
@ -258,7 +257,7 @@ function getEvalResult(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseErrorOutput(dbgWindow, string) {
|
function parseErrorOutput(dbgGlobal, string) {
|
||||||
// Reflect is not usable in workers, so return early to avoid logging an error
|
// Reflect is not usable in workers, so return early to avoid logging an error
|
||||||
// to the console when loading it.
|
// to the console when loading it.
|
||||||
if (isWorker) {
|
if (isWorker) {
|
||||||
|
@ -320,7 +319,7 @@ function parseErrorOutput(dbgWindow, string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const name of identifiers) {
|
for (const name of identifiers) {
|
||||||
dbgWindow.forceLexicalInitializationByName(name);
|
dbgGlobal.forceLexicalInitializationByName(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -454,7 +453,7 @@ function nativeHasNoSideEffects(fn) {
|
||||||
return natives && natives.some(n => fn.isSameNative(n));
|
return natives && natives.some(n => fn.isSameNative(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateConsoleInputEvaluation(dbg, dbgWindow, webConsole) {
|
function updateConsoleInputEvaluation(dbg, webConsole) {
|
||||||
// Adopt webConsole._lastConsoleInputEvaluation value in the new debugger,
|
// Adopt webConsole._lastConsoleInputEvaluation value in the new debugger,
|
||||||
// to prevent "Debugger.Object belongs to a different Debugger" exceptions
|
// to prevent "Debugger.Object belongs to a different Debugger" exceptions
|
||||||
// related to the $_ bindings if the debugger object is changed from the
|
// related to the $_ bindings if the debugger object is changed from the
|
||||||
|
@ -513,8 +512,8 @@ function getFrameDbg(options, webConsole) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDbgWindow(options, dbg, webConsole) {
|
function getDbgGlobal(options, dbg, webConsole) {
|
||||||
let evalWindow = webConsole.evalWindow;
|
let evalGlobal = webConsole.evalGlobal;
|
||||||
|
|
||||||
if (options.innerWindowID) {
|
if (options.innerWindowID) {
|
||||||
const window = Services.wm.getCurrentInnerWindowWithId(
|
const window = Services.wm.getCurrentInnerWindowWithId(
|
||||||
|
@ -522,16 +521,16 @@ function getDbgWindow(options, dbg, webConsole) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (window) {
|
if (window) {
|
||||||
evalWindow = window;
|
evalGlobal = window;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const dbgWindow = dbg.makeGlobalObjectReference(evalWindow);
|
const dbgGlobal = dbg.makeGlobalObjectReference(evalGlobal);
|
||||||
|
|
||||||
// If we have an object to bind to |_self|, create a Debugger.Object
|
// If we have an object to bind to |_self|, create a Debugger.Object
|
||||||
// referring to that object, belonging to dbg.
|
// referring to that object, belonging to dbg.
|
||||||
if (!options.selectedObjectActor) {
|
if (!options.selectedObjectActor) {
|
||||||
return { bindSelf: null, dbgWindow };
|
return { bindSelf: null, dbgGlobal };
|
||||||
}
|
}
|
||||||
|
|
||||||
// For objects related to console messages, they will be registered under the Target Actor
|
// For objects related to console messages, they will be registered under the Target Actor
|
||||||
|
@ -542,25 +541,25 @@ function getDbgWindow(options, dbg, webConsole) {
|
||||||
webConsole.parentActor.getActorByID(options.selectedObjectActor);
|
webConsole.parentActor.getActorByID(options.selectedObjectActor);
|
||||||
|
|
||||||
if (!actor) {
|
if (!actor) {
|
||||||
return { bindSelf: null, dbgWindow };
|
return { bindSelf: null, dbgGlobal };
|
||||||
}
|
}
|
||||||
|
|
||||||
const jsVal = actor instanceof LongStringActor ? actor.str : actor.rawValue();
|
const jsVal = actor instanceof LongStringActor ? actor.str : actor.rawValue();
|
||||||
if (!isObject(jsVal)) {
|
if (!isObject(jsVal)) {
|
||||||
return { bindSelf: jsVal, dbgWindow };
|
return { bindSelf: jsVal, dbgGlobal };
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we use the makeDebuggeeValue method of jsVal's own global, then
|
// If we use the makeDebuggeeValue method of jsVal's own global, then
|
||||||
// we'll get a D.O that sees jsVal as viewed from its own compartment -
|
// we'll get a D.O that sees jsVal as viewed from its own compartment -
|
||||||
// that is, without wrappers. The evalWithBindings call will then wrap
|
// that is, without wrappers. The evalWithBindings call will then wrap
|
||||||
// jsVal appropriately for the evaluation compartment.
|
// jsVal appropriately for the evaluation compartment.
|
||||||
const bindSelf = dbgWindow.makeDebuggeeValue(jsVal);
|
const bindSelf = dbgGlobal.makeDebuggeeValue(jsVal);
|
||||||
return { bindSelf, dbgWindow };
|
return { bindSelf, dbgGlobal };
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHelpers(dbgWindow, options, webConsole) {
|
function getHelpers(dbgGlobal, options, webConsole) {
|
||||||
// Get the Web Console commands for the given debugger window.
|
// Get the Web Console commands for the given debugger global.
|
||||||
const helpers = webConsole._getWebConsoleCommands(dbgWindow);
|
const helpers = webConsole._getWebConsoleCommands(dbgGlobal);
|
||||||
if (options.selectedNodeActor) {
|
if (options.selectedNodeActor) {
|
||||||
const actor = webConsole.conn.getActor(options.selectedNodeActor);
|
const actor = webConsole.conn.getActor(options.selectedNodeActor);
|
||||||
if (actor) {
|
if (actor) {
|
||||||
|
@ -582,7 +581,7 @@ function cleanupBindings(bindings, helperCache) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindCommands(isCmd, dbgWindow, bindSelf, frame, helpers) {
|
function bindCommands(isCmd, dbgGlobal, bindSelf, frame, helpers) {
|
||||||
const bindings = helpers.sandbox;
|
const bindings = helpers.sandbox;
|
||||||
if (bindSelf) {
|
if (bindSelf) {
|
||||||
bindings._self = bindSelf;
|
bindings._self = bindSelf;
|
||||||
|
@ -605,7 +604,7 @@ function bindCommands(isCmd, dbgWindow, bindSelf, frame, helpers) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
helpersToDisable = availableHelpers.filter(
|
helpersToDisable = availableHelpers.filter(
|
||||||
name => !!dbgWindow.getOwnPropertyDescriptor(name)
|
name => !!dbgGlobal.getOwnPropertyDescriptor(name)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// if we do not have the command key as a prefix, screenshot is disabled by default
|
// if we do not have the command key as a prefix, screenshot is disabled by default
|
||||||
|
|
|
@ -552,7 +552,7 @@ WebConsoleCommands._registerOriginal("cd", function(owner, window) {
|
||||||
Services.console.logMessage(scriptError);
|
Services.console.logMessage(scriptError);
|
||||||
|
|
||||||
if (!window) {
|
if (!window) {
|
||||||
owner.consoleActor.evalWindow = null;
|
owner.consoleActor.evalGlobal = null;
|
||||||
owner.helperResult = { type: "cd" };
|
owner.helperResult = { type: "cd" };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ WebConsoleCommands._registerOriginal("cd", function(owner, window) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
owner.consoleActor.evalWindow = window;
|
owner.consoleActor.evalGlobal = window;
|
||||||
owner.helperResult = { type: "cd" };
|
owner.helperResult = { type: "cd" };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ this.addEventListener("message", function(event) {
|
||||||
actorID: packet.id,
|
actorID: packet.id,
|
||||||
// threadActor is needed from the webconsole for grip previewing
|
// threadActor is needed from the webconsole for grip previewing
|
||||||
threadActor,
|
threadActor,
|
||||||
window: global,
|
workerGlobal: global,
|
||||||
|
|
||||||
onThreadAttached() {
|
onThreadAttached() {
|
||||||
postMessage(JSON.stringify({ type: "attached" }));
|
postMessage(JSON.stringify({ type: "attached" }));
|
||||||
|
|
Загрузка…
Ссылка в новой задаче