Bug 1567210 - Use Thread actor reference to distinguish the event loops. r=loganfsmyth

Use thread actor reference instead of target's actor URL *and* connection
to distinguish the currently paused event loop from the other ones which
may be on-pause from another thread actor on another connection/tab.
This happens when connecting more than one client against the same tab.

Differential Revision: https://phabricator.services.mozilla.com/D39705

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexandre Poirot 2019-07-31 15:52:30 +00:00
parent 82ff0428d0
commit a7fb7812f4
2 changed files with 10 additions and 35 deletions

View File

@ -347,7 +347,6 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
// Initialize an event loop stack. This can't be done in the constructor,
// because this.conn is not yet initialized by the actor pool at that time.
this._nestedEventLoops = new EventLoopStack({
connection: this.conn,
thread: this,
});
@ -1208,14 +1207,12 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
// only allow resumption in a LIFO order.
if (
this._nestedEventLoops.size &&
this._nestedEventLoops.lastPausedUrl &&
(this._nestedEventLoops.lastPausedUrl !== this._parent.url ||
this._nestedEventLoops.lastConnection !== this.conn)
this._nestedEventLoops.lastPausedThreadActor &&
this._nestedEventLoops.lastPausedThreadActor !== this
) {
return {
error: "wrongOrder",
message: "trying to resume in the wrong order.",
lastPausedUrl: this._nestedEventLoops.lastPausedUrl,
};
}

View File

@ -14,12 +14,9 @@ const xpcInspector = require("xpcInspector");
*
* @param ThreadActor thread
* The thread actor instance that owns this EventLoopStack.
* @param DebuggerServerConnection connection
* The remote protocol connection associated with this event loop stack.
*/
function EventLoopStack({ thread, connection }) {
function EventLoopStack({ thread }) {
this._thread = thread;
this._connection = connection;
}
EventLoopStack.prototype = {
@ -31,28 +28,13 @@ EventLoopStack.prototype = {
},
/**
* The URL of the debuggee who pushed the event loop on top of the stack.
* The thread actor of the debuggee who pushed the event loop on top of the stack.
*/
get lastPausedUrl() {
let url = null;
get lastPausedThreadActor() {
if (this.size > 0) {
try {
url = xpcInspector.lastNestRequestor.url;
} catch (e) {
// The tab's URL getter may throw if the tab is destroyed by the time
// this code runs, but we don't really care at this point.
dumpn(e);
}
return xpcInspector.lastNestRequestor.thread;
}
return url;
},
/**
* The DebuggerServerConnection of the debugger who pushed the event loop on
* top of the stack
*/
get lastConnection() {
return xpcInspector.lastNestRequestor._connection;
return null;
},
/**
@ -63,7 +45,6 @@ EventLoopStack.prototype = {
push: function() {
return new EventLoop({
thread: this._thread,
connection: this._connection,
});
},
};
@ -74,12 +55,9 @@ EventLoopStack.prototype = {
*
* @param ThreadActor thread
* The thread actor that is creating this nested event loop.
* @param DebuggerServerConnection connection
* The remote protocol connection associated with this event loop.
*/
function EventLoop({ thread, connection }) {
function EventLoop({ thread }) {
this._thread = thread;
this._connection = connection;
this.enter = this.enter.bind(this);
this.resolve = this.resolve.bind(this);
@ -88,8 +66,8 @@ function EventLoop({ thread, connection }) {
EventLoop.prototype = {
entered: false,
resolved: false,
get url() {
return this._thread._parent.url;
get thread() {
return this._thread;
},
/**