Bug 1530554 - Fix expression evaluation in worker threads; r=bhackett
authoryulia <ystartsev@mozilla.com>
Tue, 26 Feb 2019 15:58:21 +0000
changeset 519299 6d30c0a23b536f2092bde4adbcaf186e12c05a81
parent 519298 7fd5f6eee38b621a0dc06409436e72b91c518e66
child 519300 3be1277a87d2e755e1a820fa5cb959cec4839122
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1530554
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530554 - Fix expression evaluation in worker threads; r=bhackett Differential Revision: https://phabricator.services.mozilla.com/D21226
devtools/client/debugger/new/src/client/firefox/workers.js
devtools/client/debugger/new/test/mochitest/browser_dbg-windowless-workers.js
--- a/devtools/client/debugger/new/src/client/firefox/workers.js
+++ b/devtools/client/debugger/new/src/client/firefox/workers.js
@@ -32,17 +32,17 @@ export async function updateWorkerClient
       if (workerClients[workerThread.actor].thread != workerThread) {
         throw new Error(`Multiple clients for actor ID: ${workerThread.actor}`);
       }
       newWorkerClients[workerThread.actor] = workerClients[workerThread.actor];
     } else {
       addThreadEventListeners(workerThread);
       workerThread.resume();
 
-      const consoleFront = await tabTarget.getFront("console");
+      const consoleFront = await workerTargetFront.getFront("console");
       await consoleFront.startListeners([]);
 
       newWorkerClients[workerThread.actor] = {
         url: workerTargetFront.url,
         thread: workerThread,
         console: consoleFront
       };
     }
--- a/devtools/client/debugger/new/test/mochitest/browser_dbg-windowless-workers.js
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-windowless-workers.js
@@ -11,16 +11,24 @@ function threadIsPaused(dbg, index) {
 }
 
 function threadIsSelected(dbg, index) {
   return findElement(dbg, "threadsPaneItem", index).classList.contains(
     "selected"
   );
 }
 
+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() {
   await pushPref("devtools.debugger.features.windowless-workers", true);
 
   const dbg = await initDebugger("doc-windowless-workers.html");
   const mainThread = dbg.toolbox.threadClient.actor;
 
@@ -40,20 +48,31 @@ add_task(async function() {
 
   info("Test pausing in a worker");
   await dbg.actions.selectThread(worker1Thread);
   assertNotPaused(dbg);
   await dbg.actions.breakOnNext();
   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);
 
   info("Test stepping in the main thread");
   dbg.actions.selectThread(mainThread);
   await stepOver(dbg);
   assertPausedAtSourceAndLine(dbg, mainThreadSource.id, 11);