From 6b47255bce09c3d71ec817fb8029ea833f8a3f96 Mon Sep 17 00:00:00 2001 From: yulia Date: Tue, 26 Feb 2019 15:58:21 +0000 Subject: [PATCH] Bug 1530554 - Fix expression evaluation in worker threads; r=bhackett Differential Revision: https://phabricator.services.mozilla.com/D21226 --HG-- extra : moz-landing-system : lando --- .../new/src/client/firefox/workers.js | 2 +- .../browser_dbg-windowless-workers.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/devtools/client/debugger/new/src/client/firefox/workers.js b/devtools/client/debugger/new/src/client/firefox/workers.js index 6c644b50197e..096445a3a0e6 100644 --- a/devtools/client/debugger/new/src/client/firefox/workers.js +++ b/devtools/client/debugger/new/src/client/firefox/workers.js @@ -37,7 +37,7 @@ export async function updateWorkerClients({ addThreadEventListeners(workerThread); workerThread.resume(); - const consoleFront = await tabTarget.getFront("console"); + const consoleFront = await workerTargetFront.getFront("console"); await consoleFront.startListeners([]); newWorkerClients[workerThread.actor] = { diff --git a/devtools/client/debugger/new/test/mochitest/browser_dbg-windowless-workers.js b/devtools/client/debugger/new/test/mochitest/browser_dbg-windowless-workers.js index 772db2ae3fcf..749936dec585 100644 --- a/devtools/client/debugger/new/test/mochitest/browser_dbg-windowless-workers.js +++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-windowless-workers.js @@ -16,6 +16,14 @@ function threadIsSelected(dbg, index) { ); } +function getLabel(dbg, index) { + return findElement(dbg, "expressionNode", index).innerText; +} + +function getValue(dbg, index) { + return findElement(dbg, "expressionValue", index).innerText; +} + // Test basic windowless worker functionality: the main thread and worker can be // separately controlled from the same debugger. add_task(async function() { @@ -45,10 +53,21 @@ add_task(async function() { await waitForPaused(dbg, "simple-worker.js"); assertPausedAtSourceAndLine(dbg, workerSource.id, 3); + await addExpression(dbg, "count"); + is(getLabel(dbg, 1), "count"); + const v = getValue(dbg, 1); + ok(v == "" + +v, "Value of count should be a number"); + info("Test stepping in a worker"); await stepOver(dbg); assertPausedAtSourceAndLine(dbg, workerSource.id, 4); + // The watch expression should update with an incremented value. + await waitUntil(() => { + const v2 = getValue(dbg, 1); + return +v2 == +v + 1; + }); + info("Test resuming in a worker"); await resume(dbg); assertNotPaused(dbg);