diff options
author | FranklinDM <mrmineshafter17@gmail.com> | 2023-04-07 21:45:15 +0800 |
---|---|---|
committer | FranklinDM <mrmineshafter17@gmail.com> | 2023-04-07 23:41:57 +0800 |
commit | c660c6f699d69dbf5adaaa833b78ce9a57affeff (patch) | |
tree | 41583f4082725a76d6cf1607853cbd08d51fa6f1 /dom/base/nsGlobalWindow.cpp | |
parent | 84af6181e707073baff354c2ddc763570c39cb92 (diff) | |
download | uxp-c660c6f699d69dbf5adaaa833b78ce9a57affeff.tar.gz |
Issue #2197 - Part 4: Expose structuredClone in Sandbox
Partially based on https://bugzilla.mozilla.org/show_bug.cgi?id=1734320
Diffstat (limited to 'dom/base/nsGlobalWindow.cpp')
-rw-r--r-- | dom/base/nsGlobalWindow.cpp | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 8a5d62dabd..9d5ae7a8d7 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -190,7 +190,6 @@ #include "mozilla/dom/IDBFactory.h" #include "mozilla/dom/MessageChannel.h" #include "mozilla/dom/Promise.h" -#include "mozilla/dom/MessagePort.h" #ifdef MOZ_GAMEPAD #include "mozilla/dom/Gamepad.h" @@ -14636,40 +14635,10 @@ void nsGlobalWindow::StructuredClone(JSContext* aCx, JS::Handle<JS::Value> aValue, const StructuredSerializeOptions& aOptions, - JS::MutableHandle<JS::Value> aRetval, + JS::MutableHandle<JS::Value> aRv, ErrorResult& aError) { - JS::Rooted<JS::Value> transferArray(aCx, JS::UndefinedValue()); - aError = nsContentUtils::CreateJSValueFromSequenceOfObject( - aCx, aOptions.mTransfer, &transferArray); - if (NS_WARN_IF(aError.Failed())) { - return; - } - - // FIXME: Uncomment once bug 1609990 and bug 1611855 lands. - //JS::CloneDataPolicy clonePolicy; - //clonePolicy.allowIntraClusterClonableSharedObjects(); - //clonePolicy.allowSharedMemoryObjects(); - - StructuredCloneHolder holder(StructuredCloneHolder::CloningSupported, - StructuredCloneHolder::TransferringSupported, - JS::StructuredCloneScope::SameProcessDifferentThread); - holder.Write(aCx, aValue, transferArray, clonePolicy, aError); - if (NS_WARN_IF(aError.Failed())) { - return; - } - - // TODO: Stop casting to nsISupports once bug 1585284 lands. - nsISupports* windowAsSupports = static_cast<nsIGlobalObject*>(this); - // TODO: Pass clonePolicy. - //holder.Read(this, aCx, aRetval, clonePolicy, aError); - holder.Read(windowAsSupports, aCx, aRetval, aError); - if (NS_WARN_IF(aError.Failed())) { - return; - } - - nsTArray<RefPtr<MessagePort>> ports = holder.TakeTransferredPorts(); - Unused << ports; + nsContentUtils::StructuredClone(aCx, this, aValue, aOptions, aRv, aError); } // Helper called by methods that move/resize the window, |