Commit 869e3162 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

v8binding: Handle nullable DOMString return value of OnBeforeUnloadEventHandler

OnBeforeUnloadEventHandler's return type is DOMString?, so we need to
handle the case that the return value is null.  This patch fixes the
behavior in case of null.

Change-Id: I23e4b06174adb42111584f1e84f7ca1c9d04e56c
Reviewed-on: https://chromium-review.googlesource.com/c/1335750Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607984}
parent 139eccc4
...@@ -150,11 +150,12 @@ void JSEventHandler::InvokeInternal(EventTarget& event_target, ...@@ -150,11 +150,12 @@ void JSEventHandler::InvokeInternal(EventTarget& event_target,
// DOMString. // DOMString.
if (event.IsBeforeUnloadEvent() && if (event.IsBeforeUnloadEvent() &&
event.type() == event_type_names::kBeforeunload) { event.type() == event_type_names::kBeforeunload) {
DCHECK(result_for_beforeunload); if (result_for_beforeunload) {
event.preventDefault(); event.preventDefault();
BeforeUnloadEvent* before_unload_event = ToBeforeUnloadEvent(&event); BeforeUnloadEvent* before_unload_event = ToBeforeUnloadEvent(&event);
if (before_unload_event->returnValue().IsEmpty()) if (before_unload_event->returnValue().IsEmpty())
before_unload_event->setReturnValue(result_for_beforeunload); before_unload_event->setReturnValue(result_for_beforeunload);
}
} else if (!IsOnBeforeUnloadEventHandler()) { } else if (!IsOnBeforeUnloadEventHandler()) {
if (special_error_event_handling && v8_return_value->IsBoolean() && if (special_error_event_handling && v8_return_value->IsBoolean() &&
v8_return_value.As<v8::Boolean>()->Value()) v8_return_value.As<v8::Boolean>()->Value())
......
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