summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgozman <dgozman@chromium.org>2016-03-07 09:28:32 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-07 17:29:42 +0000
commit83013584d091473d3a5fee6a823bc63b223a472c (patch)
treeae3d35becbd58747eb42aa050c0d15b15d58e2b5
parent4b0a06a8f4c65caa3c2071e2ae00bf3252b148f7 (diff)
downloadchromium_src-83013584d091473d3a5fee6a823bc63b223a472c.zip
chromium_src-83013584d091473d3a5fee6a823bc63b223a472c.tar.gz
chromium_src-83013584d091473d3a5fee6a823bc63b223a472c.tar.bz2
Use v8::MicrotasksScope internally in V8RecursionScope.
If this sticks we can just remove V8RecursionScope and WebScopedMicrotaskSuppression, along with other cleanups. BUG=585949 Review URL: https://codereview.chromium.org/1743763004 Cr-Commit-Position: refs/heads/master@{#379574}
-rw-r--r--chrome/test/base/v8_unit_test.cc4
-rw-r--r--content/child/v8_value_converter_impl_unittest.cc8
-rw-r--r--content/renderer/pepper/v8_var_converter_unittest.cc2
-rw-r--r--extensions/renderer/activity_log_converter_strategy_unittest.cc2
-rw-r--r--extensions/renderer/api_test_base.cc2
-rw-r--r--extensions/renderer/module_system_test.cc2
-rw-r--r--extensions/renderer/safe_builtins.cc2
-rw-r--r--gin/run_microtasks_observer.cc2
-rw-r--r--gin/run_microtasks_observer.h2
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp14
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyTest.cpp18
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolverTest.cpp20
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/ScriptPromiseTest.cpp26
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp2
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp32
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.h20
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.cpp7
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h38
-rw-r--r--third_party/WebKit/Source/core/dom/Microtask.cpp8
-rw-r--r--third_party/WebKit/Source/core/streams/ReadableStreamReaderTest.cpp42
-rw-r--r--third_party/WebKit/Source/core/streams/ReadableStreamTest.cpp14
-rw-r--r--third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp4
-rw-r--r--third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp2
-rw-r--r--third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp2
24 files changed, 106 insertions, 169 deletions
diff --git a/chrome/test/base/v8_unit_test.cc b/chrome/test/base/v8_unit_test.cc
index 9f52f06..392ff45 100644
--- a/chrome/test/base/v8_unit_test.cc
+++ b/chrome/test/base/v8_unit_test.cc
@@ -11,6 +11,7 @@
#include "base/strings/stringprintf.h"
#include "chrome/common/chrome_paths.h"
#include "third_party/WebKit/public/web/WebKit.h"
+#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
namespace {
@@ -95,6 +96,7 @@ bool V8UnitTest::RunJavascriptTestF(const std::string& test_fixture,
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, context_);
v8::Context::Scope context_scope(context);
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
v8::Local<v8::Value> function_property =
context->Global()->Get(v8::String::NewFromUtf8(isolate, "runTest"));
@@ -209,6 +211,7 @@ void V8UnitTest::ExecuteScriptInContext(const base::StringPiece& script_source,
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, context_);
v8::Context::Scope context_scope(context);
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
v8::Local<v8::String> source =
v8::String::NewFromUtf8(isolate,
script_source.data(),
@@ -257,6 +260,7 @@ void V8UnitTest::TestFunction(const std::string& function_name) {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, context_);
v8::Context::Scope context_scope(context);
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
v8::Local<v8::Value> function_property = context->Global()->Get(
v8::String::NewFromUtf8(isolate, function_name.c_str()));
diff --git a/content/child/v8_value_converter_impl_unittest.cc b/content/child/v8_value_converter_impl_unittest.cc
index 311fa7f..435ea30 100644
--- a/content/child/v8_value_converter_impl_unittest.cc
+++ b/content/child/v8_value_converter_impl_unittest.cc
@@ -14,6 +14,7 @@
#include "base/values.h"
#include "content/child/v8_value_converter_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
#include "v8/include/v8.h"
namespace content {
@@ -287,6 +288,7 @@ TEST_F(V8ValueConverterImplTest, ObjectExceptions) {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
// Set up objects to throw when reading or writing 'foo'.
const char* source =
@@ -329,6 +331,7 @@ TEST_F(V8ValueConverterImplTest, ArrayExceptions) {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
const char* source = "(function() {"
"var arr = [];"
@@ -405,6 +408,7 @@ TEST_F(V8ValueConverterImplTest, Prototype) {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
const char* source = "(function() {"
"Object.prototype.foo = 'foo';"
@@ -429,6 +433,7 @@ TEST_F(V8ValueConverterImplTest, StripNullFromObjects) {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
const char* source = "(function() {"
"return { foo: undefined, bar: null };"
@@ -487,6 +492,7 @@ TEST_F(V8ValueConverterImplTest, WeirdProperties) {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
const char* source = "(function() {"
"return {"
@@ -525,6 +531,7 @@ TEST_F(V8ValueConverterImplTest, ArrayGetters) {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
const char* source = "(function() {"
"var a = [0];"
@@ -549,6 +556,7 @@ TEST_F(V8ValueConverterImplTest, UndefinedValueBehavior) {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
v8::Local<v8::Object> object;
{
diff --git a/content/renderer/pepper/v8_var_converter_unittest.cc b/content/renderer/pepper/v8_var_converter_unittest.cc
index cd07abb..e030ffd 100644
--- a/content/renderer/pepper/v8_var_converter_unittest.cc
+++ b/content/renderer/pepper/v8_var_converter_unittest.cc
@@ -29,6 +29,7 @@
#include "ppapi/shared_impl/var.h"
#include "ppapi/shared_impl/var_tracker.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
#include "v8/include/v8.h"
using ppapi::ArrayBufferVar;
@@ -403,6 +404,7 @@ TEST_F(V8VarConverterTest, StrangeDictionaryKeyTest) {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
const char* source =
"(function() {"
diff --git a/extensions/renderer/activity_log_converter_strategy_unittest.cc b/extensions/renderer/activity_log_converter_strategy_unittest.cc
index 9237cad..aa80447 100644
--- a/extensions/renderer/activity_log_converter_strategy_unittest.cc
+++ b/extensions/renderer/activity_log_converter_strategy_unittest.cc
@@ -6,6 +6,7 @@
#include "base/values.h"
#include "extensions/renderer/activity_log_converter_strategy.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
#include "v8/include/v8.h"
using content::V8ValueConverter;
@@ -122,6 +123,7 @@ TEST_F(ActivityLogConverterStrategyTest, ConversionTest) {
"};"
"})();";
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
v8::Local<v8::Script> script(
v8::Script::Compile(v8::String::NewFromUtf8(isolate_, source)));
v8::Local<v8::Object> v8_object = script->Run().As<v8::Object>();
diff --git a/extensions/renderer/api_test_base.cc b/extensions/renderer/api_test_base.cc
index abf868b..79f95e2 100644
--- a/extensions/renderer/api_test_base.cc
+++ b/extensions/renderer/api_test_base.cc
@@ -214,7 +214,7 @@ void ApiTestEnvironment::RunTestInner(const std::string& test_name,
}
void ApiTestEnvironment::RunPromisesAgain() {
- env()->isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(env()->isolate());
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&ApiTestEnvironment::RunPromisesAgain,
base::Unretained(this)));
diff --git a/extensions/renderer/module_system_test.cc b/extensions/renderer/module_system_test.cc
index 68c4bd1..06a4d55 100644
--- a/extensions/renderer/module_system_test.cc
+++ b/extensions/renderer/module_system_test.cc
@@ -253,7 +253,7 @@ void ModuleSystemTest::ExpectNoAssertionsMade() {
}
void ModuleSystemTest::RunResolvedPromises() {
- isolate_->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate_);
}
} // namespace extensions
diff --git a/extensions/renderer/safe_builtins.cc b/extensions/renderer/safe_builtins.cc
index 3bfa01a..3a66eaf 100644
--- a/extensions/renderer/safe_builtins.cc
+++ b/extensions/renderer/safe_builtins.cc
@@ -9,6 +9,7 @@
#include "base/strings/stringprintf.h"
#include "extensions/renderer/script_context.h"
#include "extensions/renderer/v8_helpers.h"
+#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
namespace extensions {
@@ -200,6 +201,7 @@ class ExtensionImpl : public v8::Extension {
return;
}
+ blink::WebScopedMicrotaskSuppression microtasks_scope;
v8::Local<v8::Value> return_value;
if (function->Call(context, recv, argc, argv.get()).ToLocal(&return_value))
info.GetReturnValue().Set(return_value);
diff --git a/gin/run_microtasks_observer.cc b/gin/run_microtasks_observer.cc
index f453a66..0ca0078 100644
--- a/gin/run_microtasks_observer.cc
+++ b/gin/run_microtasks_observer.cc
@@ -15,7 +15,7 @@ void RunMicrotasksObserver::WillProcessTask(const base::PendingTask& task) {
void RunMicrotasksObserver::DidProcessTask(const base::PendingTask& task) {
v8::Isolate::Scope scope(isolate_);
- isolate_->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate_);
}
} // namespace gin
diff --git a/gin/run_microtasks_observer.h b/gin/run_microtasks_observer.h
index 7f1431f..ca160be 100644
--- a/gin/run_microtasks_observer.h
+++ b/gin/run_microtasks_observer.h
@@ -12,7 +12,7 @@ namespace gin {
// Runs any pending v8 Microtasks each time a task is completed.
// TODO(hansmuller); At some point perhaps this can be replaced with
-// the (currently experimental) Isolate::SetAutorunMicrotasks() method.
+// the (currently experimental) v8::MicrotasksPolicy::kAuto method.
class RunMicrotasksObserver : public base::MessageLoop::TaskObserver {
public:
diff --git a/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp b/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp
index a76e6d0..49ddfe5 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp
@@ -12,6 +12,7 @@
#include "bindings/core/v8/V8BindingForTesting.h"
#include "bindings/core/v8/V8BindingMacros.h"
#include "bindings/core/v8/V8IteratorResultValue.h"
+#include "bindings/core/v8/V8RecursionScope.h"
#include "bindings/core/v8/V8ThrowException.h"
#include "core/dom/Document.h"
#include "core/streams/ReadableStreamController.h"
@@ -138,7 +139,7 @@ public:
~ReadableStreamOperationsTest() override
{
// Execute all pending microtasks
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_FALSE(m_block.HasCaught());
}
@@ -149,6 +150,7 @@ public:
{
v8::Local<v8::String> source;
v8::Local<v8::Script> script;
+ V8RecursionScope::MicrotaskSuppression microtasks(isolate());
if (!v8Call(v8::String::NewFromUtf8(isolate(), s, v8::NewStringType::kNormal), source)) {
ADD_FAILURE();
return ScriptValue();
@@ -253,12 +255,12 @@ TEST_F(ReadableStreamOperationsTest, Read)
Function::createFunction(scriptState(), it2),
NotReached::createFunction(scriptState()));
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_FALSE(it1->isSet());
EXPECT_FALSE(it2->isSet());
ASSERT_FALSE(evalWithPrintingError("controller.enqueue('hello')").isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(it1->isSet());
EXPECT_TRUE(it1->isValid());
EXPECT_FALSE(it1->isDone());
@@ -266,7 +268,7 @@ TEST_F(ReadableStreamOperationsTest, Read)
EXPECT_FALSE(it2->isSet());
ASSERT_FALSE(evalWithPrintingError("controller.close()").isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(it1->isSet());
EXPECT_TRUE(it1->isValid());
EXPECT_FALSE(it1->isDone());
@@ -309,7 +311,7 @@ TEST_F(ReadableStreamOperationsTest, CreateReadableStreamWithCustomUnderlyingSou
ReadableStreamOperations::read(scriptState(), reader).then(Function::createFunction(scriptState(), it2), NotReached::createFunction(scriptState()));
ReadableStreamOperations::read(scriptState(), reader).then(Function::createFunction(scriptState(), it3), NotReached::createFunction(scriptState()));
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(10, underlyingSource->desiredSize());
@@ -326,7 +328,7 @@ TEST_F(ReadableStreamOperationsTest, CreateReadableStreamWithCustomUnderlyingSou
EXPECT_FALSE(it3->isSet());
underlyingSource->close();
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(it3->isSet());
EXPECT_TRUE(it3->isValid());
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyTest.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyTest.cpp
index 34f2d7c..f6601dd 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyTest.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyTest.cpp
@@ -281,7 +281,7 @@ TEST_F(ScriptPromisePropertyGarbageCollectedTest, Resolve_ResolvesScriptPromise)
property()->resolve(value);
EXPECT_EQ(Property::Resolved, property()->getState());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(1u, nResolveCalls);
EXPECT_EQ(1u, nOtherResolveCalls);
EXPECT_EQ(wrap(mainWorld(), value), actual);
@@ -307,7 +307,7 @@ TEST_F(ScriptPromisePropertyGarbageCollectedTest, ResolveAndGetPromiseOnOtherWor
property()->resolve(value);
EXPECT_EQ(Property::Resolved, property()->getState());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(1u, nResolveCalls);
EXPECT_EQ(0u, nOtherResolveCalls);
@@ -316,7 +316,7 @@ TEST_F(ScriptPromisePropertyGarbageCollectedTest, ResolveAndGetPromiseOnOtherWor
otherPromise.then(stub(currentScriptState(), otherActual, nOtherResolveCalls), notReached(currentScriptState()));
}
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(1u, nResolveCalls);
EXPECT_EQ(1u, nOtherResolveCalls);
EXPECT_EQ(wrap(mainWorld(), value), actual);
@@ -343,7 +343,7 @@ TEST_F(ScriptPromisePropertyGarbageCollectedTest, Reject_RejectsScriptPromise)
property()->promise(otherWorld()).then(notReached(currentScriptState()), stub(currentScriptState(), otherActual, nOtherRejectCalls));
}
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(1u, nRejectCalls);
EXPECT_EQ(wrap(mainWorld(), reason), actual);
EXPECT_EQ(1u, nOtherRejectCalls);
@@ -374,7 +374,7 @@ TEST_F(ScriptPromisePropertyGarbageCollectedTest, Resolve_DeadContext)
property()->resolve(new GarbageCollectedScriptWrappable("value"));
EXPECT_EQ(Property::Pending, property()->getState());
- v8::Isolate::GetCurrent()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(v8::Isolate::GetCurrent());
}
TEST_F(ScriptPromisePropertyGarbageCollectedTest, Reset)
@@ -405,7 +405,7 @@ TEST_F(ScriptPromisePropertyGarbageCollectedTest, Reset)
EXPECT_EQ(0u, nOldResolveCalls);
EXPECT_EQ(0u, nNewRejectCalls);
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(1u, nOldResolveCalls);
EXPECT_EQ(1u, nNewRejectCalls);
EXPECT_NE(oldPromise, newPromise);
@@ -445,7 +445,7 @@ TEST_F(ScriptPromisePropertyRefCountedTest, Resolve)
property()->resolve(value.get());
EXPECT_EQ(Property::Resolved, property()->getState());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(1u, nResolveCalls);
EXPECT_EQ(wrap(mainWorld(), value), actual);
}
@@ -464,7 +464,7 @@ TEST_F(ScriptPromisePropertyRefCountedTest, Reject)
property()->reject(reason);
EXPECT_EQ(Property::Rejected, property()->getState());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(1u, nRejectCalls);
EXPECT_EQ(wrap(mainWorld(), reason), actual);
}
@@ -514,7 +514,7 @@ public:
property->promise(DOMWrapperWorld::mainWorld()).then(stub(currentScriptState(), actualValue, nResolveCalls), notReached(currentScriptState()));
}
property->resolve(value);
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
{
ScriptState::Scope scope(mainScriptState());
actual = toCoreString(actualValue.v8Value()->ToString(mainScriptState()->context()).ToLocalChecked());
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolverTest.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolverTest.cpp
index b6cf586..1c946d9 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolverTest.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolverTest.cpp
@@ -60,7 +60,7 @@ public:
createClosure(callback, v8::Undefined(isolate()), isolate());
// Execute all pending microtasks
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
}
OwnPtr<DummyPageHolder> m_pageHolder;
@@ -96,7 +96,7 @@ TEST_F(ScriptPromiseResolverTest, resolve)
EXPECT_EQ(String(), onFulfilled);
EXPECT_EQ(String(), onRejected);
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(String(), onFulfilled);
EXPECT_EQ(String(), onRejected);
@@ -111,14 +111,14 @@ TEST_F(ScriptPromiseResolverTest, resolve)
EXPECT_EQ(String(), onFulfilled);
EXPECT_EQ(String(), onRejected);
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ("hello", onFulfilled);
EXPECT_EQ(String(), onRejected);
resolver->resolve("bye");
resolver->reject("bye");
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ("hello", onFulfilled);
EXPECT_EQ(String(), onRejected);
@@ -144,7 +144,7 @@ TEST_F(ScriptPromiseResolverTest, reject)
EXPECT_EQ(String(), onFulfilled);
EXPECT_EQ(String(), onRejected);
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(String(), onFulfilled);
EXPECT_EQ(String(), onRejected);
@@ -159,14 +159,14 @@ TEST_F(ScriptPromiseResolverTest, reject)
EXPECT_EQ(String(), onFulfilled);
EXPECT_EQ(String(), onRejected);
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(String(), onFulfilled);
EXPECT_EQ("hello", onRejected);
resolver->resolve("bye");
resolver->reject("bye");
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(String(), onFulfilled);
EXPECT_EQ("hello", onRejected);
@@ -196,7 +196,7 @@ TEST_F(ScriptPromiseResolverTest, stop)
}
resolver->resolve("hello");
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(String(), onFulfilled);
EXPECT_EQ(String(), onRejected);
@@ -321,7 +321,7 @@ TEST_F(ScriptPromiseResolverTest, resolveVoid)
}
resolver->resolve();
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ("undefined", onFulfilled);
EXPECT_EQ(String(), onRejected);
@@ -345,7 +345,7 @@ TEST_F(ScriptPromiseResolverTest, rejectVoid)
}
resolver->reject();
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(String(), onFulfilled);
EXPECT_EQ("undefined", onRejected);
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseTest.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseTest.cpp
index 5c3fec7..01d144e 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseTest.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseTest.cpp
@@ -83,7 +83,7 @@ public:
createClosure(callback, v8::Undefined(m_scope.isolate()), m_scope.isolate());
// Execute all pending microtasks
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
}
String toString(const ScriptValue& value)
@@ -124,13 +124,13 @@ TEST_F(ScriptPromiseTest, thenResolve)
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_TRUE(onRejected.isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
resolver.resolve(v8String(isolate(), "hello"));
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_TRUE(onRejected.isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ("hello", toString(onFulfilled));
EXPECT_TRUE(onRejected.isEmpty());
@@ -148,7 +148,7 @@ TEST_F(ScriptPromiseTest, resolveThen)
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_TRUE(onRejected.isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ("hello", toString(onFulfilled));
EXPECT_TRUE(onRejected.isEmpty());
@@ -165,13 +165,13 @@ TEST_F(ScriptPromiseTest, thenReject)
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_TRUE(onRejected.isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
resolver.reject(v8String(isolate(), "hello"));
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_TRUE(onRejected.isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_EQ("hello", toString(onRejected));
@@ -189,7 +189,7 @@ TEST_F(ScriptPromiseTest, rejectThen)
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_TRUE(onRejected.isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_EQ("hello", toString(onRejected));
@@ -226,7 +226,7 @@ TEST_F(ScriptPromiseTest, castNonPromise)
EXPECT_TRUE(onRejected1.isEmpty());
EXPECT_TRUE(onRejected2.isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ("hello", toString(onFulfilled1));
EXPECT_EQ("hello", toString(onFulfilled2));
@@ -248,7 +248,7 @@ TEST_F(ScriptPromiseTest, reject)
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_TRUE(onRejected.isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_EQ("hello", toString(onRejected));
@@ -264,7 +264,7 @@ TEST_F(ScriptPromiseTest, rejectWithExceptionState)
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_TRUE(onRejected.isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_EQ("SyntaxError: some syntax error", toString(onRejected));
@@ -282,7 +282,7 @@ TEST_F(ScriptPromiseTest, allWithEmptyPromises)
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_TRUE(onRejected.isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_FALSE(onFulfilled.isEmpty());
EXPECT_TRUE(toStringArray(onFulfilled).isEmpty());
@@ -304,7 +304,7 @@ TEST_F(ScriptPromiseTest, allWithResolvedPromises)
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_TRUE(onRejected.isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_FALSE(onFulfilled.isEmpty());
Vector<String> values = toStringArray(onFulfilled);
@@ -329,7 +329,7 @@ TEST_F(ScriptPromiseTest, allWithRejectedPromise)
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_TRUE(onRejected.isEmpty());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isEmpty());
EXPECT_FALSE(onRejected.isEmpty());
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
index 04de69e..f0a8dfd 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
@@ -321,7 +321,7 @@ static void initializeV8Common(v8::Isolate* isolate)
v8::Debug::SetLiveEditEnabled(isolate, false);
- isolate->SetAutorunMicrotasks(false);
+ isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped);
}
namespace {
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp b/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp
index 0a2cfcb..65c02bc 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp
@@ -30,7 +30,6 @@
#include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8HiddenValue.h"
#include "bindings/core/v8/V8ObjectConstructor.h"
-#include "bindings/core/v8/V8RecursionScope.h"
#include "bindings/core/v8/V8ScriptRunner.h"
#include "core/frame/Deprecation.h"
#include "core/inspector/MainThreadDebugger.h"
@@ -53,18 +52,6 @@ static void microtasksCompletedCallback(v8::Isolate* isolate)
V8PerIsolateData::from(isolate)->runEndOfScopeTasks();
}
-#if ENABLE(ASSERT)
-static void assertV8RecursionScope(v8::Isolate* isolate)
-{
- ASSERT(V8RecursionScope::properlyUsed(isolate));
-}
-
-static bool runningUnitTest()
-{
- return Platform::current()->unitTestSupport();
-}
-#endif
-
static void useCounterCallback(v8::Isolate* isolate, v8::Isolate::UseCounterFeature feature)
{
UseCounter::Feature blinkFeature;
@@ -143,25 +130,15 @@ static void useCounterCallback(v8::Isolate* isolate, v8::Isolate::UseCounterFeat
}
V8PerIsolateData::V8PerIsolateData()
- : m_destructionPending(false)
- , m_isolateHolder(adoptPtr(new gin::IsolateHolder()))
+ : m_isolateHolder(adoptPtr(new gin::IsolateHolder()))
, m_stringCache(adoptPtr(new StringCache(isolate())))
, m_hiddenValue(V8HiddenValue::create())
, m_constructorMode(ConstructorMode::CreateNewObject)
- , m_recursionLevel(0)
, m_isHandlingRecursionLevelError(false)
, m_isReportingException(false)
-#if ENABLE(ASSERT)
- , m_internalScriptRecursionLevel(0)
-#endif
- , m_performingMicrotaskCheckpoint(false)
{
// FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone.
isolate()->Enter();
-#if ENABLE(ASSERT)
- if (!runningUnitTest())
- isolate()->AddCallCompletedCallback(&assertV8RecursionScope);
-#endif
isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback);
isolate()->AddMicrotasksCompletedCallback(&microtasksCompletedCallback);
if (isMainThread())
@@ -206,9 +183,6 @@ void V8PerIsolateData::willBeDestroyed(v8::Isolate* isolate)
{
V8PerIsolateData* data = from(isolate);
- ASSERT(!data->m_destructionPending);
- data->m_destructionPending = true;
-
data->m_threadDebugger.clear();
// Clear any data that may have handles into the heap,
// prior to calling ThreadState::detach().
@@ -219,10 +193,6 @@ void V8PerIsolateData::willBeDestroyed(v8::Isolate* isolate)
// gets called but before the Isolate exits.
void V8PerIsolateData::destroy(v8::Isolate* isolate)
{
-#if ENABLE(ASSERT)
- if (!runningUnitTest())
- isolate->RemoveCallCompletedCallback(&assertV8RecursionScope);
-#endif
isolate->RemoveBeforeCallEnteredCallback(&beforeCallEnteredCallback);
isolate->RemoveMicrotasksCompletedCallback(&microtasksCompletedCallback);
V8PerIsolateData* data = from(isolate);
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.h b/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.h
index 5d709e7..33ed8dc 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.h
+++ b/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.h
@@ -74,31 +74,18 @@ public:
static void enableIdleTasks(v8::Isolate*, PassOwnPtr<gin::V8IdleTaskRunner>);
- bool destructionPending() const { return m_destructionPending; }
v8::Isolate* isolate() { return m_isolateHolder->isolate(); }
StringCache* stringCache() { return m_stringCache.get(); }
v8::Persistent<v8::Value>& ensureLiveRoot();
- int recursionLevel() const { return m_recursionLevel; }
- int incrementRecursionLevel() { return ++m_recursionLevel; }
- int decrementRecursionLevel() { return --m_recursionLevel; }
bool isHandlingRecursionLevelError() const { return m_isHandlingRecursionLevelError; }
void setIsHandlingRecursionLevelError(bool value) { m_isHandlingRecursionLevelError = value; }
bool isReportingException() const { return m_isReportingException; }
void setReportingException(bool value) { m_isReportingException = value; }
- bool performingMicrotaskCheckpoint() const { return m_performingMicrotaskCheckpoint; }
- void setPerformingMicrotaskCheckpoint(bool performingMicrotaskCheckpoint) { m_performingMicrotaskCheckpoint = performingMicrotaskCheckpoint; }
-
-#if ENABLE(ASSERT)
- int internalScriptRecursionLevel() const { return m_internalScriptRecursionLevel; }
- int incrementInternalScriptRecursionLevel() { return ++m_internalScriptRecursionLevel; }
- int decrementInternalScriptRecursionLevel() { return --m_internalScriptRecursionLevel; }
-#endif
-
V8HiddenValue* hiddenValue() { return m_hiddenValue.get(); }
v8::Local<v8::FunctionTemplate> domTemplate(const void* domTemplateKey, v8::FunctionCallback = 0, v8::Local<v8::Value> data = v8::Local<v8::Value>(), v8::Local<v8::Signature> = v8::Local<v8::Signature>(), int length = 0);
@@ -131,7 +118,6 @@ private:
bool hasInstance(const WrapperTypeInfo* untrusted, v8::Local<v8::Value>, DOMTemplateMap&);
v8::Local<v8::Object> findInstanceInPrototypeChain(const WrapperTypeInfo*, v8::Local<v8::Value>, DOMTemplateMap&);
- bool m_destructionPending;
OwnPtr<gin::IsolateHolder> m_isolateHolder;
DOMTemplateMap m_domTemplateMapForMainWorld;
DOMTemplateMap m_domTemplateMapForNonMainWorld;
@@ -143,15 +129,9 @@ private:
bool m_constructorMode;
friend class ConstructorMode;
- int m_recursionLevel;
bool m_isHandlingRecursionLevelError;
bool m_isReportingException;
-#if ENABLE(ASSERT)
- int m_internalScriptRecursionLevel;
-#endif
- bool m_performingMicrotaskCheckpoint;
-
Vector<OwnPtr<EndOfScopeTask>> m_endOfScopeTasks;
OwnPtr<ThreadDebugger> m_threadDebugger;
};
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.cpp b/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.cpp
index ed10e86..b4c3acf 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.cpp
@@ -30,13 +30,6 @@
#include "bindings/core/v8/V8RecursionScope.h"
-#include "core/dom/Microtask.h"
-
namespace blink {
-void V8RecursionScope::didLeaveScriptContext()
-{
- Microtask::performCheckpoint(m_isolate);
-}
-
} // namespace blink
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h b/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h
index dd9a51f..8bbd26c 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h
+++ b/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h
@@ -59,63 +59,39 @@ class CORE_EXPORT V8RecursionScope {
STACK_ALLOCATED();
public:
explicit V8RecursionScope(v8::Isolate* isolate)
- : m_isolate(isolate)
+ : m_scope(isolate, v8::MicrotasksScope::kRunMicrotasks)
{
- V8PerIsolateData::from(m_isolate)->incrementRecursionLevel();
- // If you want V8 to autorun microtasks, this class needs to have a
- // v8::Isolate::SuppressMicrotaskExecutionScope member.
- ASSERT(!isolate->WillAutorunMicrotasks());
+ ASSERT(isolate->GetMicrotasksPolicy() == v8::MicrotasksPolicy::kScoped);
}
~V8RecursionScope()
{
- if (!V8PerIsolateData::from(m_isolate)->decrementRecursionLevel())
- didLeaveScriptContext();
}
static int recursionLevel(v8::Isolate* isolate)
{
- return V8PerIsolateData::from(isolate)->recursionLevel();
+ return v8::MicrotasksScope::GetCurrentDepth(isolate);
}
-#if ENABLE(ASSERT)
- static bool properlyUsed(v8::Isolate* isolate)
- {
- return recursionLevel(isolate) > 0 || V8PerIsolateData::from(isolate)->internalScriptRecursionLevel() > 0;
- }
-#endif
-
class MicrotaskSuppression {
USING_FAST_MALLOC(MicrotaskSuppression);
WTF_MAKE_NONCOPYABLE(MicrotaskSuppression);
public:
- MicrotaskSuppression(v8::Isolate* isolate)
-#if ENABLE(ASSERT)
- : m_isolate(isolate)
-#endif
+ explicit MicrotaskSuppression(v8::Isolate* isolate)
+ : m_scope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks)
{
-#if ENABLE(ASSERT)
- V8PerIsolateData::from(m_isolate)->incrementInternalScriptRecursionLevel();
-#endif
}
~MicrotaskSuppression()
{
-#if ENABLE(ASSERT)
- V8PerIsolateData::from(m_isolate)->decrementInternalScriptRecursionLevel();
-#endif
}
private:
-#if ENABLE(ASSERT)
- v8::Isolate* m_isolate;
-#endif
+ v8::MicrotasksScope m_scope;
};
private:
- void didLeaveScriptContext();
-
- v8::Isolate* m_isolate;
+ v8::MicrotasksScope m_scope;
};
} // namespace blink
diff --git a/third_party/WebKit/Source/core/dom/Microtask.cpp b/third_party/WebKit/Source/core/dom/Microtask.cpp
index 488c577..9e57c77 100644
--- a/third_party/WebKit/Source/core/dom/Microtask.cpp
+++ b/third_party/WebKit/Source/core/dom/Microtask.cpp
@@ -40,13 +40,9 @@ namespace blink {
void Microtask::performCheckpoint(v8::Isolate* isolate)
{
- V8PerIsolateData* isolateData = V8PerIsolateData::from(isolate);
- ASSERT(isolateData);
- if (isolateData->recursionLevel() || isolateData->performingMicrotaskCheckpoint() || isolateData->destructionPending() || ScriptForbiddenScope::isScriptForbidden())
+ if (ScriptForbiddenScope::isScriptForbidden())
return;
- isolateData->setPerformingMicrotaskCheckpoint(true);
- isolate->RunMicrotasks();
- isolateData->setPerformingMicrotaskCheckpoint(false);
+ v8::MicrotasksScope::PerformCheckpoint(isolate);
}
static void microtaskFunctionCallback(void* data)
diff --git a/third_party/WebKit/Source/core/streams/ReadableStreamReaderTest.cpp b/third_party/WebKit/Source/core/streams/ReadableStreamReaderTest.cpp
index f7e12f8..352a30f 100644
--- a/third_party/WebKit/Source/core/streams/ReadableStreamReaderTest.cpp
+++ b/third_party/WebKit/Source/core/streams/ReadableStreamReaderTest.cpp
@@ -179,7 +179,7 @@ TEST_F(ReadableStreamReaderTest, Release)
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_TRUE(onRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_EQ("AbortError: the reader is already released", onRejected);
@@ -208,7 +208,7 @@ TEST_F(ReadableStreamReaderTest, ReadAfterRelease)
EXPECT_FALSE(result.isSet);
EXPECT_TRUE(onRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_FALSE(result.isSet);
EXPECT_EQ("TypeError: the reader is already released", onRejected);
@@ -250,7 +250,7 @@ TEST_F(ReadableStreamReaderTest, EnqueueThenRead)
EXPECT_FALSE(result.isSet);
EXPECT_TRUE(onRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(result.isSet);
EXPECT_FALSE(result.isDone);
@@ -264,7 +264,7 @@ TEST_F(ReadableStreamReaderTest, EnqueueThenRead)
EXPECT_FALSE(result2.isSet);
EXPECT_TRUE(onRejected2.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(result2.isSet);
EXPECT_FALSE(result2.isDone);
@@ -290,7 +290,7 @@ TEST_F(ReadableStreamReaderTest, ReadThenEnqueue)
EXPECT_FALSE(result2.isSet);
EXPECT_TRUE(onRejected2.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_FALSE(result.isSet);
EXPECT_TRUE(onRejected.isNull());
@@ -298,7 +298,7 @@ TEST_F(ReadableStreamReaderTest, ReadThenEnqueue)
EXPECT_TRUE(onRejected2.isNull());
m_stream->enqueue("hello");
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(result.isSet);
EXPECT_FALSE(result.isDone);
@@ -308,7 +308,7 @@ TEST_F(ReadableStreamReaderTest, ReadThenEnqueue)
EXPECT_TRUE(onRejected2.isNull());
m_stream->enqueue("world");
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(result2.isSet);
EXPECT_FALSE(result2.isDone);
@@ -330,7 +330,7 @@ TEST_F(ReadableStreamReaderTest, ClosedReader)
String onClosedFulfilled, onClosedRejected;
ReadResult result;
String onReadRejected;
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
reader->closed(scriptState()).then(createCaptor(&onClosedFulfilled), createCaptor(&onClosedRejected));
reader->read(scriptState()).then(createResultCaptor(&result), createCaptor(&onReadRejected));
EXPECT_TRUE(onClosedFulfilled.isNull());
@@ -338,7 +338,7 @@ TEST_F(ReadableStreamReaderTest, ClosedReader)
EXPECT_FALSE(result.isSet);
EXPECT_TRUE(onReadRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ("undefined", onClosedFulfilled);
EXPECT_TRUE(onClosedRejected.isNull());
EXPECT_TRUE(result.isSet);
@@ -361,7 +361,7 @@ TEST_F(ReadableStreamReaderTest, ErroredReader)
String onClosedFulfilled, onClosedRejected;
String onReadFulfilled, onReadRejected;
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
reader->closed(scriptState()).then(createCaptor(&onClosedFulfilled), createCaptor(&onClosedRejected));
reader->read(scriptState()).then(createCaptor(&onReadFulfilled), createCaptor(&onReadRejected));
EXPECT_TRUE(onClosedFulfilled.isNull());
@@ -369,7 +369,7 @@ TEST_F(ReadableStreamReaderTest, ErroredReader)
EXPECT_TRUE(onReadFulfilled.isNull());
EXPECT_TRUE(onReadRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onClosedFulfilled.isNull());
EXPECT_EQ("SyntaxError: some error", onClosedRejected);
EXPECT_TRUE(onReadFulfilled.isNull());
@@ -389,7 +389,7 @@ TEST_F(ReadableStreamReaderTest, PendingReadsShouldBeResolvedWhenClosed)
reader->read(scriptState()).then(createResultCaptor(&result), createCaptor(&onRejected));
reader->read(scriptState()).then(createResultCaptor(&result2), createCaptor(&onRejected2));
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_FALSE(result.isSet);
EXPECT_TRUE(onRejected.isNull());
EXPECT_FALSE(result2.isSet);
@@ -401,7 +401,7 @@ TEST_F(ReadableStreamReaderTest, PendingReadsShouldBeResolvedWhenClosed)
EXPECT_FALSE(result2.isSet);
EXPECT_TRUE(onRejected2.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(result.isSet);
EXPECT_TRUE(result.isDone);
@@ -427,7 +427,7 @@ TEST_F(ReadableStreamReaderTest, PendingReadsShouldBeRejectedWhenErrored)
reader->read(scriptState()).then(createCaptor(&onFulfilled), createCaptor(&onRejected));
reader->read(scriptState()).then(createCaptor(&onFulfilled2), createCaptor(&onRejected2));
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_TRUE(onRejected.isNull());
EXPECT_TRUE(onFulfilled2.isNull());
@@ -439,7 +439,7 @@ TEST_F(ReadableStreamReaderTest, PendingReadsShouldBeRejectedWhenErrored)
EXPECT_TRUE(onFulfilled2.isNull());
EXPECT_TRUE(onRejected2.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_EQ(onRejected, "SyntaxError: some error");
@@ -460,7 +460,7 @@ TEST_F(ReadableStreamReaderTest, PendingReadsShouldBeResolvedWhenCanceled)
reader->read(scriptState()).then(createResultCaptor(&result), createCaptor(&onRejected));
reader->read(scriptState()).then(createResultCaptor(&result2), createCaptor(&onRejected2));
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_FALSE(result.isSet);
EXPECT_TRUE(onRejected.isNull());
EXPECT_FALSE(result2.isSet);
@@ -473,7 +473,7 @@ TEST_F(ReadableStreamReaderTest, PendingReadsShouldBeResolvedWhenCanceled)
EXPECT_FALSE(result2.isSet);
EXPECT_TRUE(onRejected2.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(result.isSet);
EXPECT_TRUE(result.isDone);
@@ -502,7 +502,7 @@ TEST_F(ReadableStreamReaderTest, CancelShouldNotWorkWhenNotActive)
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_TRUE(onRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_EQ("TypeError: the reader is already released", onRejected);
@@ -528,7 +528,7 @@ TEST_F(ReadableStreamReaderTest, Cancel)
EXPECT_TRUE(onCancelFulfilled.isNull());
EXPECT_TRUE(onCancelRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ("undefined", onClosedFulfilled);
EXPECT_TRUE(onClosedRejected.isNull());
EXPECT_EQ("undefined", onCancelFulfilled);
@@ -552,7 +552,7 @@ TEST_F(ReadableStreamReaderTest, Close)
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_TRUE(onRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ("undefined", onFulfilled);
EXPECT_TRUE(onRejected.isNull());
EXPECT_FALSE(exceptionState.hadException());
@@ -574,7 +574,7 @@ TEST_F(ReadableStreamReaderTest, Error)
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_TRUE(onRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_EQ("SyntaxError: some error", onRejected);
EXPECT_FALSE(exceptionState.hadException());
diff --git a/third_party/WebKit/Source/core/streams/ReadableStreamTest.cpp b/third_party/WebKit/Source/core/streams/ReadableStreamTest.cpp
index fb52f46..031ecdd 100644
--- a/third_party/WebKit/Source/core/streams/ReadableStreamTest.cpp
+++ b/third_party/WebKit/Source/core/streams/ReadableStreamTest.cpp
@@ -304,7 +304,7 @@ TEST_F(ReadableStreamTest, CloseWhenReadable)
stream->read(scriptState());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ(ReadableStream::Readable, stream->stateInternal());
EXPECT_FALSE(stream->isPulling());
@@ -335,7 +335,7 @@ TEST_F(ReadableStreamTest, CancelWhenClosed)
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_TRUE(onRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ("undefined", onFulfilled);
EXPECT_TRUE(onRejected.isNull());
}
@@ -358,7 +358,7 @@ TEST_F(ReadableStreamTest, CancelWhenErrored)
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_TRUE(onRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_EQ("NotFoundError: error", onRejected);
}
@@ -392,7 +392,7 @@ TEST_F(ReadableStreamTest, CancelWhenReadable)
EXPECT_TRUE(onCancelFulfilled.isNull());
EXPECT_TRUE(onCancelRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ("undefined", onCancelFulfilled);
EXPECT_TRUE(onCancelRejected.isNull());
}
@@ -416,7 +416,7 @@ TEST_F(ReadableStreamTest, CancelWhenLocked)
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_TRUE(onRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_EQ("TypeError: this stream is locked to a ReadableStreamReader", onRejected);
@@ -563,7 +563,7 @@ TEST_F(ReadableStreamTest, GetClosedReader)
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_TRUE(onRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_EQ("undefined", onFulfilled);
EXPECT_TRUE(onRejected.isNull());
}
@@ -586,7 +586,7 @@ TEST_F(ReadableStreamTest, GetErroredReader)
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_TRUE(onRejected.isNull());
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
EXPECT_TRUE(onFulfilled.isNull());
EXPECT_EQ("SyntaxError: some error", onRejected);
}
diff --git a/third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp b/third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp
index 7834ae9..1c4030c 100644
--- a/third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp
+++ b/third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp
@@ -249,7 +249,7 @@ public:
{
ScriptValue onReject;
promise.then(UnreachableFunction::create(scriptState()), TestFunction::create(scriptState(), &onReject));
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
return onReject;
}
@@ -263,7 +263,7 @@ public:
{
ScriptValue onResolve;
promise.then(TestFunction::create(scriptState(), &onResolve), UnreachableFunction::create(scriptState()));
- isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(isolate());
return onResolve;
}
diff --git a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp
index 9a9daea..fba225c 100644
--- a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp
+++ b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp
@@ -8,6 +8,7 @@
#include "bindings/core/v8/ScriptState.h"
#include "bindings/core/v8/V8BindingMacros.h"
#include "bindings/core/v8/V8GCController.h"
+#include "bindings/core/v8/V8RecursionScope.h"
#include "core/dom/Document.h"
#include "core/testing/DummyPageHolder.h"
#include "modules/fetch/DataConsumerHandleTestUtil.h"
@@ -59,6 +60,7 @@ public:
{
v8::Local<v8::String> source;
v8::Local<v8::Script> script;
+ V8RecursionScope::MicrotaskSuppression microtasks(isolate());
if (!v8Call(v8::String::NewFromUtf8(isolate(), s, v8::NewStringType::kNormal), source)) {
ADD_FAILURE();
return v8::MaybeLocal<v8::Value>();
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp
index 8c0af13..cb4e2da 100644
--- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp
+++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp
@@ -92,7 +92,7 @@ void expectRejected(ScriptState* scriptState, ScriptPromise& promise, const Scri
{
StubScriptFunction resolved, rejected;
promise.then(resolved.function(scriptState), rejected.function(scriptState));
- promise.isolate()->RunMicrotasks();
+ v8::MicrotasksScope::PerformCheckpoint(promise.isolate());
EXPECT_EQ(0ul, resolved.callCount());
EXPECT_EQ(1ul, rejected.callCount());
if (rejected.callCount())