[execution] Pass microtask queue from Context to MicrotasksScope

With a unique microtask queue possibly per context we need to pass
the microtask queue for the MicrotasksScope otherwise the default one
for the isolate will be used.

BUG=chromium:961186

Change-Id: Ib085f08e20185c69760aeea335d673d9c4c72999
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3950216
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83803}
This commit is contained in:
Dave Tapuska 2022-10-13 10:59:47 -04:00 committed by V8 LUCI CQ
parent c437ecdf21
commit 2f0384871f
18 changed files with 69 additions and 59 deletions

View File

@ -118,7 +118,12 @@ class V8_EXPORT V8_NODISCARD MicrotasksScope {
public:
enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
V8_DEPRECATE_SOON(
"May be incorrect if context was created with non-default microtask "
"queue")
MicrotasksScope(Isolate* isolate, Type type);
MicrotasksScope(Local<Context> context, Type type);
MicrotasksScope(Isolate* isolate, MicrotaskQueue* microtask_queue, Type type);
~MicrotasksScope();

View File

@ -9721,6 +9721,11 @@ MicrotasksScope::MicrotasksScope(Isolate* v8_isolate,
MicrotasksScope::Type type)
: MicrotasksScope(v8_isolate, nullptr, type) {}
MicrotasksScope::MicrotasksScope(Local<Context> v8_context,
MicrotasksScope::Type type)
: MicrotasksScope(v8_context->GetIsolate(), v8_context->GetMicrotaskQueue(),
type) {}
MicrotasksScope::MicrotasksScope(Isolate* v8_isolate,
MicrotaskQueue* microtask_queue,
MicrotasksScope::Type type)

View File

@ -6085,9 +6085,9 @@ class DefaultWasmAsyncResolvePromiseTask : public v8::Task {
void Run() override {
v8::HandleScope scope(isolate_);
MicrotasksScope microtasks_scope(isolate_,
MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Context> context = context_.Get(isolate_);
MicrotasksScope microtasks_scope(context,
MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Promise::Resolver> resolver = resolver_.Get(isolate_);
v8::Local<v8::Value> result = result_.Get(isolate_);

View File

@ -260,7 +260,7 @@ void generateCustomPreview(int sessionId, const String16& groupName,
}
v8::Isolate* isolate = context->GetIsolate();
v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope microtasksScope(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::TryCatch tryCatch(isolate);

View File

@ -713,7 +713,7 @@ void InjectedScript::addPromiseCallback(
return;
}
v8::MicrotasksScope microtasksScope(m_context->isolate(),
v8::MicrotasksScope microtasksScope(m_context->context(),
v8::MicrotasksScope::kRunMicrotasks);
ProtocolPromiseHandler::add(session, m_context->context(),
value.ToLocalChecked(), m_context->contextId(),

View File

@ -824,7 +824,7 @@ void V8Console::installAsyncStackTaggingAPI(v8::Local<v8::Context> context,
v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::External> data = v8::External::New(isolate, this);
v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope microtasksScope(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
createBoundFunctionProperty(context, console, data, "createTask",
@ -834,7 +834,7 @@ void V8Console::installAsyncStackTaggingAPI(v8::Local<v8::Context> context,
v8::Local<v8::Object> V8Console::createCommandLineAPI(
v8::Local<v8::Context> context, int sessionId) {
v8::Isolate* isolate = context->GetIsolate();
v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope microtasksScope(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Object> commandLineAPI = v8::Object::New(isolate);
@ -933,7 +933,7 @@ void V8Console::CommandLineAPIScope::accessorGetterCallback(
if (isCommandLineAPIGetter(
toProtocolStringWithTypeCheck(info.GetIsolate(), name))) {
DCHECK(value->IsFunction());
v8::MicrotasksScope microtasks(info.GetIsolate(),
v8::MicrotasksScope microtasks(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
if (value.As<v8::Function>()
->Call(context, commandLineAPI, 0, nullptr)
@ -964,7 +964,7 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope(
m_commandLineAPI(commandLineAPI),
m_global(global),
m_installedMethods(v8::Set::New(context->GetIsolate())) {
v8::MicrotasksScope microtasksScope(context->GetIsolate(),
v8::MicrotasksScope microtasksScope(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Array> names;
if (!m_commandLineAPI->GetOwnPropertyNames(context).ToLocal(&names)) return;
@ -996,7 +996,7 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope(
V8Console::CommandLineAPIScope::~CommandLineAPIScope() {
auto isolate = m_context->GetIsolate();
if (isolate->IsExecutionTerminating()) return;
v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope microtasksScope(m_context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
*static_cast<CommandLineAPIScope**>(
m_thisReference->GetBackingStore()->Data()) = nullptr;

View File

@ -793,7 +793,7 @@ Response V8DebuggerAgentImpl::getPossibleBreakpoints(
return Response::ServerError("Cannot retrive script context");
}
v8::Context::Scope contextScope(inspected->context());
v8::MicrotasksScope microtasks(m_isolate,
v8::MicrotasksScope microtasks(inspected->context(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::TryCatch tryCatch(m_isolate);
it->second->getPossibleBreakpoints(

View File

@ -818,7 +818,7 @@ v8::Local<v8::Array> V8Debugger::queryObjects(v8::Local<v8::Context> context,
MatchPrototypePredicate predicate(m_inspector, context, prototype);
v8::debug::QueryObjects(context, &predicate, &v8_objects);
v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope microtasksScope(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Array> resultArray = v8::Array::New(
m_inspector->isolate(), static_cast<int>(v8_objects.size()));

View File

@ -97,7 +97,7 @@ v8::MaybeLocal<v8::Value> V8InspectorImpl::compileAndRunInternalScript(
if (!v8::debug::CompileInspectorScript(m_isolate, source)
.ToLocal(&unboundScript))
return v8::MaybeLocal<v8::Value>();
v8::MicrotasksScope microtasksScope(m_isolate,
v8::MicrotasksScope microtasksScope(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Context::Scope contextScope(context);
v8::Isolate::SafeForTerminationScope allowTermination(m_isolate);
@ -533,7 +533,7 @@ V8InspectorImpl::getAssociatedExceptionDataForProtocol(
if (!exceptionMetaDataContext().ToLocal(&context)) return nullptr;
v8::TryCatch tryCatch(m_isolate);
v8::MicrotasksScope microtasksScope(m_isolate,
v8::MicrotasksScope microtasksScope(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Context::Scope contextScope(context);
std::unique_ptr<protocol::DictionaryValue> jsonObject;

View File

@ -63,7 +63,7 @@ int V8Regex::match(const String16& string, int startFrom,
return -1;
}
v8::Context::Scope contextScope(context);
v8::MicrotasksScope microtasks(isolate,
v8::MicrotasksScope microtasks(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::TryCatch tryCatch(isolate);

View File

@ -152,7 +152,7 @@ void innerCallFunctionOn(
if (inspector
->compileScript(scope.context(), "(" + expression + ")", String16())
.ToLocal(&functionScript)) {
v8::MicrotasksScope microtasksScope(inspector->isolate(),
v8::MicrotasksScope microtasksScope(scope.context(),
v8::MicrotasksScope::kRunMicrotasks);
maybeFunctionValue = functionScript->Run(scope.context());
}
@ -181,7 +181,7 @@ void innerCallFunctionOn(
v8::MaybeLocal<v8::Value> maybeResultValue;
{
v8::MicrotasksScope microtasksScope(inspector->isolate(),
v8::MicrotasksScope microtasksScope(scope.context(),
v8::MicrotasksScope::kRunMicrotasks);
maybeResultValue = v8::debug::CallFunctionOn(
scope.context(), functionValue.As<v8::Function>(), recv, argc,
@ -299,7 +299,7 @@ void V8RuntimeAgentImpl::evaluate(
return;
}
}
v8::MicrotasksScope microtasksScope(m_inspector->isolate(),
v8::MicrotasksScope microtasksScope(scope.context(),
v8::MicrotasksScope::kRunMicrotasks);
v8::debug::EvaluateGlobalMode mode =
v8::debug::EvaluateGlobalMode::kDefault;
@ -447,7 +447,7 @@ Response V8RuntimeAgentImpl::getProperties(
if (!response.IsSuccess()) return response;
scope.ignoreExceptionsAndMuteConsole();
v8::MicrotasksScope microtasks_scope(m_inspector->isolate(),
v8::MicrotasksScope microtasks_scope(scope.context(),
v8::MicrotasksScope::kRunMicrotasks);
if (!scope.object()->IsObject())
return Response::ServerError("Value with given id is not an object");
@ -620,7 +620,7 @@ void V8RuntimeAgentImpl::runScript(
v8::MaybeLocal<v8::Value> maybeResultValue;
{
v8::MicrotasksScope microtasksScope(m_inspector->isolate(),
v8::MicrotasksScope microtasksScope(scope.context(),
v8::MicrotasksScope::kRunMicrotasks);
maybeResultValue = script->Run(scope.context());
}
@ -799,7 +799,7 @@ void V8RuntimeAgentImpl::addBinding(InspectedContext* context,
v8::Local<v8::Object> global = localContext->Global();
v8::Local<v8::String> v8Name = toV8String(m_inspector->isolate(), name);
v8::Local<v8::Value> functionValue;
v8::MicrotasksScope microtasks(m_inspector->isolate(),
v8::MicrotasksScope microtasks(localContext,
v8::MicrotasksScope::kDoNotRunMicrotasks);
if (v8::Function::New(localContext, bindingCallback, v8Name)
.ToLocal(&functionValue)) {

View File

@ -819,7 +819,7 @@ bool isArrayLike(v8::Local<v8::Context> context, v8::Local<v8::Value> value,
if (!value->IsObject()) return false;
v8::Isolate* isolate = context->GetIsolate();
v8::TryCatch tryCatch(isolate);
v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope microtasksScope(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Object> object = value.As<v8::Object>();
v8::Local<v8::Value> spliceValue;
@ -1362,7 +1362,7 @@ bool ValueMirror::getProperties(v8::Local<v8::Context> context,
v8::TryCatch tryCatch(isolate);
v8::Local<v8::Set> set = v8::Set::New(isolate);
v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope microtasksScope(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
V8InternalValueType internalType = v8InternalValueTypeFrom(context, object);
if (internalType == V8InternalValueType::kScope) {
@ -1510,7 +1510,7 @@ void ValueMirror::getInternalProperties(
v8::Local<v8::Context> context, v8::Local<v8::Object> object,
std::vector<InternalPropertyMirror>* mirrors) {
v8::Isolate* isolate = context->GetIsolate();
v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope microtasksScope(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::TryCatch tryCatch(isolate);
if (object->IsFunction()) {
@ -1565,7 +1565,7 @@ std::vector<PrivatePropertyMirror> ValueMirror::getPrivateProperties(
bool accessorPropertiesOnly) {
std::vector<PrivatePropertyMirror> mirrors;
v8::Isolate* isolate = context->GetIsolate();
v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope microtasksScope(context,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::TryCatch tryCatch(isolate);
v8::Local<v8::Array> privateProperties;

View File

@ -19790,7 +19790,7 @@ TEST(CallCompletedCallbackTwoExceptions) {
static void MicrotaskOne(const v8::FunctionCallbackInfo<Value>& info) {
CHECK(v8::MicrotasksScope::IsRunningMicrotasks(info.GetIsolate()));
v8::HandleScope scope(info.GetIsolate());
v8::MicrotasksScope microtasks(info.GetIsolate(),
v8::MicrotasksScope microtasks(info.GetIsolate()->GetCurrentContext(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
CompileRun("ext1Calls++;");
}
@ -19799,7 +19799,7 @@ static void MicrotaskOne(const v8::FunctionCallbackInfo<Value>& info) {
static void MicrotaskTwo(const v8::FunctionCallbackInfo<Value>& info) {
CHECK(v8::MicrotasksScope::IsRunningMicrotasks(info.GetIsolate()));
v8::HandleScope scope(info.GetIsolate());
v8::MicrotasksScope microtasks(info.GetIsolate(),
v8::MicrotasksScope microtasks(info.GetIsolate()->GetCurrentContext(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
CompileRun("ext2Calls++;");
}
@ -20101,31 +20101,31 @@ TEST(ScopedMicrotasks) {
v8::HandleScope handles(env->GetIsolate());
env->GetIsolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped);
{
v8::MicrotasksScope scope1(env->GetIsolate(),
v8::MicrotasksScope scope1(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
env->GetIsolate()->EnqueueMicrotask(
Function::New(env.local(), MicrotaskOne).ToLocalChecked());
CompileRun("var ext1Calls = 0;");
}
{
v8::MicrotasksScope scope1(env->GetIsolate(),
v8::MicrotasksScope scope1(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
ExpectInt32("ext1Calls", 1);
}
{
v8::MicrotasksScope scope1(env->GetIsolate(),
v8::MicrotasksScope scope1(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
env->GetIsolate()->EnqueueMicrotask(
Function::New(env.local(), MicrotaskOne).ToLocalChecked());
CompileRun("throw new Error()");
}
{
v8::MicrotasksScope scope1(env->GetIsolate(),
v8::MicrotasksScope scope1(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
ExpectInt32("ext1Calls", 2);
}
{
v8::MicrotasksScope scope1(env->GetIsolate(),
v8::MicrotasksScope scope1(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
env->GetIsolate()->EnqueueMicrotask(
Function::New(env.local(), MicrotaskOne).ToLocalChecked());
@ -20133,18 +20133,18 @@ TEST(ScopedMicrotasks) {
CompileRun("throw new Error()");
}
{
v8::MicrotasksScope scope1(env->GetIsolate(),
v8::MicrotasksScope scope1(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
ExpectInt32("ext1Calls", 3);
}
{
v8::MicrotasksScope scope1(env->GetIsolate(),
v8::MicrotasksScope scope1(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
env->GetIsolate()->EnqueueMicrotask(
Function::New(env.local(), MicrotaskOne).ToLocalChecked());
env->GetIsolate()->TerminateExecution();
{
v8::MicrotasksScope scope2(env->GetIsolate(),
v8::MicrotasksScope scope2(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
env->GetIsolate()->EnqueueMicrotask(
Function::New(env.local(), MicrotaskOne).ToLocalChecked());
@ -20152,21 +20152,21 @@ TEST(ScopedMicrotasks) {
}
env->GetIsolate()->CancelTerminateExecution();
{
v8::MicrotasksScope scope1(env->GetIsolate(),
v8::MicrotasksScope scope1(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
ExpectInt32("ext1Calls", 3);
env->GetIsolate()->EnqueueMicrotask(
Function::New(env.local(), MicrotaskOne).ToLocalChecked());
}
{
v8::MicrotasksScope scope1(env->GetIsolate(),
v8::MicrotasksScope scope1(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
ExpectInt32("ext1Calls", 4);
}
{
v8::MicrotasksScope scope1(env->GetIsolate(),
v8::MicrotasksScope scope1(env.local(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
env->GetIsolate()->EnqueueMicrotask(
Function::New(env.local(), MicrotaskOne).ToLocalChecked());
@ -20177,13 +20177,13 @@ TEST(ScopedMicrotasks) {
CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
{
v8::MicrotasksScope scope2(env->GetIsolate(),
v8::MicrotasksScope scope2(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
CompileRun("1+1;");
CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
{
v8::MicrotasksScope scope3(env->GetIsolate(),
v8::MicrotasksScope scope3(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
CompileRun("1+1;");
CHECK_EQ(0,
@ -20201,20 +20201,20 @@ TEST(ScopedMicrotasks) {
}
{
v8::MicrotasksScope scope(env->GetIsolate(),
v8::MicrotasksScope scope(env.local(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
}
{
v8::MicrotasksScope scope1(env->GetIsolate(),
v8::MicrotasksScope scope1(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
CompileRun("1+1;");
CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
{
v8::MicrotasksScope scope2(env->GetIsolate(),
v8::MicrotasksScope scope2(env.local(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
}
CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
@ -20222,7 +20222,7 @@ TEST(ScopedMicrotasks) {
}
{
v8::MicrotasksScope scope(env->GetIsolate(),
v8::MicrotasksScope scope(env.local(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
@ -20233,17 +20233,17 @@ TEST(ScopedMicrotasks) {
{
v8::Isolate::SuppressMicrotaskExecutionScope scope1(env->GetIsolate());
{
v8::MicrotasksScope scope2(env->GetIsolate(),
v8::MicrotasksScope scope2(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
}
v8::MicrotasksScope scope3(env->GetIsolate(),
v8::MicrotasksScope scope3(env.local(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
}
{
v8::MicrotasksScope scope1(env->GetIsolate(),
v8::MicrotasksScope scope1(env.local(),
v8::MicrotasksScope::kRunMicrotasks);
v8::MicrotasksScope::PerformCheckpoint(env->GetIsolate());
CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
@ -20251,7 +20251,7 @@ TEST(ScopedMicrotasks) {
}
{
v8::MicrotasksScope scope(env->GetIsolate(),
v8::MicrotasksScope scope(env.local(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
@ -20260,7 +20260,7 @@ TEST(ScopedMicrotasks) {
v8::MicrotasksScope::PerformCheckpoint(env->GetIsolate());
{
v8::MicrotasksScope scope(env->GetIsolate(),
v8::MicrotasksScope scope(env.local(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
@ -20271,7 +20271,7 @@ TEST(ScopedMicrotasks) {
v8::MicrotasksScope::PerformCheckpoint(env->GetIsolate());
{
v8::MicrotasksScope scope(env->GetIsolate(),
v8::MicrotasksScope scope(env.local(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
@ -20282,7 +20282,7 @@ TEST(ScopedMicrotasks) {
{
v8::Isolate::SuppressMicrotaskExecutionScope scope1(env->GetIsolate());
v8::MicrotasksScope::PerformCheckpoint(env->GetIsolate());
v8::MicrotasksScope scope2(env->GetIsolate(),
v8::MicrotasksScope scope2(env.local(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
@ -20291,7 +20291,7 @@ TEST(ScopedMicrotasks) {
v8::MicrotasksScope::PerformCheckpoint(env->GetIsolate());
{
v8::MicrotasksScope scope(env->GetIsolate(),
v8::MicrotasksScope scope(env.local(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());

View File

@ -5339,7 +5339,7 @@ bool microtask_one_ran = false;
static void MicrotaskOne(const v8::FunctionCallbackInfo<v8::Value>& info) {
CHECK(v8::MicrotasksScope::IsRunningMicrotasks(info.GetIsolate()));
v8::HandleScope scope(info.GetIsolate());
v8::MicrotasksScope microtasks(info.GetIsolate(),
v8::MicrotasksScope microtasks(info.GetIsolate()->GetCurrentContext(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
ExpectInt32("1 + 1", 2);
microtask_one_ran = true;

View File

@ -55,11 +55,11 @@ class FrontendChannelImpl : public v8_inspector::V8Inspector::Channel {
private:
void Run(InspectorIsolateData* data) override {
v8::MicrotasksScope microtasks_scope(data->isolate(),
v8::MicrotasksScope::kRunMicrotasks);
v8::HandleScope handle_scope(data->isolate());
v8::Local<v8::Context> context =
data->GetDefaultContext(channel_->context_group_id_);
v8::MicrotasksScope microtasks_scope(context,
v8::MicrotasksScope::kRunMicrotasks);
v8::Context::Scope context_scope(context);
v8::Local<v8::Value> message = ToV8String(data->isolate(), message_);
v8::MaybeLocal<v8::Value> result;

View File

@ -389,7 +389,7 @@ bool InspectorIsolateData::isInspectableHeapObject(
v8::Local<v8::Object> object) {
v8::Local<v8::Context> context = isolate()->GetCurrentContext();
v8::MicrotasksScope microtasks_scope(
isolate(), v8::MicrotasksScope::kDoNotRunMicrotasks);
context, v8::MicrotasksScope::kDoNotRunMicrotasks);
return !object->HasPrivate(context, not_inspectable_private_.Get(isolate()))
.FromMaybe(false);
}

View File

@ -15,10 +15,10 @@ namespace v8 {
namespace internal {
void ExecuteStringTask::Run(InspectorIsolateData* data) {
v8::MicrotasksScope microtasks_scope(data->isolate(),
v8::MicrotasksScope::kRunMicrotasks);
v8::HandleScope handle_scope(data->isolate());
v8::Local<v8::Context> context = data->GetDefaultContext(context_group_id_);
v8::MicrotasksScope microtasks_scope(context,
v8::MicrotasksScope::kRunMicrotasks);
v8::Context::Scope context_scope(context);
v8::ScriptOrigin origin(data->isolate(), ToV8String(data->isolate(), name_),
line_offset_, column_offset_,

View File

@ -129,10 +129,10 @@ class SetTimeoutTask : public TaskRunner::Task {
private:
void Run(InspectorIsolateData* data) override {
v8::MicrotasksScope microtasks_scope(data->isolate(),
v8::MicrotasksScope::kRunMicrotasks);
v8::HandleScope handle_scope(data->isolate());
v8::Local<v8::Context> context = data->GetDefaultContext(context_group_id_);
v8::MicrotasksScope microtasks_scope(context,
v8::MicrotasksScope::kRunMicrotasks);
v8::Context::Scope context_scope(context);
v8::Local<v8::Function> function = function_.Get(data->isolate());