Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: Source/bindings/core/v8/ScriptStreamerTest.cpp

Issue 651163002: Script streaming: Add an option to make the main thread block (wait for parsing) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: . Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/core/v8/ScriptStreamerTest.cpp
diff --git a/Source/bindings/core/v8/ScriptStreamerTest.cpp b/Source/bindings/core/v8/ScriptStreamerTest.cpp
index b5d670b4597ea1055eeda49d336eb68c723b513b..adf5383d2ca07cfe71c58e60f0c6ab2166397d04 100644
--- a/Source/bindings/core/v8/ScriptStreamerTest.cpp
+++ b/Source/bindings/core/v8/ScriptStreamerTest.cpp
@@ -58,7 +58,9 @@ private:
PendingScript m_pendingScript;
};
-class ScriptStreamingTest : public testing::Test {
+// The bool param for ScriptStreamingTest controls whether to make the main
+// thread block and wait for parsing.
+class ScriptStreamingTest : public testing::TestWithParam<bool> {
public:
ScriptStreamingTest()
: m_scope(v8::Isolate::GetCurrent())
@@ -68,6 +70,7 @@ public:
, m_pendingScript(PendingScriptWrapper::create(0, m_resource)) // Takes ownership of m_resource.
{
m_settings->setV8ScriptStreamingEnabled(true);
+ m_settings->setV8ScriptStreamingBlocking(GetParam());
m_resource->setLoading(true);
ScriptStreamer::removeSmallScriptThresholdForTesting();
}
@@ -140,7 +143,7 @@ private:
bool m_finished;
};
-TEST_F(ScriptStreamingTest, CompilingStreamedScript)
+TEST_P(ScriptStreamingTest, CompilingStreamedScript)
{
// Test that we can successfully compile a streamed script.
ScriptStreamer::startStreaming(pendingScript(), m_settings.get(), m_scope.scriptState(), PendingScript::ParsingBlocking);
@@ -169,7 +172,7 @@ TEST_F(ScriptStreamingTest, CompilingStreamedScript)
EXPECT_FALSE(tryCatch.HasCaught());
}
-TEST_F(ScriptStreamingTest, CompilingStreamedScriptWithParseError)
+TEST_P(ScriptStreamingTest, CompilingStreamedScriptWithParseError)
{
// Test that scripts with parse errors are handled properly. In those cases,
// the V8 side typically finished before loading finishes: make sure we
@@ -202,7 +205,7 @@ TEST_F(ScriptStreamingTest, CompilingStreamedScriptWithParseError)
EXPECT_TRUE(tryCatch.HasCaught());
}
-TEST_F(ScriptStreamingTest, CancellingStreaming)
+TEST_P(ScriptStreamingTest, CancellingStreaming)
{
// Test that the upper layers (PendingScript and up) can be ramped down
// while streaming is ongoing, and ScriptStreamer handles it gracefully.
@@ -228,7 +231,7 @@ TEST_F(ScriptStreamingTest, CancellingStreaming)
EXPECT_FALSE(client.finished());
}
-TEST_F(ScriptStreamingTest, SuppressingStreaming)
+TEST_P(ScriptStreamingTest, SuppressingStreaming)
{
// If we notice during streaming that there is a code cache, streaming
// is suppressed (V8 doesn't parse while the script is loading), and the
@@ -256,7 +259,7 @@ TEST_F(ScriptStreamingTest, SuppressingStreaming)
EXPECT_FALSE(sourceCode.streamer());
}
-TEST_F(ScriptStreamingTest, EmptyScripts)
+TEST_P(ScriptStreamingTest, EmptyScripts)
{
// Empty scripts should also be streamed properly, that is, the upper layer
// (ScriptResourceClient) should be notified when an empty script has been
@@ -277,6 +280,8 @@ TEST_F(ScriptStreamingTest, EmptyScripts)
EXPECT_FALSE(sourceCode.streamer());
}
+INSTANTIATE_TEST_CASE_P(ScriptStreamingInstantiation, ScriptStreamingTest, ::testing::Values(false, true));
+
} // namespace
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698