зеркало из https://github.com/mozilla/gecko-dev.git
Bug 997119 - Move ThreadActor logic from BrowsingContext. r=yulia
Differential Revision: https://phabricator.services.mozilla.com/D36554 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8af4bd8505
Коммит
32e32e8cea
|
@ -1346,25 +1346,6 @@ const browsingContextTargetPrototype = {
|
||||||
isTopLevel: isTopLevel,
|
isTopLevel: isTopLevel,
|
||||||
id: getWindowID(window),
|
id: getWindowID(window),
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO bug 997119: move that code to ThreadActor by listening to
|
|
||||||
// window-ready
|
|
||||||
const threadActor = this.threadActor;
|
|
||||||
if (isTopLevel && threadActor.state != "detached") {
|
|
||||||
this.sources.reset();
|
|
||||||
threadActor.clearDebuggees();
|
|
||||||
threadActor.dbg.enable();
|
|
||||||
threadActor.maybePauseOnExceptions();
|
|
||||||
// Update the global no matter if the debugger is on or off,
|
|
||||||
// otherwise the global will be wrong when enabled later.
|
|
||||||
threadActor.global = window;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Refresh the debuggee list when a new window object appears (top window or
|
|
||||||
// iframe).
|
|
||||||
if (threadActor.attached) {
|
|
||||||
threadActor.dbg.addDebuggees();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_windowDestroyed(window, id = null, isFrozen = false) {
|
_windowDestroyed(window, id = null, isFrozen = false) {
|
||||||
|
@ -1417,16 +1398,6 @@ const browsingContextTargetPrototype = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proceed normally only if the debuggee is not paused.
|
|
||||||
// TODO bug 997119: move that code to ThreadActor by listening to
|
|
||||||
// will-navigate
|
|
||||||
const threadActor = this.threadActor;
|
|
||||||
if (threadActor.state == "paused") {
|
|
||||||
threadActor.unsafeSynchronize(Promise.resolve(threadActor.doResume()));
|
|
||||||
threadActor.dbg.disable();
|
|
||||||
}
|
|
||||||
threadActor.disableAllBreakpoints();
|
|
||||||
|
|
||||||
this.emit("tabNavigated", {
|
this.emit("tabNavigated", {
|
||||||
url: newURI,
|
url: newURI,
|
||||||
nativeConsoleAPI: true,
|
nativeConsoleAPI: true,
|
||||||
|
@ -1461,12 +1432,6 @@ const browsingContextTargetPrototype = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO bug 997119: move that code to ThreadActor by listening to navigate
|
|
||||||
const threadActor = this.threadActor;
|
|
||||||
if (threadActor.state == "running") {
|
|
||||||
threadActor.dbg.enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.emit("tabNavigated", {
|
this.emit("tabNavigated", {
|
||||||
url: this.url,
|
url: this.url,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
|
|
|
@ -138,6 +138,13 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
|
||||||
this._onOpeningRequest = this._onOpeningRequest.bind(this);
|
this._onOpeningRequest = this._onOpeningRequest.bind(this);
|
||||||
this._onNewDebuggee = this._onNewDebuggee.bind(this);
|
this._onNewDebuggee = this._onNewDebuggee.bind(this);
|
||||||
this._eventBreakpointListener = this._eventBreakpointListener.bind(this);
|
this._eventBreakpointListener = this._eventBreakpointListener.bind(this);
|
||||||
|
this._onWindowReady = this._onWindowReady.bind(this);
|
||||||
|
this._onWillNavigate = this._onWillNavigate.bind(this);
|
||||||
|
this._onNavigate = this._onNavigate.bind(this);
|
||||||
|
|
||||||
|
this._parent.on("window-ready", this._onWindowReady);
|
||||||
|
this._parent.on("will-navigate", this._onWillNavigate);
|
||||||
|
this._parent.on("navigate", this._onNavigate);
|
||||||
|
|
||||||
this._debuggerNotificationObserver = new DebuggerNotificationObserver();
|
this._debuggerNotificationObserver = new DebuggerNotificationObserver();
|
||||||
|
|
||||||
|
@ -282,6 +289,10 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._parent.off("window-ready", this._onWindowReady);
|
||||||
|
this._parent.off("will-navigate", this._onWillNavigate);
|
||||||
|
this._parent.off("navigate", this._onNavigate);
|
||||||
|
|
||||||
this.sources.off("newSource", this.onNewSourceEvent);
|
this.sources.off("newSource", this.onNewSourceEvent);
|
||||||
this.clearDebuggees();
|
this.clearDebuggees();
|
||||||
this.conn.removeActorPool(this._threadLifetimePool);
|
this.conn.removeActorPool(this._threadLifetimePool);
|
||||||
|
@ -1752,6 +1763,43 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_onWindowReady: function({ isTopLevel, window }) {
|
||||||
|
if (isTopLevel && this.state != "detached") {
|
||||||
|
this.sources.reset();
|
||||||
|
this.clearDebuggees();
|
||||||
|
this.dbg.enabled = true;
|
||||||
|
this.maybePauseOnExceptions();
|
||||||
|
// Update the global no matter if the debugger is on or off,
|
||||||
|
// otherwise the global will be wrong when enabled later.
|
||||||
|
this.global = window;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh the debuggee list when a new window object appears (top window or
|
||||||
|
// iframe).
|
||||||
|
if (this.attached) {
|
||||||
|
this.dbg.addDebuggees();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_onWillNavigate: function({ isTopLevel }) {
|
||||||
|
if (!isTopLevel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Proceed normally only if the debuggee is not paused.
|
||||||
|
if (this.state == "paused") {
|
||||||
|
this.unsafeSynchronize(Promise.resolve(this.doResume()));
|
||||||
|
this.dbg.enabled = false;
|
||||||
|
}
|
||||||
|
this.disableAllBreakpoints();
|
||||||
|
},
|
||||||
|
|
||||||
|
_onNavigate: function() {
|
||||||
|
if (this.state == "running") {
|
||||||
|
this.dbg.enabled = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// JS Debugger API hooks.
|
// JS Debugger API hooks.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,6 +37,7 @@ this.rpc = function(method, ...params) {
|
||||||
loadSubScript("resource://devtools/shared/worker/loader.js");
|
loadSubScript("resource://devtools/shared/worker/loader.js");
|
||||||
|
|
||||||
var defer = worker.require("devtools/shared/defer");
|
var defer = worker.require("devtools/shared/defer");
|
||||||
|
var EventEmitter = worker.require("devtools/shared/event-emitter");
|
||||||
var { ActorPool } = worker.require("devtools/server/actors/common");
|
var { ActorPool } = worker.require("devtools/server/actors/common");
|
||||||
var { ThreadActor } = worker.require("devtools/server/actors/thread");
|
var { ThreadActor } = worker.require("devtools/server/actors/thread");
|
||||||
var { WebConsoleActor } = worker.require("devtools/server/actors/webconsole");
|
var { WebConsoleActor } = worker.require("devtools/server/actors/webconsole");
|
||||||
|
@ -97,6 +98,8 @@ this.addEventListener("message", function(event) {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
EventEmitter.decorate(parent);
|
||||||
|
|
||||||
const threadActor = new ThreadActor(parent, global);
|
const threadActor = new ThreadActor(parent, global);
|
||||||
pool.addActor(threadActor);
|
pool.addActor(threadActor);
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ const {
|
||||||
const { TabSources } = require("devtools/server/actors/utils/TabSources");
|
const { TabSources } = require("devtools/server/actors/utils/TabSources");
|
||||||
const makeDebugger = require("devtools/server/actors/utils/make-debugger");
|
const makeDebugger = require("devtools/server/actors/utils/make-debugger");
|
||||||
|
|
||||||
|
const noop = () => {};
|
||||||
|
|
||||||
var gTestGlobals = new Set();
|
var gTestGlobals = new Set();
|
||||||
DebuggerServer.addTestGlobal = function(global) {
|
DebuggerServer.addTestGlobal = function(global) {
|
||||||
gTestGlobals.add(global);
|
gTestGlobals.add(global);
|
||||||
|
@ -122,6 +124,8 @@ function TestTargetActor(connection, global) {
|
||||||
TestTargetActor.prototype = {
|
TestTargetActor.prototype = {
|
||||||
constructor: TestTargetActor,
|
constructor: TestTargetActor,
|
||||||
actorPrefix: "TestTargetActor",
|
actorPrefix: "TestTargetActor",
|
||||||
|
on: noop,
|
||||||
|
off: noop,
|
||||||
|
|
||||||
get window() {
|
get window() {
|
||||||
return this._global;
|
return this._global;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче