Bug 1494796 - get rid of ThreadClient specifics in DebuggerClient ; r=jdescottes

This is part one of removing threadClient specifics out of the debuggerClient. We were
managing messages from the thread client in a special way -- this was the "Unsolicited Pauses"
object that we had before. This patch updates the threadClient to use Front style events. This
required updating the spec for the threadClient, and several of the methods. What has not been fully
migrated here is the "resumed" event, as this is much more complex. This is taken care of in the
next patch.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
yulia 2019-06-14 00:28:03 +00:00
Родитель 650d7f9c31
Коммит ecc3907641
5 изменённых файлов: 40 добавлений и 11 удалений

Просмотреть файл

@ -392,9 +392,12 @@ async function attachTestTab(client, title) {
// thread.
async function attachTestThread(client, title, callback = () => {}) {
const targetFront = await attachTestTab(client, title);
const [response, threadClient] = await targetFront.attachThread({
const threadClient = await targetFront.getFront("context");
const onPaused = threadClient.once("paused");
await targetFront.attachThread({
autoBlackBox: true,
});
const response = await onPaused;
Assert.equal(threadClient.state, "paused", "Thread client is paused");
Assert.ok("why" in response);
Assert.equal(response.why.type, "attached");

Просмотреть файл

@ -46,12 +46,10 @@ async function test_nesting() {
await gThreadClient2.resume();
} catch (e) {
Assert.ok(!e.error);
Assert.equal(e.from, gThreadClient2.actor);
}
gThreadClient1.resume().then(response => {
Assert.ok(!response.error);
Assert.equal(response.from, gThreadClient1.actor);
gClient1.close(() => finishClient(gClient2));
});

Просмотреть файл

@ -229,7 +229,6 @@ ThreadClient.prototype = {
type: "detach",
}, {
after: function(response) {
this.client.unregisterClient(this);
return response;
},
}),
@ -342,7 +341,7 @@ ThreadClient.prototype = {
// The debugger UI may not be initialized yet so we want to keep
// the packet around so it knows what to pause state to display
// when it's initialized
this._lastPausePacket = packet.type === "resumed" ? null : packet;
this._lastPausePacket = packet;
this._clearPauseGrips();
packet.type === ThreadStateTypes.detached && this._clearThreadGrips();
this.client._eventsEnabled && this.emit(packet.type, packet);

Просмотреть файл

@ -38,6 +38,12 @@ class ThreadClient extends FrontClassWithSpec(threadSpec) {
this._pauseGrips = {};
this._threadGrips = {};
this._state = "paused";
this._beforePaused = this._beforePaused.bind(this);
this._beforeResumed = this._beforeResumed.bind(this);
this._beforeDetached = this._beforeDetached.bind(this);
this.before("paused", this._beforePaused);
this.before("resumed", this._beforeResumed);
this.before("detached", this._beforeDetached);
this.actorID = actor;
this.manage(this);
}
@ -276,18 +282,31 @@ class ThreadClient extends FrontClassWithSpec(threadSpec) {
this._clearObjectClients("_threadGrips");
}
_beforePaused(packet) {
this._state = "paused";
this._onThreadState(packet);
}
_beforeResumed() {
this._state = "attached";
this._onThreadState(null);
}
_beforeDetached(packet) {
this._state = "detached";
this._onThreadState(packet);
this._clearThreadGrips();
}
/**
* Handle thread state change by doing necessary cleanup
*/
_onThreadState(packet) {
this._state = ThreadStateTypes[packet.type];
// The debugger UI may not be initialized yet so we want to keep
// the packet around so it knows what to pause state to display
// when it's initialized
this._lastPausePacket = packet.type === "resumed" ? null : packet;
this._lastPausePacket = packet;
this._clearPauseGrips();
packet.type === ThreadStateTypes.detached && this._clearThreadGrips();
this.client._eventsEnabled && this.emit(packet.type, packet);
}
getLastPausePacket() {

Просмотреть файл

@ -18,8 +18,18 @@ const threadSpec = generateActorSpec({
typeName: "context",
events: {
paused: {
actor: Option(0, "nullable:string"),
frame: Option(0, "nullable:json"),
why: Option(0, "nullable:json"),
poppedFrames: Option(0, "nullable:json"),
error: Option(0, "nullable:json"),
},
resumed: {},
detached: {},
willInterrupt: {},
newSource: {
source: Option(0, "source"),
source: Option(0, "json"),
},
progress: {
recording: Option(0, "json"),
@ -61,7 +71,7 @@ const threadSpec = generateActorSpec({
request: {
when: Arg(0, "json"),
},
response: RetVal("array:json"),
response: RetVal("nullable:json"),
},
sources: {
response: RetVal("array:json"),