diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index bbd728a72859..6454ac898e87 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -20,6 +20,7 @@ #include "mozilla/dom/RootedDictionary.h" #include "mozilla/dom/workers/Workers.h" #include "mozilla/ErrorResult.h" +#include "mozilla/HoldDropJSObjects.h" #include "mozilla/Likely.h" #include "mozilla/Util.h" #include "nsCycleCollector.h" @@ -2323,6 +2324,8 @@ CreateGlobal(JSContext* aCx, T* aObject, nsWrapperCache* aCache, return nullptr; } + mozilla::HoldJSObjects(aObject); + return global; } diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index ecc5e7459cd1..9a7f9f2d5c2a 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -41,6 +41,8 @@ WorkerGlobalScope::WorkerGlobalScope(WorkerPrivate* aWorkerPrivate) WorkerGlobalScope::~WorkerGlobalScope() { + // Matches the HoldJSObjects in CreateGlobal. + mozilla::DropJSObjects(this); } NS_IMPL_CYCLE_COLLECTION_CLASS(WorkerGlobalScope) diff --git a/dom/workers/test/mochitest.ini b/dom/workers/test/mochitest.ini index ce42a9cb05d8..4c60ab35ba48 100644 --- a/dom/workers/test/mochitest.ini +++ b/dom/workers/test/mochitest.ini @@ -45,6 +45,7 @@ support-files = threadErrors_worker4.js threadTimeouts_worker.js throwingOnerror_worker.js + timeoutTracing_worker.js transferable_worker.js urlApi_worker.js url_worker.js @@ -96,6 +97,7 @@ support-files = [test_threadErrors.html] [test_threadTimeouts.html] [test_throwingOnerror.html] +[test_timeoutTracing.html] [test_transferable.html] [test_url.html] [test_urlApi.html] diff --git a/dom/workers/test/test_timeoutTracing.html b/dom/workers/test/test_timeoutTracing.html new file mode 100644 index 000000000000..b995f487908e --- /dev/null +++ b/dom/workers/test/test_timeoutTracing.html @@ -0,0 +1,47 @@ + + + + + + Test for DOM Worker Threads + + + + +
+
+
+ + + diff --git a/dom/workers/test/timeoutTracing_worker.js b/dom/workers/test/timeoutTracing_worker.js new file mode 100644 index 000000000000..d0759642b38f --- /dev/null +++ b/dom/workers/test/timeoutTracing_worker.js @@ -0,0 +1,12 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +onmessage = function(event) { + throw "No messages should reach me!"; +} + +setInterval(function() { postMessage("Still alive!"); }, 20); + +postMessage("Begin!");