Commit e307bb3b authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Fix WebSocket crash caused by ContextDestroyed during close event

We can cause frame a detach event in a onclose handler (as in the added
layout test), and that led to an inconsistent state. This change fixes
the issue.

Bug: 788890
Change-Id: I229336d89f7c9863f7d8a9770e5410ab76dc3dc9
Reviewed-on: https://chromium-review.googlesource.com/805594Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521629}
parent 94dc6b4f
<!doctype html>
<html>
<script src = "/resources/testharness.js"></script>
<script src = "/resources/testharnessreport.js"></script>
<iframe src="resources/empty.html"></iframe>
<script>
async_test((test) => {
const iframe = document.querySelector('iframe');
iframe.addEventListener('load', () => {
const url = 'ws://127.0.0.1:8880/server-close';
const ws = new iframe.contentWindow.WebSocket(url);
ws.onclose = () => {
iframe.remove();
test.done();
};
});
}, 'Destroying the frame in the close event handler should not lead to crash.');
</script>
</html>
...@@ -755,8 +755,9 @@ void DOMWebSocket::DidClose( ...@@ -755,8 +755,9 @@ void DOMWebSocket::DidClose(
code != WebSocketChannel::kCloseEventCodeAbnormalClosure; code != WebSocketChannel::kCloseEventCodeAbnormalClosure;
state_ = kClosed; state_ = kClosed;
event_queue_->Dispatch(CloseEvent::Create(was_clean, code, reason));
ReleaseChannel(); ReleaseChannel();
event_queue_->Dispatch(CloseEvent::Create(was_clean, code, reason));
} }
void DOMWebSocket::RecordSendTypeHistogram(WebSocketSendType type) { void DOMWebSocket::RecordSendTypeHistogram(WebSocketSendType type) {
......
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