Bug 1042642 - Stop using the DebuggerClient instance to listen for ThreadClient events in tests; r=jdescottes

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
yulia 2019-05-30 08:38:51 +00:00
Родитель a9f8c70111
Коммит ae4a4c8517
3 изменённых файлов: 11 добавлений и 9 удалений

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

@ -34,6 +34,8 @@ async function testEarlyDebuggerStatement(client, tab, targetFront) {
ok(false, "Pause shouldn't be called before we've attached!");
};
// using the DebuggerClient to listen to the pause packet, as the
// threadClient is not yet attached.
client.on("paused", onPaused);
// This should continue without nesting an event loop and calling
@ -52,7 +54,7 @@ async function testEarlyDebuggerStatement(client, tab, targetFront) {
async function testDebuggerStatement(client, tab, threadClient) {
const onPaused = new Promise(resolve => {
client.on("paused", async (packet) => {
threadClient.on("paused", async (packet) => {
await threadClient.resume();
ok(true, "The pause handler was triggered on a debugger statement.");
resolve();

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

@ -28,12 +28,12 @@ const secondLocation = {
column: 18,
};
add_task(threadClientTest(({ threadClient, debuggee, client }) => {
add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => {
client.on("paused", async (packet) => {
threadClient.on("paused", async (packet) => {
const [ first, second ] = await set_breakpoints(packet, threadClient);
test_different_actors(first, second);
await test_remove_one(first, second, threadClient, debuggee, client);
await test_remove_one(first, second, threadClient, debuggee);
resolve();
});
@ -70,13 +70,13 @@ function test_different_actors(first, second) {
"Each breakpoint should have a different actor");
}
function test_remove_one(first, second, threadClient, debuggee, client) {
function test_remove_one(first, second, threadClient, debuggee) {
return new Promise(resolve => {
first.remove(function({error}) {
Assert.ok(!error, "Should not get an error removing a breakpoint");
let hitSecond;
client.on("paused", function _onPaused({why, frame}) {
threadClient.on("paused", function _onPaused({why, frame}) {
if (why.type == "breakpoint") {
hitSecond = true;
Assert.equal(why.actors.length, 1,
@ -92,7 +92,7 @@ function test_remove_one(first, second, threadClient, debuggee, client) {
}
if (why.type == "debuggerStatement") {
client.off("paused", _onPaused);
threadClient.off("paused", _onPaused);
Assert.ok(hitSecond,
"We should still hit `second`, but not `first`.");

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

@ -5,11 +5,11 @@
const xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
add_task(threadClientTest(async ({ threadClient, debuggee, client, targetFront }) => {
add_task(threadClientTest(async ({ threadClient, debuggee, targetFront }) => {
Assert.equal(xpcInspector.eventLoopNestLevel, 0);
await new Promise(resolve => {
client.on("paused", function(packet) {
threadClient.on("paused", function(packet) {
Assert.equal(false, "error" in packet);
Assert.equal(packet.from, threadClient.actor);
Assert.equal(packet.type, "paused");