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

--HG--
extra : transplant_source : %C1%97%D86%09Bd%AB%E8%08%98%D4%29%25S%A3%B8%2C%8E%11
This commit is contained in:
Sami Jaktholm 2016-07-17 10:10:08 +03:00
Родитель 6f1a0a43ef
Коммит f88f710018
1 изменённых файлов: 3 добавлений и 0 удалений

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

@ -97,6 +97,9 @@ function _attachConsole(aListeners, aCallback, aAttachToTab, aAttachToWorker)
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) {