Bug 943516 - Add weak map wrapper preserving key callback to workers. r=peterv on a CLOSED TREE

This commit is contained in:
Andrew McCreight 2014-10-08 16:27:55 -07:00
parent 49e9bd979c
commit 94f9448048
4 changed files with 23 additions and 0 deletions

View File

@ -843,6 +843,16 @@ CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate, JSRuntime* aRuntime)
return workerCx;
}
static bool
PreserveWrapper(JSContext *cx, JSObject *obj)
{
MOZ_ASSERT(cx);
MOZ_ASSERT(obj);
MOZ_ASSERT(mozilla::dom::IsDOMObject(obj));
return mozilla::dom::TryPreserveWrapper(obj);
}
class WorkerJSRuntime : public mozilla::CycleCollectedJSRuntime
{
public:
@ -854,6 +864,7 @@ public:
WORKER_DEFAULT_NURSERY_SIZE),
mWorkerPrivate(aWorkerPrivate)
{
js::SetPreserveWrapperCallback(Runtime(), PreserveWrapper);
JS_InitDestroyPrincipalsCallback(Runtime(), DestroyWorkerPrincipals);
}

View File

@ -0,0 +1,10 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE html>
<script>
// Using a DOM bindings object as a weak map key should not crash when attempting to
// call the preserve wrapper callback.
new Worker("data:text/javascript;charset=UTF-8,(new WeakMap()).set(self, 0);")
</script>

View File

@ -0,0 +1 @@
load 943516.html

View File

@ -26,6 +26,7 @@ include ../../dom/mathml/crashtests/crashtests.list
include ../../dom/offline/crashtests/crashtests.list
include ../../dom/plugins/test/crashtests/crashtests.list
include ../../dom/smil/crashtests/crashtests.list
include ../../dom/workers/test/crashtests.list
include ../../dom/xbl/crashtests/crashtests.list
include ../../dom/xml/crashtests/crashtests.list
include ../../dom/xslt/crashtests/crashtests.list