Commit 1a602b7b authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

v8binding: Invoke 'beforeunload' event listeners even when paused

This patch fixes a regression at https://crrev.com/c/1215512 ,
which doesn't run 'beforeunload' event listeners when one of the
related execution contexts is paused.

This patch adds an exceptional handling for 'beforeunload' event
so that 'beforeunload' event listeners run regardless of pause.

Bug: 903297
Change-Id: I92bb24a8fd16ee9f81a5082f5c561c97c1dd5348
Reviewed-on: https://chromium-review.googlesource.com/c/1333548
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609217}
parent d3f0bde5
...@@ -32,18 +32,28 @@ v8::Local<v8::Value> V8Deserialize(v8::Isolate* isolate, ...@@ -32,18 +32,28 @@ v8::Local<v8::Value> V8Deserialize(v8::Isolate* isolate,
return v8::Null(isolate); return v8::Null(isolate);
} }
bool IsCallbackFunctionRunnable( namespace {
enum class IgnorePause { kDontIgnore, kIgnore };
// 'beforeunload' event listeners are runnable even when execution contexts are
// paused. Use |RespectPause::kPrioritizeOverPause| in such a case.
bool IsCallbackFunctionRunnableInternal(
const ScriptState* callback_relevant_script_state, const ScriptState* callback_relevant_script_state,
ScriptState* incumbent_script_state) { const ScriptState* incumbent_script_state,
IgnorePause ignore_pause) {
if (!callback_relevant_script_state->ContextIsValid()) if (!callback_relevant_script_state->ContextIsValid())
return false; return false;
const ExecutionContext* relevant_execution_context = const ExecutionContext* relevant_execution_context =
ExecutionContext::From(callback_relevant_script_state); ExecutionContext::From(callback_relevant_script_state);
if (!relevant_execution_context || if (!relevant_execution_context ||
relevant_execution_context->IsContextPaused() ||
relevant_execution_context->IsContextDestroyed()) { relevant_execution_context->IsContextDestroyed()) {
return false; return false;
} }
if (relevant_execution_context->IsContextPaused()) {
if (ignore_pause == IgnorePause::kDontIgnore)
return false;
}
// TODO(yukishiino): Callback function type value must make the incumbent // TODO(yukishiino): Callback function type value must make the incumbent
// environment alive, i.e. the reference to v8::Context must be strong. // environment alive, i.e. the reference to v8::Context must be strong.
...@@ -60,12 +70,34 @@ bool IsCallbackFunctionRunnable( ...@@ -60,12 +70,34 @@ bool IsCallbackFunctionRunnable(
// the callback. // the callback.
// TODO(crbug.com/608641): move IsMainWorld check into // TODO(crbug.com/608641): move IsMainWorld check into
// ExecutionContext::CanExecuteScripts() // ExecutionContext::CanExecuteScripts()
return incumbent_execution_context && if (!incumbent_execution_context ||
!incumbent_execution_context->IsContextPaused() && incumbent_execution_context->IsContextDestroyed()) {
!incumbent_execution_context->IsContextDestroyed() && return false;
(!incumbent_script_state->World().IsMainWorld() || }
incumbent_execution_context->CanExecuteScripts( if (incumbent_execution_context->IsContextPaused()) {
kAboutToExecuteScript)); if (ignore_pause == IgnorePause::kDontIgnore)
return false;
}
return !incumbent_script_state->World().IsMainWorld() ||
incumbent_execution_context->CanExecuteScripts(kAboutToExecuteScript);
}
} // namespace
bool IsCallbackFunctionRunnable(
const ScriptState* callback_relevant_script_state,
const ScriptState* incumbent_script_state) {
return IsCallbackFunctionRunnableInternal(callback_relevant_script_state,
incumbent_script_state,
IgnorePause::kDontIgnore);
}
bool IsCallbackFunctionRunnableIgnoringPause(
const ScriptState* callback_relevant_script_state,
const ScriptState* incumbent_script_state) {
return IsCallbackFunctionRunnableInternal(callback_relevant_script_state,
incumbent_script_state,
IgnorePause::kIgnore);
} }
} // namespace blink } // namespace blink
...@@ -36,7 +36,7 @@ CORE_EXPORT v8::Local<v8::Value> V8Deserialize(v8::Isolate*, ...@@ -36,7 +36,7 @@ CORE_EXPORT v8::Local<v8::Value> V8Deserialize(v8::Isolate*,
// Promise-returning DOM operations are required to always return a promise // Promise-returning DOM operations are required to always return a promise
// and to never throw an exception. // and to never throw an exception.
// See also http://heycam.github.io/webidl/#es-operations // See also http://heycam.github.io/webidl/#es-operations
class CORE_EXPORT ExceptionToRejectPromiseScope { class CORE_EXPORT ExceptionToRejectPromiseScope final {
STACK_ALLOCATED(); STACK_ALLOCATED();
public: public:
...@@ -62,7 +62,11 @@ class CORE_EXPORT ExceptionToRejectPromiseScope { ...@@ -62,7 +62,11 @@ class CORE_EXPORT ExceptionToRejectPromiseScope {
CORE_EXPORT bool IsCallbackFunctionRunnable( CORE_EXPORT bool IsCallbackFunctionRunnable(
const ScriptState* callback_relevant_script_state, const ScriptState* callback_relevant_script_state,
ScriptState* incumbent_script_state); const ScriptState* incumbent_script_state);
CORE_EXPORT bool IsCallbackFunctionRunnableIgnoringPause(
const ScriptState* callback_relevant_script_state,
const ScriptState* incumbent_script_state);
using InstallTemplateFunction = using InstallTemplateFunction =
void (*)(v8::Isolate* isolate, void (*)(v8::Isolate* isolate,
......
...@@ -103,8 +103,19 @@ void JSEventHandler::InvokeInternal(EventTarget& event_target, ...@@ -103,8 +103,19 @@ void JSEventHandler::InvokeInternal(EventTarget& event_target,
arguments = {ScriptValue::From(script_state_of_listener, js_event)}; arguments = {ScriptValue::From(script_state_of_listener, js_event)};
} }
const bool is_beforeunload_event =
event.IsBeforeUnloadEvent() &&
event.type() == event_type_names::kBeforeunload;
if (!event_handler_->IsRunnableOrThrowException(
is_beforeunload_event
? V8EventHandlerNonNull::IgnorePause::kIgnore
: V8EventHandlerNonNull::IgnorePause::kDontIgnore)) {
return;
}
ScriptValue result; ScriptValue result;
if (!event_handler_->Invoke(event.currentTarget(), arguments).To(&result) || if (!event_handler_
->InvokeWithoutRunnabilityCheck(event.currentTarget(), arguments)
.To(&result) ||
GetIsolate()->IsExecutionTerminating()) GetIsolate()->IsExecutionTerminating())
return; return;
v8::Local<v8::Value> v8_return_value = result.V8Value(); v8::Local<v8::Value> v8_return_value = result.V8Value();
...@@ -148,8 +159,7 @@ void JSEventHandler::InvokeInternal(EventTarget& event_target, ...@@ -148,8 +159,7 @@ void JSEventHandler::InvokeInternal(EventTarget& event_target,
// then return value will never be false, since in such cases // then return value will never be false, since in such cases
// return value will have been coerced into either null or a // return value will have been coerced into either null or a
// DOMString. // DOMString.
if (event.IsBeforeUnloadEvent() && if (is_beforeunload_event) {
event.type() == event_type_names::kBeforeunload) {
if (result_for_beforeunload) { if (result_for_beforeunload) {
event.preventDefault(); event.preventDefault();
BeforeUnloadEvent* before_unload_event = ToBeforeUnloadEvent(&event); BeforeUnloadEvent* before_unload_event = ToBeforeUnloadEvent(&event);
......
...@@ -47,8 +47,16 @@ void JSEventListener::InvokeInternal(EventTarget&, ...@@ -47,8 +47,16 @@ void JSEventListener::InvokeInternal(EventTarget&,
v8::Local<v8::Value> js_event) { v8::Local<v8::Value> js_event) {
// Step 10: Call a listener with event's currentTarget as receiver and event // Step 10: Call a listener with event's currentTarget as receiver and event
// and handle errors if thrown. // and handle errors if thrown.
v8::Maybe<void> maybe_result = const bool is_beforeunload_event =
event_listener_->handleEvent(event.currentTarget(), &event); event.IsBeforeUnloadEvent() &&
event.type() == event_type_names::kBeforeunload;
if (!event_listener_->IsRunnableOrThrowException(
is_beforeunload_event ? V8EventListener::IgnorePause::kIgnore
: V8EventListener::IgnorePause::kDontIgnore)) {
return;
}
v8::Maybe<void> maybe_result = event_listener_->InvokeWithoutRunnabilityCheck(
event.currentTarget(), &event);
ALLOW_UNUSED_LOCAL(maybe_result); ALLOW_UNUSED_LOCAL(maybe_result);
} }
......
...@@ -19,7 +19,7 @@ v8::Maybe<{{return_cpp_type}}> {{cpp_class}}::Invoke({{argument_declarations | j ...@@ -19,7 +19,7 @@ v8::Maybe<{{return_cpp_type}}> {{cpp_class}}::Invoke({{argument_declarations | j
{{callback_invoke( {{callback_invoke(
'callback function', 'invoke', 'callback function', 'invoke',
return_cpp_type, native_value_traits_tag, arguments, return_cpp_type, native_value_traits_tag, arguments,
is_treat_non_object_as_null, is_treat_non_object_as_null, False,
callback_function_name, 'invoke')}} callback_function_name, 'invoke')}}
} }
...@@ -28,7 +28,7 @@ v8::Maybe<{{return_cpp_type}}> {{cpp_class}}::Construct({{argument_declarations[ ...@@ -28,7 +28,7 @@ v8::Maybe<{{return_cpp_type}}> {{cpp_class}}::Construct({{argument_declarations[
{{callback_invoke( {{callback_invoke(
'callback function', 'construct', 'callback function', 'construct',
return_cpp_type, native_value_traits_tag, arguments, return_cpp_type, native_value_traits_tag, arguments,
is_treat_non_object_as_null, is_treat_non_object_as_null, False,
callback_function_name, 'construct')}} callback_function_name, 'construct')}}
} }
{% endif %} {% endif %}
...@@ -49,6 +49,42 @@ void {{cpp_class}}::InvokeAndReportException({{argument_declarations | join(', ' ...@@ -49,6 +49,42 @@ void {{cpp_class}}::InvokeAndReportException({{argument_declarations | join(', '
} }
{% endif %} {% endif %}
{% if callback_function_name == 'EventHandlerNonNull' %}
bool {{cpp_class}}::IsRunnableOrThrowException(IgnorePause ignore_pause) {
bool is_runnable =
ignore_pause == IgnorePause::kIgnore ?
IsCallbackFunctionRunnableIgnoringPause(
CallbackRelevantScriptState(), IncumbentScriptState()) :
IsCallbackFunctionRunnable(
CallbackRelevantScriptState(), IncumbentScriptState());
if (is_runnable)
return true;
// Wrapper-tracing for the callback function makes the function object and
// its creation context alive. Thus it's safe to use the creation context
// of the callback function here.
v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"invoke",
"{{callback_function_name}}",
"The provided callback is no longer runnable."));
return false;
}
v8::Maybe<{{return_cpp_type}}> {{cpp_class}}::InvokeWithoutRunnabilityCheck({{argument_declarations | join(', ')}}) {
{{callback_invoke(
'callback function', 'invoke',
return_cpp_type, native_value_traits_tag, arguments,
is_treat_non_object_as_null, True,
callback_function_name, 'invoke')}}
}
{% endif %}
v8::Maybe<{{return_cpp_type}}> V8PersistentCallbackFunction<{{cpp_class}}>::Invoke({{argument_declarations | join(', ')}}) { v8::Maybe<{{return_cpp_type}}> V8PersistentCallbackFunction<{{cpp_class}}>::Invoke({{argument_declarations | join(', ')}}) {
return Proxy()->Invoke( return Proxy()->Invoke(
{{ {{
......
...@@ -51,6 +51,20 @@ class {{exported}}{{cpp_class}} final : public CallbackFunctionBase { ...@@ -51,6 +51,20 @@ class {{exported}}{{cpp_class}} final : public CallbackFunctionBase {
// error handler such as DevTools' console. // error handler such as DevTools' console.
void InvokeAndReportException({{argument_declarations | join(', ')}}); void InvokeAndReportException({{argument_declarations | join(', ')}});
{% endif %} {% endif %}
{% if callback_function_name == 'EventHandlerNonNull' %}
// Returns true if the callback is runnable, otherwise returns false and
// throws an exception. 'beforeunload' event need to have priority over pause
// of execution contexts.
enum class IgnorePause { kDontIgnore, kIgnore };
bool IsRunnableOrThrowException(IgnorePause);
// Performs "invoke" without checking the runnability check, which must be
// done prior to this call by |IsRunnableOrThrowException|.
// https://heycam.github.io/webidl/#es-invoking-callback-functions
// This function may throw unlike InvokeAndReportException.
v8::Maybe<{{return_cpp_type}}> InvokeWithoutRunnabilityCheck({{argument_declarations | join(', ')}}) WARN_UNUSED_RESULT;
{% endif %}
}; };
template <> template <>
......
...@@ -88,7 +88,7 @@ v8::Maybe<{{method.cpp_type}}> {{v8_class}}::{{method.name}}({{method.argument_d ...@@ -88,7 +88,7 @@ v8::Maybe<{{method.cpp_type}}> {{v8_class}}::{{method.name}}({{method.argument_d
{{callback_invoke( {{callback_invoke(
'callback interface', None, 'callback interface', None,
method.cpp_type, method.native_value_traits_tag, method.arguments, method.cpp_type, method.native_value_traits_tag, method.arguments,
False, False, False,
interface_name, method.name)}} interface_name, method.name)}}
} }
...@@ -110,6 +110,42 @@ void {{v8_class}}::InvokeAndReportException({{methods[0].argument_declarations | ...@@ -110,6 +110,42 @@ void {{v8_class}}::InvokeAndReportException({{methods[0].argument_declarations |
} }
{% endif %} {% endif %}
{% if interface_name == 'EventListener' %}
bool {{v8_class}}::IsRunnableOrThrowException(IgnorePause ignore_pause) {
bool is_runnable =
ignore_pause == IgnorePause::kIgnore ?
IsCallbackFunctionRunnableIgnoringPause(
CallbackRelevantScriptState(), IncumbentScriptState()) :
IsCallbackFunctionRunnable(
CallbackRelevantScriptState(), IncumbentScriptState());
if (is_runnable)
return true;
// Wrapper-tracing for the callback function makes the function object and
// its creation context alive. Thus it's safe to use the creation context
// of the callback function here.
v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"{{methods[0].name}}",
"{{interface_name}}",
"The provided callback is no longer runnable."));
return false;
}
v8::Maybe<{{methods[0].cpp_type}}> {{v8_class}}::InvokeWithoutRunnabilityCheck({{methods[0].argument_declarations | join(', ')}}) {
{{callback_invoke(
'callback interface', None,
methods[0].cpp_type, methods[0].native_value_traits_tag, methods[0].arguments,
False, True,
interface_name, methods[0].name)}}
}
{% endif %}
{% for method in methods %} {% for method in methods %}
v8::Maybe<{{method.cpp_type}}> V8PersistentCallbackInterface<{{v8_class}}>::{{method.name}}({{method.argument_declarations | join(', ')}}) { v8::Maybe<{{method.cpp_type}}> V8PersistentCallbackInterface<{{v8_class}}>::{{method.name}}({{method.argument_declarations | join(', ')}}) {
return Proxy()->{{method.name}}( return Proxy()->{{method.name}}(
......
...@@ -57,6 +57,21 @@ class {{exported}}{{v8_class}} final : public CallbackInterfaceBase { ...@@ -57,6 +57,21 @@ class {{exported}}{{v8_class}} final : public CallbackInterfaceBase {
// if any, to the global error handler such as DevTools' console. // if any, to the global error handler such as DevTools' console.
void InvokeAndReportException({{methods[0].argument_declarations | join(', ')}}); void InvokeAndReportException({{methods[0].argument_declarations | join(', ')}});
{% endif %} {% endif %}
{% if interface_name == 'EventListener' %}
// Returns true if the callback is runnable, otherwise returns false and
// throws an exception. 'beforeunload' event need to have priority over pause
// of execution contexts.
enum class IgnorePause { kDontIgnore, kIgnore };
bool IsRunnableOrThrowException(IgnorePause);
// Performs "call a user object's operation" for '{{methods[0].name}}' without
// checking the runnability check, which must be done prior to this call by
// |IsRunnableOrThrowException|.
// https://heycam.github.io/webidl/#call-a-user-objects-operation
// This function may throw unlike InvokeAndReportException.
v8::Maybe<{{methods[0].cpp_type}}> InvokeWithoutRunnabilityCheck({{methods[0].argument_declarations | join(', ')}}) WARN_UNUSED_RESULT;
{% endif %}
}; };
template <> template <>
......
...@@ -12,25 +12,23 @@ ...@@ -12,25 +12,23 @@
return_native_value_traits_tag = tag of NativeValueTraits for return type return_native_value_traits_tag = tag of NativeValueTraits for return type
arguments = dict of arguments\' info arguments = dict of arguments\' info
is_treat_non_object_as_null = True if [TreatNonObjectAsNull] is_treat_non_object_as_null = True if [TreatNonObjectAsNull]
bypass_runnability_check = Skip IsCallbackFunctionRunnable check if True
interface_name = interface name used for exception interface_name = interface name used for exception
operation_name = interface name used for exception and property lookup operation_name = interface name used for exception and property lookup
#} #}
{% macro callback_invoke( {% macro callback_invoke(
interface_or_function, invoke_or_construct, interface_or_function, invoke_or_construct,
return_cpp_type, return_native_value_traits_tag, arguments, return_cpp_type, return_native_value_traits_tag, arguments,
is_treat_non_object_as_null, is_treat_non_object_as_null, bypass_runnability_check,
interface_name, operation_name) %} interface_name, operation_name) %}
{% if not bypass_runnability_check %}
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(), if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
IncumbentScriptState())) { IncumbentScriptState())) {
// Wrapper-tracing for the callback function makes the function object and // Wrapper-tracing for the callback function makes the function object and
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
{% if interface_or_function == 'callback function' %}
v8::Local<v8::Object> callback_object = CallbackFunction();
{% else %}
v8::Local<v8::Object> callback_object = CallbackObject(); v8::Local<v8::Object> callback_object = CallbackObject();
{% endif %}
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
...@@ -41,6 +39,7 @@ ...@@ -41,6 +39,7 @@
"The provided callback is no longer runnable.")); "The provided callback is no longer runnable."));
return v8::Nothing<{{return_cpp_type}}>(); return v8::Nothing<{{return_cpp_type}}>();
} }
{% endif %}
// step: Prepare to run script with relevant settings. // step: Prepare to run script with relevant settings.
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
......
...@@ -34,7 +34,7 @@ v8::Maybe<ScriptValue> V8AnyCallbackFunctionOptionalAnyArg::Invoke(ScriptWrappab ...@@ -34,7 +34,7 @@ v8::Maybe<ScriptValue> V8AnyCallbackFunctionOptionalAnyArg::Invoke(ScriptWrappab
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
...@@ -114,7 +114,7 @@ v8::Maybe<ScriptValue> V8AnyCallbackFunctionOptionalAnyArg::Construct(ScriptValu ...@@ -114,7 +114,7 @@ v8::Maybe<ScriptValue> V8AnyCallbackFunctionOptionalAnyArg::Construct(ScriptValu
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
...@@ -34,7 +34,7 @@ v8::Maybe<ScriptValue> V8AnyCallbackFunctionVariadicAnyArgs::Invoke(ScriptWrappa ...@@ -34,7 +34,7 @@ v8::Maybe<ScriptValue> V8AnyCallbackFunctionVariadicAnyArgs::Invoke(ScriptWrappa
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
...@@ -115,7 +115,7 @@ v8::Maybe<ScriptValue> V8AnyCallbackFunctionVariadicAnyArgs::Construct(const Vec ...@@ -115,7 +115,7 @@ v8::Maybe<ScriptValue> V8AnyCallbackFunctionVariadicAnyArgs::Construct(const Vec
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
...@@ -34,7 +34,7 @@ v8::Maybe<int32_t> V8LongCallbackFunction::Invoke(ScriptWrappable* callback_this ...@@ -34,7 +34,7 @@ v8::Maybe<int32_t> V8LongCallbackFunction::Invoke(ScriptWrappable* callback_this
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
...@@ -34,7 +34,7 @@ v8::Maybe<Vector<String>> V8StringSequenceCallbackFunctionLongSequenceArg::Invok ...@@ -34,7 +34,7 @@ v8::Maybe<Vector<String>> V8StringSequenceCallbackFunctionLongSequenceArg::Invok
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
...@@ -33,7 +33,7 @@ v8::Maybe<bool> V8TreatNonObjectAsNullBooleanFunction::Invoke(ScriptWrappable* c ...@@ -33,7 +33,7 @@ v8::Maybe<bool> V8TreatNonObjectAsNullBooleanFunction::Invoke(ScriptWrappable* c
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
...@@ -33,7 +33,7 @@ v8::Maybe<void> V8TreatNonObjectAsNullVoidFunction::Invoke(ScriptWrappable* call ...@@ -33,7 +33,7 @@ v8::Maybe<void> V8TreatNonObjectAsNullVoidFunction::Invoke(ScriptWrappable* call
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
...@@ -33,7 +33,7 @@ v8::Maybe<void> V8VoidCallbackFunction::Invoke(ScriptWrappable* callback_this_va ...@@ -33,7 +33,7 @@ v8::Maybe<void> V8VoidCallbackFunction::Invoke(ScriptWrappable* callback_this_va
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
...@@ -34,7 +34,7 @@ v8::Maybe<void> V8VoidCallbackFunctionDictionaryArg::Invoke(ScriptWrappable* cal ...@@ -34,7 +34,7 @@ v8::Maybe<void> V8VoidCallbackFunctionDictionaryArg::Invoke(ScriptWrappable* cal
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
...@@ -34,7 +34,7 @@ v8::Maybe<void> V8VoidCallbackFunctionEnumArg::Invoke(ScriptWrappable* callback_ ...@@ -34,7 +34,7 @@ v8::Maybe<void> V8VoidCallbackFunctionEnumArg::Invoke(ScriptWrappable* callback_
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
...@@ -34,7 +34,7 @@ v8::Maybe<void> V8VoidCallbackFunctionInterfaceArg::Invoke(ScriptWrappable* call ...@@ -34,7 +34,7 @@ v8::Maybe<void> V8VoidCallbackFunctionInterfaceArg::Invoke(ScriptWrappable* call
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
...@@ -35,7 +35,7 @@ v8::Maybe<void> V8VoidCallbackFunctionTestInterfaceSequenceArg::Invoke(ScriptWra ...@@ -35,7 +35,7 @@ v8::Maybe<void> V8VoidCallbackFunctionTestInterfaceSequenceArg::Invoke(ScriptWra
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
...@@ -34,7 +34,7 @@ v8::Maybe<void> V8VoidCallbackFunctionTypedef::Invoke(ScriptWrappable* callback_ ...@@ -34,7 +34,7 @@ v8::Maybe<void> V8VoidCallbackFunctionTypedef::Invoke(ScriptWrappable* callback_
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
...@@ -33,7 +33,7 @@ v8::Maybe<void> V8VoidCallbackFunctionModules::Invoke(ScriptWrappable* callback_ ...@@ -33,7 +33,7 @@ v8::Maybe<void> V8VoidCallbackFunctionModules::Invoke(ScriptWrappable* callback_
// its creation context alive. Thus it's safe to use the creation context // its creation context alive. Thus it's safe to use the creation context
// of the callback function here. // of the callback function here.
v8::HandleScope handle_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Object> callback_object = CallbackFunction(); v8::Local<v8::Object> callback_object = CallbackObject();
CHECK(!callback_object.IsEmpty()); CHECK(!callback_object.IsEmpty());
v8::Context::Scope context_scope(callback_object->CreationContext()); v8::Context::Scope context_scope(callback_object->CreationContext());
V8ThrowException::ThrowError( V8ThrowException::ThrowError(
......
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