From 4891262c8d17805099e2e3340fbbb28d8651bd52 Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Fri, 14 Jun 2019 13:23:57 +0000 Subject: [PATCH] Bug 1542931 serialize AudioWorkletNodeOptions r=padenot Depends on D34478 Differential Revision: https://phabricator.services.mozilla.com/D34479 --HG-- extra : moz-landing-system : lando --- dom/media/webaudio/AudioWorkletNode.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dom/media/webaudio/AudioWorkletNode.cpp b/dom/media/webaudio/AudioWorkletNode.cpp index 33dcf3bca1df..ddda44189dac 100644 --- a/dom/media/webaudio/AudioWorkletNode.cpp +++ b/dom/media/webaudio/AudioWorkletNode.cpp @@ -80,6 +80,27 @@ already_AddRefed AudioWorkletNode::Constructor( return nullptr; } + /** + * 7. Let optionsSerialization be the result of StructuredSerialize(options). + */ + JSContext* cx = aGlobal.Context(); + JS::Rooted optionsVal(cx); + if (NS_WARN_IF(!ToJSValue(cx, aOptions, &optionsVal))) { + aRv.NoteJSContextException(cx); + return nullptr; + } + // StructuredCloneHolder does not have a move constructor. Instead allocate + // memory so that the pointer can be passed to the rendering thread. + UniquePtr optionsSerialization = + MakeUnique( + StructuredCloneHolder::CloningSupported, + StructuredCloneHolder::TransferringNotSupported, + JS::StructuredCloneScope::SameProcessDifferentThread); + optionsSerialization->Write(cx, optionsVal, aRv); + if (NS_WARN_IF(aRv.Failed())) { + return nullptr; + } + return audioWorkletNode.forget(); }