Commit 73fe6ba4 authored by xiaochengh's avatar xiaochengh Committed by Commit bot

Make FrameSelection::SelectAll bail if 'selectstart' detaches frame

BUG=715387
TEST=LayoutTests/editing/selection/selectstart_detaches_frame.html

Review-Url: https://codereview.chromium.org/2848993002
Cr-Commit-Position: refs/heads/master@{#468292}
parent d62951ac
<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<iframe></iframe>
<script>
iframe = document.querySelector('iframe');
iframe.contentDocument.onselectstart = () => iframe.remove();
test(() => iframe.contentDocument.execCommand('selectAll'),
'Should not crash if selectstart event handler detaches frame');
</script>
...@@ -658,6 +658,11 @@ void FrameSelection::SelectAll() { ...@@ -658,6 +658,11 @@ void FrameSelection::SelectAll() {
if (select_start_target->DispatchEvent(Event::CreateCancelableBubble( if (select_start_target->DispatchEvent(Event::CreateCancelableBubble(
EventTypeNames::selectstart)) != DispatchEventResult::kNotCanceled) EventTypeNames::selectstart)) != DispatchEventResult::kNotCanceled)
return; return;
// The frame may be detached due to selectstart event.
if (!IsAvailable()) {
// Reached by editing/selection/selectstart_detach_frame.html
return;
}
// |root| may be detached due to selectstart event. // |root| may be detached due to selectstart event.
if (!root->isConnected() || expected_document != root->GetDocument()) if (!root->isConnected() || expected_document != root->GetDocument())
return; return;
......
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