| 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
|
|
|