| Index: third_party/WebKit/Source/bindings/core/v8/ScriptStreamerTest.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerTest.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerTest.cpp
|
| index fb86979bc174f95f1115683d5186a777dc47053b..776824b89a49748bd27decd56e3ada68310b4a68 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerTest.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerTest.cpp
|
| @@ -25,41 +25,6 @@ namespace blink {
|
|
|
| namespace {
|
|
|
| -// For the benefit of Oilpan, put the part object PendingScript inside
|
| -// a wrapper that's on the Oilpan heap and hold a reference to that wrapper
|
| -// from ScriptStreamingTest.
|
| -class PendingScriptWrapper : public NoBaseWillBeGarbageCollectedFinalized<PendingScriptWrapper> {
|
| -public:
|
| - static PassOwnPtrWillBeRawPtr<PendingScriptWrapper> create()
|
| - {
|
| - return adoptPtrWillBeNoop(new PendingScriptWrapper());
|
| - }
|
| -
|
| - static PassOwnPtrWillBeRawPtr<PendingScriptWrapper> create(Element* element, ScriptResource* resource)
|
| - {
|
| - return adoptPtrWillBeNoop(new PendingScriptWrapper(element, resource));
|
| - }
|
| -
|
| - PendingScript& get() { return m_pendingScript; }
|
| -
|
| - DEFINE_INLINE_TRACE()
|
| - {
|
| - visitor->trace(m_pendingScript);
|
| - }
|
| -
|
| -private:
|
| - PendingScriptWrapper()
|
| - {
|
| - }
|
| -
|
| - PendingScriptWrapper(Element* element, ScriptResource* resource)
|
| - : m_pendingScript(PendingScript(element, resource))
|
| - {
|
| - }
|
| -
|
| - PendingScript m_pendingScript;
|
| -};
|
| -
|
| class ScriptStreamingTest : public ::testing::Test {
|
| public:
|
| ScriptStreamingTest()
|
| @@ -68,17 +33,17 @@ public:
|
| , m_settings(Settings::create())
|
| , m_resourceRequest("http://www.streaming-test.com/")
|
| , m_resource(new ScriptResource(m_resourceRequest, "UTF-8"))
|
| - , m_pendingScript(PendingScriptWrapper::create(0, m_resource.get()))
|
| + , m_pendingScript(PendingScript::create(0, m_resource.get()))
|
| {
|
| m_resource->setLoading(true);
|
| - m_pendingScript = PendingScriptWrapper::create(0, m_resource.get());
|
| + m_pendingScript = PendingScript::create(0, m_resource.get());
|
| ScriptStreamer::setSmallScriptThresholdForTesting(0);
|
| }
|
|
|
| ScriptState* scriptState() const { return m_scope.scriptState(); }
|
| v8::Isolate* isolate() const { return m_scope.isolate(); }
|
|
|
| - PendingScript& pendingScript() const { return m_pendingScript->get(); }
|
| + PendingScript* pendingScript() const { return m_pendingScript.get(); }
|
|
|
| protected:
|
| void appendData(const char* data)
|
| @@ -125,7 +90,7 @@ protected:
|
| // ScriptResource::appendData.
|
| ResourceRequest m_resourceRequest;
|
| ResourcePtr<ScriptResource> m_resource;
|
| - OwnPtrWillBePersistent<PendingScriptWrapper> m_pendingScript;
|
| + OwnPtrWillBePersistent<PendingScript> m_pendingScript;
|
| };
|
|
|
| class TestScriptResourceClient : public ScriptResourceClient {
|
| @@ -153,7 +118,7 @@ TEST_F(ScriptStreamingTest, MAYBE_CompilingStreamedScript)
|
| // Test that we can successfully compile a streamed script.
|
| ScriptStreamer::startStreaming(pendingScript(), PendingScript::ParsingBlocking, m_settings.get(), m_scope.scriptState(), m_loadingTaskRunner);
|
| TestScriptResourceClient client;
|
| - pendingScript().watchForLoad(&client);
|
| + pendingScript()->watchForLoad(&client);
|
|
|
| appendData("function foo() {");
|
| appendPadding();
|
| @@ -168,7 +133,7 @@ TEST_F(ScriptStreamingTest, MAYBE_CompilingStreamedScript)
|
| processTasksUntilStreamingComplete();
|
| EXPECT_TRUE(client.finished());
|
| bool errorOccurred = false;
|
| - ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
|
| + ScriptSourceCode sourceCode = pendingScript()->getSource(KURL(), errorOccurred);
|
| EXPECT_FALSE(errorOccurred);
|
| EXPECT_TRUE(sourceCode.streamer());
|
| v8::TryCatch tryCatch(isolate());
|
| @@ -184,7 +149,7 @@ TEST_F(ScriptStreamingTest, CompilingStreamedScriptWithParseError)
|
| // handle it gracefully.
|
| ScriptStreamer::startStreaming(pendingScript(), PendingScript::ParsingBlocking, m_settings.get(), m_scope.scriptState(), m_loadingTaskRunner);
|
| TestScriptResourceClient client;
|
| - pendingScript().watchForLoad(&client);
|
| + pendingScript()->watchForLoad(&client);
|
| appendData("function foo() {");
|
| appendData("this is the part which will be a parse error");
|
| // V8 won't realize the parse error until it actually starts parsing the
|
| @@ -201,7 +166,7 @@ TEST_F(ScriptStreamingTest, CompilingStreamedScriptWithParseError)
|
| EXPECT_TRUE(client.finished());
|
|
|
| bool errorOccurred = false;
|
| - ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
|
| + ScriptSourceCode sourceCode = pendingScript()->getSource(KURL(), errorOccurred);
|
| EXPECT_FALSE(errorOccurred);
|
| EXPECT_TRUE(sourceCode.streamer());
|
| v8::TryCatch tryCatch(isolate());
|
| @@ -216,7 +181,7 @@ TEST_F(ScriptStreamingTest, CancellingStreaming)
|
| // while streaming is ongoing, and ScriptStreamer handles it gracefully.
|
| ScriptStreamer::startStreaming(pendingScript(), PendingScript::ParsingBlocking, m_settings.get(), m_scope.scriptState(), m_loadingTaskRunner);
|
| TestScriptResourceClient client;
|
| - pendingScript().watchForLoad(&client);
|
| + pendingScript()->watchForLoad(&client);
|
| appendData("function foo() {");
|
|
|
| // In general, we cannot control what the background thread is doing
|
| @@ -226,9 +191,9 @@ TEST_F(ScriptStreamingTest, CancellingStreaming)
|
| // Simulate cancelling the network load (e.g., because the user navigated
|
| // away).
|
| EXPECT_FALSE(client.finished());
|
| - pendingScript().stopWatchingForLoad(&client);
|
| - pendingScript().releaseElementAndClear();
|
| - m_pendingScript = PendingScriptWrapper::create(); // This will destroy m_resource.
|
| + pendingScript()->stopWatchingForLoad(&client);
|
| + pendingScript()->releaseElementAndClear();
|
| + m_pendingScript = nullptr; // This will destroy m_resource.
|
| m_resource = 0;
|
|
|
| // The V8 side will complete too. This should not crash. We don't receive
|
| @@ -245,7 +210,7 @@ TEST_F(ScriptStreamingTest, SuppressingStreaming)
|
| // script is loaded.
|
| ScriptStreamer::startStreaming(pendingScript(), PendingScript::ParsingBlocking, m_settings.get(), m_scope.scriptState(), m_loadingTaskRunner);
|
| TestScriptResourceClient client;
|
| - pendingScript().watchForLoad(&client);
|
| + pendingScript()->watchForLoad(&client);
|
| appendData("function foo() {");
|
| appendPadding();
|
|
|
| @@ -259,7 +224,7 @@ TEST_F(ScriptStreamingTest, SuppressingStreaming)
|
| EXPECT_TRUE(client.finished());
|
|
|
| bool errorOccurred = false;
|
| - ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
|
| + ScriptSourceCode sourceCode = pendingScript()->getSource(KURL(), errorOccurred);
|
| EXPECT_FALSE(errorOccurred);
|
| // ScriptSourceCode doesn't refer to the streamer, since we have suppressed
|
| // the streaming and resumed the non-streaming code path for script
|
| @@ -274,7 +239,7 @@ TEST_F(ScriptStreamingTest, EmptyScripts)
|
| // loaded.
|
| ScriptStreamer::startStreaming(pendingScript(), PendingScript::ParsingBlocking, m_settings.get(), m_scope.scriptState(), m_loadingTaskRunner);
|
| TestScriptResourceClient client;
|
| - pendingScript().watchForLoad(&client);
|
| + pendingScript()->watchForLoad(&client);
|
|
|
| // Finish the script without sending any data.
|
| finish();
|
| @@ -283,7 +248,7 @@ TEST_F(ScriptStreamingTest, EmptyScripts)
|
| EXPECT_TRUE(client.finished());
|
|
|
| bool errorOccurred = false;
|
| - ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
|
| + ScriptSourceCode sourceCode = pendingScript()->getSource(KURL(), errorOccurred);
|
| EXPECT_FALSE(errorOccurred);
|
| EXPECT_FALSE(sourceCode.streamer());
|
| }
|
| @@ -295,7 +260,7 @@ TEST_F(ScriptStreamingTest, SmallScripts)
|
|
|
| ScriptStreamer::startStreaming(pendingScript(), PendingScript::ParsingBlocking, m_settings.get(), m_scope.scriptState(), m_loadingTaskRunner);
|
| TestScriptResourceClient client;
|
| - pendingScript().watchForLoad(&client);
|
| + pendingScript()->watchForLoad(&client);
|
|
|
| appendData("function foo() { }");
|
|
|
| @@ -306,7 +271,7 @@ TEST_F(ScriptStreamingTest, SmallScripts)
|
| EXPECT_TRUE(client.finished());
|
|
|
| bool errorOccurred = false;
|
| - ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
|
| + ScriptSourceCode sourceCode = pendingScript()->getSource(KURL(), errorOccurred);
|
| EXPECT_FALSE(errorOccurred);
|
| EXPECT_FALSE(sourceCode.streamer());
|
| }
|
| @@ -325,7 +290,7 @@ TEST_F(ScriptStreamingTest, MAYBE_ScriptsWithSmallFirstChunk)
|
|
|
| ScriptStreamer::startStreaming(pendingScript(), PendingScript::ParsingBlocking, m_settings.get(), m_scope.scriptState(), m_loadingTaskRunner);
|
| TestScriptResourceClient client;
|
| - pendingScript().watchForLoad(&client);
|
| + pendingScript()->watchForLoad(&client);
|
|
|
| // This is the first data chunk which is small.
|
| appendData("function foo() { }");
|
| @@ -338,7 +303,7 @@ TEST_F(ScriptStreamingTest, MAYBE_ScriptsWithSmallFirstChunk)
|
| processTasksUntilStreamingComplete();
|
| EXPECT_TRUE(client.finished());
|
| bool errorOccurred = false;
|
| - ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
|
| + ScriptSourceCode sourceCode = pendingScript()->getSource(KURL(), errorOccurred);
|
| EXPECT_FALSE(errorOccurred);
|
| EXPECT_TRUE(sourceCode.streamer());
|
| v8::TryCatch tryCatch(isolate());
|
| @@ -361,7 +326,7 @@ TEST_F(ScriptStreamingTest, MAYBE_EncodingChanges)
|
|
|
| ScriptStreamer::startStreaming(pendingScript(), PendingScript::ParsingBlocking, m_settings.get(), m_scope.scriptState(), m_loadingTaskRunner);
|
| TestScriptResourceClient client;
|
| - pendingScript().watchForLoad(&client);
|
| + pendingScript()->watchForLoad(&client);
|
|
|
| m_resource->setEncoding("UTF-8");
|
| // \xec\x92\x81 are the raw bytes for \uc481.
|
| @@ -372,7 +337,7 @@ TEST_F(ScriptStreamingTest, MAYBE_EncodingChanges)
|
| processTasksUntilStreamingComplete();
|
| EXPECT_TRUE(client.finished());
|
| bool errorOccurred = false;
|
| - ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
|
| + ScriptSourceCode sourceCode = pendingScript()->getSource(KURL(), errorOccurred);
|
| EXPECT_FALSE(errorOccurred);
|
| EXPECT_TRUE(sourceCode.streamer());
|
| v8::TryCatch tryCatch(isolate());
|
| @@ -396,7 +361,7 @@ TEST_F(ScriptStreamingTest, MAYBE_EncodingFromBOM)
|
|
|
| ScriptStreamer::startStreaming(pendingScript(), PendingScript::ParsingBlocking, m_settings.get(), m_scope.scriptState(), m_loadingTaskRunner);
|
| TestScriptResourceClient client;
|
| - pendingScript().watchForLoad(&client);
|
| + pendingScript()->watchForLoad(&client);
|
|
|
| // \xef\xbb\xbf is the UTF-8 byte order mark. \xec\x92\x81 are the raw bytes
|
| // for \uc481.
|
| @@ -406,7 +371,7 @@ TEST_F(ScriptStreamingTest, MAYBE_EncodingFromBOM)
|
| processTasksUntilStreamingComplete();
|
| EXPECT_TRUE(client.finished());
|
| bool errorOccurred = false;
|
| - ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
|
| + ScriptSourceCode sourceCode = pendingScript()->getSource(KURL(), errorOccurred);
|
| EXPECT_FALSE(errorOccurred);
|
| EXPECT_TRUE(sourceCode.streamer());
|
| v8::TryCatch tryCatch(isolate());
|
|
|