mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 08:48:39 +09:00
Issue #2197 - Part 1b: Transferables should be arrays of objects
Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1336020
This commit is contained in:
parent
438cdbd913
commit
47147d58b0
24 changed files with 118 additions and 129 deletions
|
|
@ -3006,13 +3006,12 @@ WorkerPrivateParent<Derived>::ForgetMainThreadObjects(
|
|||
|
||||
template <class Derived>
|
||||
void
|
||||
WorkerPrivateParent<Derived>::PostMessageInternal(
|
||||
JSContext* aCx,
|
||||
JS::Handle<JS::Value> aMessage,
|
||||
const Sequence<JS::Value>& aTransferable,
|
||||
UniquePtr<ServiceWorkerClientInfo>&& aClientInfo,
|
||||
PromiseNativeHandler* aHandler,
|
||||
ErrorResult& aRv)
|
||||
WorkerPrivateParent<Derived>::PostMessageInternal(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aMessage,
|
||||
const Sequence<JSObject*>& aTransferable,
|
||||
UniquePtr<ServiceWorkerClientInfo>&& aClientInfo,
|
||||
PromiseNativeHandler* aHandler,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
AssertIsOnParentThread();
|
||||
|
||||
|
|
@ -3024,20 +3023,11 @@ WorkerPrivateParent<Derived>::PostMessageInternal(
|
|||
}
|
||||
|
||||
JS::Rooted<JS::Value> transferable(aCx, JS::UndefinedValue());
|
||||
if (!aTransferable.IsEmpty()) {
|
||||
// The input sequence only comes from the generated bindings code, which
|
||||
// ensures it is rooted.
|
||||
JS::HandleValueArray elements =
|
||||
JS::HandleValueArray::fromMarkedLocation(aTransferable.Length(),
|
||||
aTransferable.Elements());
|
||||
|
||||
JSObject* array =
|
||||
JS_NewArrayObject(aCx, elements);
|
||||
if (!array) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
transferable.setObject(*array);
|
||||
aRv = nsContentUtils::CreateJSValueFromSequenceOfObject(aCx,
|
||||
aTransferable,
|
||||
&transferable);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<MessageEventRunnable> runnable =
|
||||
|
|
@ -3083,7 +3073,7 @@ void
|
|||
WorkerPrivateParent<Derived>::PostMessage(
|
||||
JSContext* aCx,
|
||||
JS::Handle<JS::Value> aMessage,
|
||||
const Sequence<JS::Value>& aTransferable,
|
||||
const Sequence<JSObject*>& aTransferable,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
PostMessageInternal(aCx, aMessage, aTransferable, nullptr, nullptr, aRv);
|
||||
|
|
@ -3094,7 +3084,7 @@ void
|
|||
WorkerPrivateParent<Derived>::PostMessageToServiceWorker(
|
||||
JSContext* aCx,
|
||||
JS::Handle<JS::Value> aMessage,
|
||||
const Sequence<JS::Value>& aTransferable,
|
||||
const Sequence<JSObject*>& aTransferable,
|
||||
UniquePtr<ServiceWorkerClientInfo>&& aClientInfo,
|
||||
PromiseNativeHandler* aHandler,
|
||||
ErrorResult& aRv)
|
||||
|
|
@ -5677,25 +5667,17 @@ void
|
|||
WorkerPrivate::PostMessageToParentInternal(
|
||||
JSContext* aCx,
|
||||
JS::Handle<JS::Value> aMessage,
|
||||
const Sequence<JS::Value>& aTransferable,
|
||||
const Sequence<JSObject*>& aTransferable,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
JS::Rooted<JS::Value> transferable(aCx, JS::UndefinedValue());
|
||||
if (!aTransferable.IsEmpty()) {
|
||||
// The input sequence only comes from the generated bindings code, which
|
||||
// ensures it is rooted.
|
||||
JS::HandleValueArray elements =
|
||||
JS::HandleValueArray::fromMarkedLocation(aTransferable.Length(),
|
||||
aTransferable.Elements());
|
||||
|
||||
JSObject* array = JS_NewArrayObject(aCx, elements);
|
||||
if (!array) {
|
||||
aRv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
transferable.setObject(*array);
|
||||
aRv = nsContentUtils::CreateJSValueFromSequenceOfObject(aCx,
|
||||
aTransferable,
|
||||
&transferable);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<MessageEventRunnable> runnable =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue