Issue #2197 - Part 1a: postMessages should have transferable as [] by default

Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1336020
This commit is contained in:
FranklinDM 2023-04-07 09:56:33 +08:00 committed by roytam1
commit 438cdbd913
22 changed files with 52 additions and 58 deletions

View file

@ -8888,18 +8888,17 @@ nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
void
nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const nsAString& aTargetOrigin,
const Optional<Sequence<JS::Value>>& aTransfer,
const Sequence<JS::Value>& aTransfer,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aError)
{
JS::Rooted<JS::Value> transferArray(aCx, JS::UndefinedValue());
if (aTransfer.WasPassed()) {
const Sequence<JS::Value >& values = aTransfer.Value();
if (!aTransfer.IsEmpty()) {
// The input sequence only comes from the generated bindings code, which
// ensures it is rooted.
JS::HandleValueArray elements =
JS::HandleValueArray::fromMarkedLocation(values.Length(), values.Elements());
JS::HandleValueArray::fromMarkedLocation(aTransfer.Length(),
aTransfer.Elements());
transferArray = JS::ObjectOrNullValue(JS_NewArrayObject(aCx, elements));
if (transferArray.isNull()) {