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:
FranklinDM 2023-04-07 12:04:38 +08:00 committed by roytam1
commit 47147d58b0
24 changed files with 118 additions and 129 deletions

View file

@ -8886,29 +8886,22 @@ nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
}
void
nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
nsGlobalWindow::PostMessageMoz(JSContext* aCx,
JS::Handle<JS::Value> aMessage,
const nsAString& aTargetOrigin,
const Sequence<JS::Value>& aTransfer,
const Sequence<JSObject*>& aTransfer,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aError)
ErrorResult& aRv)
{
JS::Rooted<JS::Value> transferArray(aCx, JS::UndefinedValue());
if (!aTransfer.IsEmpty()) {
// The input sequence only comes from the generated bindings code, which
// ensures it is rooted.
JS::HandleValueArray elements =
JS::HandleValueArray::fromMarkedLocation(aTransfer.Length(),
aTransfer.Elements());
transferArray = JS::ObjectOrNullValue(JS_NewArrayObject(aCx, elements));
if (transferArray.isNull()) {
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
aRv = nsContentUtils::CreateJSValueFromSequenceOfObject(aCx, aTransfer,
&transferArray);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
PostMessageMoz(aCx, aMessage, aTargetOrigin, transferArray,
aSubjectPrincipal, aError);
aSubjectPrincipal, aRv);
}
class nsCloseEvent : public Runnable {