mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 13:57:32 +00:00
Bug 943516 - Add weak map wrapper preserving key callback to workers. r=peterv on a CLOSED TREE
This commit is contained in:
parent
49e9bd979c
commit
94f9448048
@ -843,6 +843,16 @@ CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate, JSRuntime* aRuntime)
|
|||||||
return workerCx;
|
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
|
class WorkerJSRuntime : public mozilla::CycleCollectedJSRuntime
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -854,6 +864,7 @@ public:
|
|||||||
WORKER_DEFAULT_NURSERY_SIZE),
|
WORKER_DEFAULT_NURSERY_SIZE),
|
||||||
mWorkerPrivate(aWorkerPrivate)
|
mWorkerPrivate(aWorkerPrivate)
|
||||||
{
|
{
|
||||||
|
js::SetPreserveWrapperCallback(Runtime(), PreserveWrapper);
|
||||||
JS_InitDestroyPrincipalsCallback(Runtime(), DestroyWorkerPrincipals);
|
JS_InitDestroyPrincipalsCallback(Runtime(), DestroyWorkerPrincipals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
dom/workers/test/943516.html
Normal file
10
dom/workers/test/943516.html
Normal 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>
|
1
dom/workers/test/crashtests.list
Normal file
1
dom/workers/test/crashtests.list
Normal file
@ -0,0 +1 @@
|
|||||||
|
load 943516.html
|
@ -26,6 +26,7 @@ include ../../dom/mathml/crashtests/crashtests.list
|
|||||||
include ../../dom/offline/crashtests/crashtests.list
|
include ../../dom/offline/crashtests/crashtests.list
|
||||||
include ../../dom/plugins/test/crashtests/crashtests.list
|
include ../../dom/plugins/test/crashtests/crashtests.list
|
||||||
include ../../dom/smil/crashtests/crashtests.list
|
include ../../dom/smil/crashtests/crashtests.list
|
||||||
|
include ../../dom/workers/test/crashtests.list
|
||||||
include ../../dom/xbl/crashtests/crashtests.list
|
include ../../dom/xbl/crashtests/crashtests.list
|
||||||
include ../../dom/xml/crashtests/crashtests.list
|
include ../../dom/xml/crashtests/crashtests.list
|
||||||
include ../../dom/xslt/crashtests/crashtests.list
|
include ../../dom/xslt/crashtests/crashtests.list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user