Bug 1237492 - Hold a strong reference to the Worker used in webconsole tests. r=ejpbruel, a=test-only
authorSami Jaktholm <sjakthol@outlook.com>
Sun, 17 Jul 2016 10:10:08 +0300
changeset 342068 591bffeb167fdf0bc19f547619612c4eac7a4129
parent 342067 550f70e6855f21fea5d88f8afdbb6912886452cd
child 342069 2d8d82f4786b72de0bb98a4cbae63ed53f1a6d02
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersejpbruel, test-only
bugs1237492
milestone49.0a2
Bug 1237492 - Hold a strong reference to the Worker used in webconsole tests. r=ejpbruel, a=test-only If a reference is not kept, the Worker might be GCd before the test compteles. If that happens, the test times out as it tries to detach a worker that has already been destroyed. The state object is kept around for the duration of the tests so keeping a reference in the state object ensures the worker lifetime matches that of the test. MozReview-Commit-ID: 31F54vHlm3z
devtools/shared/webconsole/test/common.js
--- a/devtools/shared/webconsole/test/common.js
+++ b/devtools/shared/webconsole/test/common.js
@@ -92,16 +92,19 @@ function _attachConsole(aListeners, aCal
           aCallback(aState, aResponse);
           return;
         }
         let tab = aResponse.tabs[aResponse.selected];
         aState.dbgClient.attachTab(tab.actor, function (response, tabClient) {
           if (aAttachToWorker) {
             let workerName = "console-test-worker.js#" + new Date().getTime();
             var worker = new Worker(workerName);
+            // Keep a strong reference to the Worker to avoid it being
+            // GCd during the test (bug 1237492).
+            aState._worker_ref = worker;
             worker.addEventListener("message", function listener() {
               worker.removeEventListener("message", listener);
               tabClient.listWorkers(function (response) {
                 let worker = response.workers.filter(w => w.url == workerName)[0];
                 if (!worker) {
                   console.error("listWorkers failed. Unable to find the " +
                                 "worker actor\n");
                   return;