From 848137750005e27c7afb0794a51751db3ab5e5fa Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 13 Aug 2021 13:43:46 +0530 Subject: [PATCH] fix(ext/web): use Array primordials in MessagePort (#11680) --- ext/web/13_message_port.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ext/web/13_message_port.js b/ext/web/13_message_port.js index d5014fdb94..d0d9e160e6 100644 --- a/ext/web/13_message_port.js +++ b/ext/web/13_message_port.js @@ -15,6 +15,8 @@ const { defineEventHandler } = window.__bootstrap.event; const { DOMException } = window.__bootstrap.domException; const { + ArrayPrototypeIncludes, + ArrayPrototypePush, ObjectSetPrototypeOf, Symbol, SymbolFor, @@ -117,7 +119,7 @@ ); } const { transfer } = options; - if (transfer.includes(this)) { + if (ArrayPrototypeIncludes(transfer, this)) { throw new DOMException("Can not tranfer self", "DataCloneError"); } const data = serializeJsMessageData(message, transfer); @@ -196,7 +198,7 @@ switch (transferable.kind) { case "messagePort": { const port = createMessagePort(transferable.data); - transferables.push(port); + ArrayPrototypePush(transferables, port); break; } default: @@ -238,7 +240,10 @@ ); } transferable[_id] = null; - serializedTransferables.push({ kind: "messagePort", data: id }); + ArrayPrototypePush(serializedTransferables, { + kind: "messagePort", + data: id, + }); } else { throw new DOMException("Value not transferable", "DataCloneError"); }