Bug 979951: Always preserve the worker wrapper to ensure that we have something to tell us what compartment to enter. r=bent
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -2137,17 +2137,25 @@ JSObject*
WorkerPrivateParent<Derived>::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope)
{
MOZ_ASSERT(!IsSharedWorker(),
"We should never wrap a WorkerPrivate for a SharedWorker");
AssertIsOnParentThread();
- return WorkerBinding::Wrap(aCx, aScope, ParentAsWorkerPrivate());
+ // XXXkhuey this should not need to be rooted, the analysis is dumb.
+ // See bug 980181.
+ JS::Rooted<JSObject*> wrapper(aCx,
+ WorkerBinding::Wrap(aCx, aScope, ParentAsWorkerPrivate()));
+ if (wrapper) {
+ MOZ_ALWAYS_TRUE(TryPreserveWrapper(wrapper));
+ }
+
+ return wrapper;
}
template <class Derived>
nsresult
WorkerPrivateParent<Derived>::DispatchPrivate(WorkerRunnable* aRunnable,
nsIEventTarget* aSyncLoopTarget)
{
// May be called on any thread!