Commit 0b65d886 authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

[Streams] Initialise binding.MessagePort_postMessage to undefined

Some worklet contexts lack MessagePort and so cannot implement
tranferable streams. This is detected by looking for the
MessagePort_postMessage function on the binding object, which is
initialised during context creation.

Previously MessagePort_postMessage was only placed on the binding object
when it was available, meaning when it was absent the prototype chain
was searched for it. Since this could be interfered with by code running
on the page, initialise it to undefined instead.

BUG=934201

Change-Id: Ic114d92300207f41a8b762457504a4d70009ee34
Reviewed-on: https://chromium-review.googlesource.com/c/1488402Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635922}
parent 97410ad5
......@@ -136,8 +136,13 @@ void AddOriginals(ScriptState* script_state, v8::Local<v8::Object> binding) {
// Most Worklets don't have MessagePort. In this case, serialization will
// fail. AudioWorklet has MessagePort but no DOMException, so it can't use
// serialization for now.
if (message_port->IsUndefined() || dom_exception->IsUndefined())
if (message_port->IsUndefined() || dom_exception->IsUndefined()) {
// Allow V8 Extras JavaScript to safely detect that MessagePort is not
// available. Without this, lookups of MessagePort_postMessage will follow
// the prototype chain.
Bind("MessagePort_postMessage", v8::Undefined(isolate));
return;
}
v8::Local<v8::Value> event_target_prototype =
GetPrototype(ObjectGet(global, "EventTarget"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment