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

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: more versatile options 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 ccc814ab96772b0a0a9364bcbd85e4311a62c1c1..3f7f9157f4c918b850c506ad6a2201d5b957022f 100644
--- a/Source/bindings/core/v8/ScriptStreamerTest.cpp
+++ b/Source/bindings/core/v8/ScriptStreamerTest.cpp
@@ -8,6 +8,7 @@
#include "bindings/core/v8/ScriptSourceCode.h"
#include "bindings/core/v8/ScriptStreamerThread.h"
+#include "bindings/core/v8/ScriptStreamingMode.h"
#include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8ScriptRunner.h"
#include "core/dom/PendingScript.h"
@@ -58,7 +59,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 +71,8 @@ public:
, m_pendingScript(PendingScriptWrapper::create(0, m_resource)) // Takes ownership of m_resource.
{
m_settings->setV8ScriptStreamingEnabled(true);
+ if (GetParam())
+ m_settings->setV8ScriptStreamingMode(ScriptStreamingModeAllPlusBlockParsingBlocking);
m_resource->setLoading(true);
ScriptStreamer::setSmallScriptThresholdForTesting(0);
}
@@ -140,7 +145,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 +174,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 +207,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.
@@ -229,7 +234,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
@@ -257,7 +262,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
@@ -278,7 +283,7 @@ TEST_F(ScriptStreamingTest, EmptyScripts)
EXPECT_FALSE(sourceCode.streamer());
}
-TEST_F(ScriptStreamingTest, SmallScripts)
+TEST_P(ScriptStreamingTest, SmallScripts)
{
// Small scripts shouldn't be streamed.
ScriptStreamer::setSmallScriptThresholdForTesting(100);
@@ -301,7 +306,7 @@ TEST_F(ScriptStreamingTest, SmallScripts)
EXPECT_FALSE(sourceCode.streamer());
}
-TEST_F(ScriptStreamingTest, ScriptsWithSmallFirstChunk)
+TEST_P(ScriptStreamingTest, ScriptsWithSmallFirstChunk)
{
// If a script is long enough, if should be streamed, even if the first data
// chunk is small.
@@ -331,6 +336,8 @@ TEST_F(ScriptStreamingTest, ScriptsWithSmallFirstChunk)
EXPECT_FALSE(tryCatch.HasCaught());
}
+INSTANTIATE_TEST_CASE_P(ScriptStreamingInstantiation, ScriptStreamingTest, ::testing::Values(false, true));
+
} // namespace
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698