Bug 1237492 - Hold a strong reference to the Worker used in webconsole tests. r=ejpbruel
authorSami Jaktholm <sjakthol@outlook.com>
Sun, 17 Jul 2016 10:10:08 +0300
changeset 306079 0cca5d80caa9f04d491c28b388f2f396fd45fe5c
parent 306078 ead2d5b90435613618f9dfc74e440fd137648bdd
child 306080 f272791a6d75ec9d551f9c73493eaa39021e5827
push id79765
push usercbook@mozilla.com
push dateThu, 21 Jul 2016 14:26:34 +0000
treeherdermozilla-inbound@ab54bfc55266 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersejpbruel
bugs1237492
milestone50.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 1237492 - Hold a strong reference to the Worker used in webconsole tests. r=ejpbruel 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;