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

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
yulia 2019-06-14 00:16:39 +00:00
Родитель 844b51e01a
Коммит 2e3fde9d0e
3 изменённых файлов: 10 добавлений и 11 удалений

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

@ -553,7 +553,7 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
const pkt = onPacket(packet);
this._priorPause = pkt;
this.conn.send(pkt);
this.conn.sendActorEvent(this.actorID, "paused", pkt);
} catch (error) {
reportError(error);
this.conn.send({
@ -1151,31 +1151,30 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
/**
* Handle a protocol request to pause the debuggee.
*/
onInterrupt: function(request) {
onInterrupt: function({when}) {
if (this.state == "exited") {
return { type: "exited" };
} else if (this.state == "paused") {
// TODO: return the actual reason for the existing pause.
return { type: "paused", why: { type: "alreadyPaused" } };
this.conn.sendActorEvent(this.actorID, "paused", { why: { type: "alreadyPaused" }});
return {};
} else if (this.state != "running") {
return { error: "wrongState",
message: "Received interrupt request in " + this.state +
" state." };
}
try {
// If execution should pause just before the next JavaScript bytecode is
// executed, just set an onEnterFrame handler.
if (request.when == "onNext" && !this.dbg.replaying) {
if (when == "onNext" && !this.dbg.replaying) {
const onEnterFrame = (frame) => {
return this._pauseAndRespond(frame, { type: "interrupted", onNext: true });
this._pauseAndRespond(frame, { type: "interrupted", onNext: true });
};
this.dbg.onEnterFrame = onEnterFrame;
this.conn.sendActorEvent(this.actorID, "willInterrupt");
return {};
}
if (this.dbg.replaying) {
this.dbg.replayPause();
}
@ -1194,7 +1193,8 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
// Send the response to the interrupt request now (rather than
// returning it), because we're going to start a nested event loop
// here.
this.conn.send(packet);
this.conn.send({from: this.actorID, type: "interrupt"});
this.conn.sendActorEvent(this.actorID, "paused", packet);
// Start a nested event loop.
this._pushThreadPause();

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

@ -40,12 +40,12 @@ async function test_nesting() {
try {
await gThreadClient1.resume();
} catch (e) {
Assert.equal(e.error, "wrongOrder");
Assert.ok(e.includes("wrongOrder"));
}
try {
await gThreadClient2.resume();
} catch (e) {
Assert.ok(!e.error);
Assert.ok(!e);
}
gThreadClient1.resume().then(response => {

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

@ -72,7 +72,6 @@ const threadSpec = generateActorSpec({
request: {
when: Arg(0, "json"),
},
response: RetVal("nullable:json"),
},
sources: {
response: RetVal("array:json"),