Commit cda583a7 authored by tzik's avatar tzik Committed by Commit Bot

Run correct MicrotaskQueue on MicrotasksScope instead of the default one

MicrotasksScope has accidentally ignored the given MicrotaskQueue instance
when it's scoping out. That confused the embedder to start using the non
default MicrotaskQueue.

Change-Id: Id345605cf6520cd073429b08698de75f7681d93c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1563836Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60765}
parent 1416d5a5
......@@ -8960,7 +8960,7 @@ MicrotasksScope::~MicrotasksScope() {
if (run_) {
microtask_queue_->DecrementMicrotasksScopeDepth();
if (MicrotasksPolicy::kScoped == microtask_queue_->microtasks_policy()) {
PerformCheckpoint(reinterpret_cast<Isolate*>(isolate_));
microtask_queue_->PerformCheckpoint(reinterpret_cast<Isolate*>(isolate_));
}
}
#ifdef DEBUG
......
......@@ -584,5 +584,21 @@ TEST_F(MicrotaskQueueTest, DetachGlobal_InactiveHandler) {
Object::GetElement(isolate(), result, 1).ToHandleChecked()->IsFalse());
}
TEST_F(MicrotaskQueueTest, MicrotasksScope) {
ASSERT_NE(isolate()->default_microtask_queue(), microtask_queue());
microtask_queue()->set_microtasks_policy(MicrotasksPolicy::kScoped);
bool ran = false;
{
MicrotasksScope scope(v8_isolate(), microtask_queue(),
MicrotasksScope::kRunMicrotasks);
microtask_queue()->EnqueueMicrotask(*NewMicrotask([&ran]() {
EXPECT_FALSE(ran);
ran = true;
}));
}
EXPECT_TRUE(ran);
}
} // namespace internal
} // namespace v8
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