Commit 9a56b451 authored by Johnny(Jianning) Ding's avatar Johnny(Jianning) Ding Committed by Commit Bot

Add script setting check in IsCallbackFunctionRunnable.

The incumbent realm schedules the currently-running callback although
it may not correspond to the currently-running function object.
The goal for this CL to is check whether the script setting is disabled
before invoking JS callback, then checking the context which originally
schedules the current-running callback seems to make more sense.

Please notice that this CL changes the behavior of the method
IsCallbackFunctionRunnable to require the execution context of the
incumbent environment to be not empty, not paused and enabled for
JavaScript.

Bug: 849600,849601,849730,848086,849915,851357
Change-Id: Id8ab0f9f67f9602635b295b414d2d0026c87e4ab
Reviewed-on: https://chromium-review.googlesource.com/1087536
Commit-Queue: Johnny Ding <jnd@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568799}
parent 6f413cc6
Tests mutation observer invocation. Tests mutation observer invocation.
Count: 2. Count: 1.
Count: 2.
(async function(testRunner) { (async function(testRunner) {
var {page, session, dp} = var {page, session, dp} =
await testRunner.startHTML(` await testRunner.startBlank('Tests mutation observer invocation.');
<body><script>
count = 0;
var observer = new MutationObserver(() => {count++;});
observer.observe(document.body, {childList: true});
</script></body>
`, 'Tests mutation observer invocation.');
async function triggerMutation() {
await session.evaluate(`document.body.appendChild(document.createTextNode('ha'))`);
let result = await session.evaluate(`count`);
testRunner.log(`Count: ${result}.`);
}
await triggerMutation(); await dp.Runtime.enable();
await dp.Emulation.setScriptExecutionDisabled({value: true}); let promise = page.navigate('../resources/mutation-observer-triggered-by-parser.html')
await triggerMutation();
await dp.Runtime.onceConsoleAPICalled();
await Promise.all([
dp.Emulation.setScriptExecutionDisabled({value: true}),
dp.Runtime.terminateExecution(),
promise
]);
let result = await session.evaluate(`count`);
testRunner.log(`Count: ${result}.`);
testRunner.completeTest(); testRunner.completeTest();
}) })
<!DOCTYPE html>
<html>
<body>
<script>
count = 0;
let observer = new MutationObserver(() => { count++; if (count==1) { console.log(42); while(true){} } });
observer.observe(document.body, {childList: true});
</script>
<b>0</b><b>1</b><b>2</b><b>3</b><b>4</b><b>5</b><b>6</b><b>7</b><b>8</b><b>9</b>
<b>0</b><b>1</b><b>2</b><b>3</b><b>4</b><b>5</b><b>6</b><b>7</b><b>8</b><b>9</b>
<b>0</b><b>1</b><b>2</b><b>3</b><b>4</b><b>5</b><b>6</b><b>7</b><b>8</b><b>9</b>
<b>0</b><b>1</b><b>2</b><b>3</b><b>4</b><b>5</b><b>6</b><b>7</b><b>8</b><b>9</b>
<b>0</b><b>1</b><b>2</b><b>3</b><b>4</b><b>5</b><b>6</b><b>7</b><b>8</b><b>9</b>
<b>0</b><b>1</b><b>2</b><b>3</b><b>4</b><b>5</b><b>6</b><b>7</b><b>8</b><b>9</b>
<script>
// Remove this script block to prevent parser from yeilding, so the parsing work can be done in one task, then the mutation observer handler just runs once.
</script>
</body>
</html>
...@@ -32,13 +32,35 @@ v8::Local<v8::Value> V8Deserialize(v8::Isolate* isolate, ...@@ -32,13 +32,35 @@ v8::Local<v8::Value> V8Deserialize(v8::Isolate* isolate,
} }
bool IsCallbackFunctionRunnable( bool IsCallbackFunctionRunnable(
const ScriptState* callback_relevant_script_state) { const ScriptState* callback_relevant_script_state,
ScriptState* incumbent_script_state) {
if (!callback_relevant_script_state->ContextIsValid()) if (!callback_relevant_script_state->ContextIsValid())
return false; return false;
const ExecutionContext* execution_context = const ExecutionContext* relevant_execution_context =
ExecutionContext::From(callback_relevant_script_state); ExecutionContext::From(callback_relevant_script_state);
return execution_context && !execution_context->IsContextPaused() && if (!relevant_execution_context ||
!execution_context->IsContextDestroyed(); relevant_execution_context->IsContextPaused() ||
relevant_execution_context->IsContextDestroyed()) {
return false;
}
// TODO(yukishiino): Callback function type value must make the incumbent
// environment alive, i.e. the reference to v8::Context must be strong.
v8::HandleScope handle_scope(incumbent_script_state->GetIsolate());
v8::Local<v8::Context> incumbent_context =
incumbent_script_state->GetContext();
ExecutionContext* incumbent_execution_context =
incumbent_context.IsEmpty() ? nullptr
: ToExecutionContext(incumbent_context);
// The incumbent realm schedules the currently-running callback although it
// may not correspond to the currently-running function object. So we check
// the incumbent context which originally schedules the currently-running
// callback to see whether the script setting is disabled before invoking
// the callback.
return incumbent_execution_context &&
!incumbent_execution_context->IsContextPaused() &&
!incumbent_execution_context->IsContextDestroyed() &&
incumbent_execution_context->CanExecuteScripts(kAboutToExecuteScript);
} }
} // namespace blink } // namespace blink
...@@ -61,7 +61,8 @@ class CORE_EXPORT ExceptionToRejectPromiseScope { ...@@ -61,7 +61,8 @@ 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);
using InstallTemplateFunction = using InstallTemplateFunction =
void (*)(v8::Isolate* isolate, void (*)(v8::Isolate* isolate,
......
...@@ -24,7 +24,8 @@ v8::Maybe<{{return_cpp_type}}> {{cpp_class}}::Invoke({{argument_declarations | j ...@@ -24,7 +24,8 @@ v8::Maybe<{{return_cpp_type}}> {{cpp_class}}::Invoke({{argument_declarations | j
promise type, in which case this function needs to convert any exception promise type, in which case this function needs to convert any exception
into a rejected promise. See also step 14.4. to 14.6. #} into a rejected promise. See also step 14.4. to 14.6. #}
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -55,17 +56,6 @@ v8::Maybe<{{return_cpp_type}}> {{cpp_class}}::Invoke({{argument_declarations | j ...@@ -55,17 +56,6 @@ v8::Maybe<{{return_cpp_type}}> {{cpp_class}}::Invoke({{argument_declarations | j
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 9. Prepare to run a callback with stored settings. // step 9. Prepare to run a callback with stored settings.
{# TODO(yukishiino): Callback function type value must make the incumbent
environment alive, i.e. the reference to v8::Context must be strong. #}
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"invoke",
"{{callback_function_name}}",
"The provided callback is no longer runnable."));
return v8::Nothing<{{return_cpp_type}}>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -73,7 +73,8 @@ v8::Maybe<{{method.cpp_type}}> {{v8_class}}::{{method.name}}({{method.argument_d ...@@ -73,7 +73,8 @@ v8::Maybe<{{method.cpp_type}}> {{v8_class}}::{{method.name}}({{method.argument_d
// This function implements "call a user object's operation". // This function implements "call a user object's operation".
// https://heycam.github.io/webidl/#call-a-user-objects-operation // https://heycam.github.io/webidl/#call-a-user-objects-operation
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -93,17 +94,6 @@ v8::Maybe<{{method.cpp_type}}> {{v8_class}}::{{method.name}}({{method.argument_d ...@@ -93,17 +94,6 @@ v8::Maybe<{{method.cpp_type}}> {{v8_class}}::{{method.name}}({{method.argument_d
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 8. Prepare to run a callback with stored settings. // step 8. Prepare to run a callback with stored settings.
{# TODO(yukishiino): Callback interface type value must make the incumbent
environment alive, i.e. the reference to v8::Context must be strong. #}
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"{{method.name}}",
"{{cpp_class}}",
"The provided callback is no longer runnable."));
return v8::Nothing<{{method.cpp_type}}>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -31,7 +31,8 @@ v8::Maybe<ScriptValue> V8AnyCallbackFunctionOptionalAnyArg::Invoke(ScriptWrappab ...@@ -31,7 +31,8 @@ v8::Maybe<ScriptValue> V8AnyCallbackFunctionOptionalAnyArg::Invoke(ScriptWrappab
// "3.10. Invoking callback functions". // "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions // https://heycam.github.io/webidl/#es-invoking-callback-functions
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -62,15 +63,6 @@ v8::Maybe<ScriptValue> V8AnyCallbackFunctionOptionalAnyArg::Invoke(ScriptWrappab ...@@ -62,15 +63,6 @@ v8::Maybe<ScriptValue> V8AnyCallbackFunctionOptionalAnyArg::Invoke(ScriptWrappab
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 9. Prepare to run a callback with stored settings. // step 9. Prepare to run a callback with stored settings.
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"invoke",
"AnyCallbackFunctionOptionalAnyArg",
"The provided callback is no longer runnable."));
return v8::Nothing<ScriptValue>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -31,7 +31,8 @@ v8::Maybe<int32_t> V8LongCallbackFunction::Invoke(ScriptWrappable* callback_this ...@@ -31,7 +31,8 @@ v8::Maybe<int32_t> V8LongCallbackFunction::Invoke(ScriptWrappable* callback_this
// "3.10. Invoking callback functions". // "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions // https://heycam.github.io/webidl/#es-invoking-callback-functions
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -62,15 +63,6 @@ v8::Maybe<int32_t> V8LongCallbackFunction::Invoke(ScriptWrappable* callback_this ...@@ -62,15 +63,6 @@ v8::Maybe<int32_t> V8LongCallbackFunction::Invoke(ScriptWrappable* callback_this
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 9. Prepare to run a callback with stored settings. // step 9. Prepare to run a callback with stored settings.
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"invoke",
"LongCallbackFunction",
"The provided callback is no longer runnable."));
return v8::Nothing<int32_t>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -31,7 +31,8 @@ v8::Maybe<Vector<String>> V8StringSequenceCallbackFunctionLongSequenceArg::Invok ...@@ -31,7 +31,8 @@ v8::Maybe<Vector<String>> V8StringSequenceCallbackFunctionLongSequenceArg::Invok
// "3.10. Invoking callback functions". // "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions // https://heycam.github.io/webidl/#es-invoking-callback-functions
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -62,15 +63,6 @@ v8::Maybe<Vector<String>> V8StringSequenceCallbackFunctionLongSequenceArg::Invok ...@@ -62,15 +63,6 @@ v8::Maybe<Vector<String>> V8StringSequenceCallbackFunctionLongSequenceArg::Invok
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 9. Prepare to run a callback with stored settings. // step 9. Prepare to run a callback with stored settings.
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"invoke",
"StringSequenceCallbackFunctionLongSequenceArg",
"The provided callback is no longer runnable."));
return v8::Nothing<Vector<String>>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -85,7 +85,8 @@ v8::Maybe<uint16_t> V8TestLegacyCallbackInterface::acceptNode(ScriptWrappable* c ...@@ -85,7 +85,8 @@ v8::Maybe<uint16_t> V8TestLegacyCallbackInterface::acceptNode(ScriptWrappable* c
// This function implements "call a user object's operation". // This function implements "call a user object's operation".
// https://heycam.github.io/webidl/#call-a-user-objects-operation // https://heycam.github.io/webidl/#call-a-user-objects-operation
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -105,15 +106,6 @@ v8::Maybe<uint16_t> V8TestLegacyCallbackInterface::acceptNode(ScriptWrappable* c ...@@ -105,15 +106,6 @@ v8::Maybe<uint16_t> V8TestLegacyCallbackInterface::acceptNode(ScriptWrappable* c
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 8. Prepare to run a callback with stored settings. // step 8. Prepare to run a callback with stored settings.
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"acceptNode",
"TestLegacyCallbackInterface",
"The provided callback is no longer runnable."));
return v8::Nothing<uint16_t>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -30,7 +30,8 @@ v8::Maybe<void> V8VoidCallbackFunction::Invoke(ScriptWrappable* callback_this_va ...@@ -30,7 +30,8 @@ v8::Maybe<void> V8VoidCallbackFunction::Invoke(ScriptWrappable* callback_this_va
// "3.10. Invoking callback functions". // "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions // https://heycam.github.io/webidl/#es-invoking-callback-functions
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -61,15 +62,6 @@ v8::Maybe<void> V8VoidCallbackFunction::Invoke(ScriptWrappable* callback_this_va ...@@ -61,15 +62,6 @@ v8::Maybe<void> V8VoidCallbackFunction::Invoke(ScriptWrappable* callback_this_va
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 9. Prepare to run a callback with stored settings. // step 9. Prepare to run a callback with stored settings.
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"invoke",
"VoidCallbackFunction",
"The provided callback is no longer runnable."));
return v8::Nothing<void>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -31,7 +31,8 @@ v8::Maybe<void> V8VoidCallbackFunctionDictionaryArg::Invoke(ScriptWrappable* cal ...@@ -31,7 +31,8 @@ v8::Maybe<void> V8VoidCallbackFunctionDictionaryArg::Invoke(ScriptWrappable* cal
// "3.10. Invoking callback functions". // "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions // https://heycam.github.io/webidl/#es-invoking-callback-functions
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -62,15 +63,6 @@ v8::Maybe<void> V8VoidCallbackFunctionDictionaryArg::Invoke(ScriptWrappable* cal ...@@ -62,15 +63,6 @@ v8::Maybe<void> V8VoidCallbackFunctionDictionaryArg::Invoke(ScriptWrappable* cal
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 9. Prepare to run a callback with stored settings. // step 9. Prepare to run a callback with stored settings.
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"invoke",
"VoidCallbackFunctionDictionaryArg",
"The provided callback is no longer runnable."));
return v8::Nothing<void>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -31,7 +31,8 @@ v8::Maybe<void> V8VoidCallbackFunctionEnumArg::Invoke(ScriptWrappable* callback_ ...@@ -31,7 +31,8 @@ v8::Maybe<void> V8VoidCallbackFunctionEnumArg::Invoke(ScriptWrappable* callback_
// "3.10. Invoking callback functions". // "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions // https://heycam.github.io/webidl/#es-invoking-callback-functions
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -62,15 +63,6 @@ v8::Maybe<void> V8VoidCallbackFunctionEnumArg::Invoke(ScriptWrappable* callback_ ...@@ -62,15 +63,6 @@ v8::Maybe<void> V8VoidCallbackFunctionEnumArg::Invoke(ScriptWrappable* callback_
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 9. Prepare to run a callback with stored settings. // step 9. Prepare to run a callback with stored settings.
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"invoke",
"VoidCallbackFunctionEnumArg",
"The provided callback is no longer runnable."));
return v8::Nothing<void>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -31,7 +31,8 @@ v8::Maybe<void> V8VoidCallbackFunctionInterfaceArg::Invoke(ScriptWrappable* call ...@@ -31,7 +31,8 @@ v8::Maybe<void> V8VoidCallbackFunctionInterfaceArg::Invoke(ScriptWrappable* call
// "3.10. Invoking callback functions". // "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions // https://heycam.github.io/webidl/#es-invoking-callback-functions
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -62,15 +63,6 @@ v8::Maybe<void> V8VoidCallbackFunctionInterfaceArg::Invoke(ScriptWrappable* call ...@@ -62,15 +63,6 @@ v8::Maybe<void> V8VoidCallbackFunctionInterfaceArg::Invoke(ScriptWrappable* call
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 9. Prepare to run a callback with stored settings. // step 9. Prepare to run a callback with stored settings.
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"invoke",
"VoidCallbackFunctionInterfaceArg",
"The provided callback is no longer runnable."));
return v8::Nothing<void>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -32,7 +32,8 @@ v8::Maybe<void> V8VoidCallbackFunctionTestInterfaceSequenceArg::Invoke(ScriptWra ...@@ -32,7 +32,8 @@ v8::Maybe<void> V8VoidCallbackFunctionTestInterfaceSequenceArg::Invoke(ScriptWra
// "3.10. Invoking callback functions". // "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions // https://heycam.github.io/webidl/#es-invoking-callback-functions
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -63,15 +64,6 @@ v8::Maybe<void> V8VoidCallbackFunctionTestInterfaceSequenceArg::Invoke(ScriptWra ...@@ -63,15 +64,6 @@ v8::Maybe<void> V8VoidCallbackFunctionTestInterfaceSequenceArg::Invoke(ScriptWra
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 9. Prepare to run a callback with stored settings. // step 9. Prepare to run a callback with stored settings.
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"invoke",
"VoidCallbackFunctionTestInterfaceSequenceArg",
"The provided callback is no longer runnable."));
return v8::Nothing<void>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -31,7 +31,8 @@ v8::Maybe<void> V8VoidCallbackFunctionTypedef::Invoke(ScriptWrappable* callback_ ...@@ -31,7 +31,8 @@ v8::Maybe<void> V8VoidCallbackFunctionTypedef::Invoke(ScriptWrappable* callback_
// "3.10. Invoking callback functions". // "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions // https://heycam.github.io/webidl/#es-invoking-callback-functions
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -62,15 +63,6 @@ v8::Maybe<void> V8VoidCallbackFunctionTypedef::Invoke(ScriptWrappable* callback_ ...@@ -62,15 +63,6 @@ v8::Maybe<void> V8VoidCallbackFunctionTypedef::Invoke(ScriptWrappable* callback_
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 9. Prepare to run a callback with stored settings. // step 9. Prepare to run a callback with stored settings.
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"invoke",
"VoidCallbackFunctionTypedef",
"The provided callback is no longer runnable."));
return v8::Nothing<void>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -30,7 +30,8 @@ v8::Maybe<void> V8VoidCallbackFunctionModules::Invoke(ScriptWrappable* callback_ ...@@ -30,7 +30,8 @@ v8::Maybe<void> V8VoidCallbackFunctionModules::Invoke(ScriptWrappable* callback_
// "3.10. Invoking callback functions". // "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions // https://heycam.github.io/webidl/#es-invoking-callback-functions
if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState(),
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.
...@@ -61,15 +62,6 @@ v8::Maybe<void> V8VoidCallbackFunctionModules::Invoke(ScriptWrappable* callback_ ...@@ -61,15 +62,6 @@ v8::Maybe<void> V8VoidCallbackFunctionModules::Invoke(ScriptWrappable* callback_
ScriptState::Scope callback_relevant_context_scope( ScriptState::Scope callback_relevant_context_scope(
CallbackRelevantScriptState()); CallbackRelevantScriptState());
// step 9. Prepare to run a callback with stored settings. // step 9. Prepare to run a callback with stored settings.
if (IncumbentScriptState()->GetContext().IsEmpty()) {
V8ThrowException::ThrowError(
GetIsolate(),
ExceptionMessages::FailedToExecute(
"invoke",
"VoidCallbackFunctionModules",
"The provided callback is no longer runnable."));
return v8::Nothing<void>();
}
v8::Context::BackupIncumbentScope backup_incumbent_scope( v8::Context::BackupIncumbentScope backup_incumbent_scope(
IncumbentScriptState()->GetContext()); IncumbentScriptState()->GetContext());
......
...@@ -287,13 +287,8 @@ HeapHashSet<Member<Node>> MutationObserver::GetObservedNodes() const { ...@@ -287,13 +287,8 @@ HeapHashSet<Member<Node>> MutationObserver::GetObservedNodes() const {
} }
bool MutationObserver::ShouldBeSuspended() const { bool MutationObserver::ShouldBeSuspended() const {
ExecutionContext* execution_context = delegate_->GetExecutionContext(); const ExecutionContext* execution_context = delegate_->GetExecutionContext();
if (!execution_context) return execution_context && execution_context->IsContextPaused();
return false;
Document* document = ToDocument(execution_context);
DCHECK(document);
return !document->CanExecuteScripts(kAboutToExecuteScript) ||
execution_context->IsContextPaused();
} }
void MutationObserver::CancelInspectorAsyncTasks() { void MutationObserver::CancelInspectorAsyncTasks() {
......
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