Commit 2f1cdb34 authored by Hongchan Choi's avatar Hongchan Choi Committed by Commit Bot

Throw an exception when AudioWorkletNode is created on a destroyed ExecutionContext

The repro case creates an AudioWorkletNode after the ExecutionContext
goes away. (detached iframe) AudioWorkletNode is equipped with a
MessageChannel which requires a valid ExecutionContext.

AudioWorkletNode is not fully functional without message ports anyway,
so we can throw an exception in this case.

Test: Locally confirmed the ASAN build doesn't crash with the repro anymore.
Bug: 1050419
Change-Id: I52af9f877e2ad31923c6380dc0732eb6c97ab407
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2051386Reviewed-by: default avatarRaymond Toy <rtoy@chromium.org>
Commit-Queue: Hongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740754}
parent dc94dca7
......@@ -311,6 +311,13 @@ AudioWorkletNode* AudioWorkletNode::Create(
return nullptr;
}
if (context->IsContextClosed()) {
exception_state.ThrowDOMException(
DOMExceptionCode::kInvalidStateError,
"AudioWorkletNode cannot be created: No execution context available.");
return nullptr;
}
auto* channel =
MakeGarbageCollected<MessageChannel>(context->GetExecutionContext());
MessagePortChannel processor_port_channel = channel->port2()->Disentangle();
......
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