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 9a51bf9df9e4d7357e1e436885a160672955fac7..79c27cbafa3b696bb9fac7dea9c6901c9133d95c 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerTest.cpp |
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerTest.cpp |
@@ -98,7 +98,8 @@ protected: |
Persistent<PendingScript> m_pendingScript; |
}; |
-class TestScriptResourceClient : public ScriptResourceClient { |
+class TestScriptResourceClient : public GarbageCollectedFinalized<TestScriptResourceClient>, public ScriptResourceClient { |
+ USING_GARBAGE_COLLECTED_MIXIN(TestScriptResourceClient); |
public: |
TestScriptResourceClient() |
: m_finished(false) { } |
@@ -122,21 +123,21 @@ TEST_F(ScriptStreamingTest, MAYBE_CompilingStreamedScript) |
{ |
// Test that we can successfully compile a streamed script. |
ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBlocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); |
- TestScriptResourceClient client; |
- getPendingScript()->watchForLoad(&client); |
+ TestScriptResourceClient* client = new TestScriptResourceClient; |
+ getPendingScript()->watchForLoad(client); |
appendData("function foo() {"); |
appendPadding(); |
appendData("return 5; }"); |
appendPadding(); |
appendData("foo();"); |
- EXPECT_FALSE(client.finished()); |
+ EXPECT_FALSE(client->finished()); |
finish(); |
// Process tasks on the main thread until the streaming background thread |
// has completed its tasks. |
processTasksUntilStreamingComplete(); |
- EXPECT_TRUE(client.finished()); |
+ EXPECT_TRUE(client->finished()); |
bool errorOccurred = false; |
ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOccurred); |
EXPECT_FALSE(errorOccurred); |
@@ -153,22 +154,22 @@ TEST_F(ScriptStreamingTest, CompilingStreamedScriptWithParseError) |
// the V8 side typically finished before loading finishes: make sure we |
// handle it gracefully. |
ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBlocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); |
- TestScriptResourceClient client; |
- getPendingScript()->watchForLoad(&client); |
+ TestScriptResourceClient* client = new TestScriptResourceClient; |
+ getPendingScript()->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 |
// script, and this happens only when its buffer is filled. |
appendPadding(); |
- EXPECT_FALSE(client.finished()); |
+ EXPECT_FALSE(client->finished()); |
// Force the V8 side to finish before the loading. |
processTasksUntilStreamingComplete(); |
- EXPECT_FALSE(client.finished()); |
+ EXPECT_FALSE(client->finished()); |
finish(); |
- EXPECT_TRUE(client.finished()); |
+ EXPECT_TRUE(client->finished()); |
bool errorOccurred = false; |
ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOccurred); |
@@ -185,8 +186,8 @@ TEST_F(ScriptStreamingTest, CancellingStreaming) |
// Test that the upper layers (PendingScript and up) can be ramped down |
// while streaming is ongoing, and ScriptStreamer handles it gracefully. |
ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBlocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); |
- TestScriptResourceClient client; |
- getPendingScript()->watchForLoad(&client); |
+ TestScriptResourceClient* client = new TestScriptResourceClient; |
+ getPendingScript()->watchForLoad(client); |
appendData("function foo() {"); |
// In general, we cannot control what the background thread is doing |
@@ -195,7 +196,7 @@ TEST_F(ScriptStreamingTest, CancellingStreaming) |
// Simulate cancelling the network load (e.g., because the user navigated |
// away). |
- EXPECT_FALSE(client.finished()); |
+ EXPECT_FALSE(client->finished()); |
getPendingScript()->stopWatchingForLoad(); |
getPendingScript()->releaseElementAndClear(); |
m_pendingScript = nullptr; // This will destroy m_resource. |
@@ -204,7 +205,7 @@ TEST_F(ScriptStreamingTest, CancellingStreaming) |
// The V8 side will complete too. This should not crash. We don't receive |
// any results from the streaming and the client doesn't get notified. |
processTasksUntilStreamingComplete(); |
- EXPECT_FALSE(client.finished()); |
+ EXPECT_FALSE(client->finished()); |
} |
TEST_F(ScriptStreamingTest, SuppressingStreaming) |
@@ -214,8 +215,8 @@ TEST_F(ScriptStreamingTest, SuppressingStreaming) |
// upper layer (ScriptResourceClient) should get a notification when the |
// script is loaded. |
ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBlocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); |
- TestScriptResourceClient client; |
- getPendingScript()->watchForLoad(&client); |
+ TestScriptResourceClient* client = new TestScriptResourceClient; |
+ getPendingScript()->watchForLoad(client); |
appendData("function foo() {"); |
appendPadding(); |
@@ -226,7 +227,7 @@ TEST_F(ScriptStreamingTest, SuppressingStreaming) |
appendPadding(); |
finish(); |
processTasksUntilStreamingComplete(); |
- EXPECT_TRUE(client.finished()); |
+ EXPECT_TRUE(client->finished()); |
bool errorOccurred = false; |
ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOccurred); |
@@ -243,14 +244,14 @@ TEST_F(ScriptStreamingTest, EmptyScripts) |
// (ScriptResourceClient) should be notified when an empty script has been |
// loaded. |
ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBlocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); |
- TestScriptResourceClient client; |
- getPendingScript()->watchForLoad(&client); |
+ TestScriptResourceClient* client = new TestScriptResourceClient; |
+ getPendingScript()->watchForLoad(client); |
// Finish the script without sending any data. |
finish(); |
// The finished notification should arrive immediately and not be cycled |
// through a background thread. |
- EXPECT_TRUE(client.finished()); |
+ EXPECT_TRUE(client->finished()); |
bool errorOccurred = false; |
ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOccurred); |
@@ -264,8 +265,8 @@ TEST_F(ScriptStreamingTest, SmallScripts) |
ScriptStreamer::setSmallScriptThresholdForTesting(100); |
ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBlocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); |
- TestScriptResourceClient client; |
- getPendingScript()->watchForLoad(&client); |
+ TestScriptResourceClient* client = new TestScriptResourceClient; |
+ getPendingScript()->watchForLoad(client); |
appendData("function foo() { }"); |
@@ -273,7 +274,7 @@ TEST_F(ScriptStreamingTest, SmallScripts) |
// The finished notification should arrive immediately and not be cycled |
// through a background thread. |
- EXPECT_TRUE(client.finished()); |
+ EXPECT_TRUE(client->finished()); |
bool errorOccurred = false; |
ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOccurred); |
@@ -294,8 +295,8 @@ TEST_F(ScriptStreamingTest, MAYBE_ScriptsWithSmallFirstChunk) |
ScriptStreamer::setSmallScriptThresholdForTesting(100); |
ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBlocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); |
- TestScriptResourceClient client; |
- getPendingScript()->watchForLoad(&client); |
+ TestScriptResourceClient* client = new TestScriptResourceClient; |
+ getPendingScript()->watchForLoad(client); |
// This is the first data chunk which is small. |
appendData("function foo() { }"); |
@@ -306,7 +307,7 @@ TEST_F(ScriptStreamingTest, MAYBE_ScriptsWithSmallFirstChunk) |
finish(); |
processTasksUntilStreamingComplete(); |
- EXPECT_TRUE(client.finished()); |
+ EXPECT_TRUE(client->finished()); |
bool errorOccurred = false; |
ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOccurred); |
EXPECT_FALSE(errorOccurred); |
@@ -330,8 +331,8 @@ TEST_F(ScriptStreamingTest, MAYBE_EncodingChanges) |
m_resource->setEncoding("windows-1252"); |
ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBlocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); |
- TestScriptResourceClient client; |
- getPendingScript()->watchForLoad(&client); |
+ TestScriptResourceClient* client = new TestScriptResourceClient; |
+ getPendingScript()->watchForLoad(client); |
m_resource->setEncoding("UTF-8"); |
// \xec\x92\x81 are the raw bytes for \uc481. |
@@ -340,7 +341,7 @@ TEST_F(ScriptStreamingTest, MAYBE_EncodingChanges) |
finish(); |
processTasksUntilStreamingComplete(); |
- EXPECT_TRUE(client.finished()); |
+ EXPECT_TRUE(client->finished()); |
bool errorOccurred = false; |
ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOccurred); |
EXPECT_FALSE(errorOccurred); |
@@ -365,8 +366,8 @@ TEST_F(ScriptStreamingTest, MAYBE_EncodingFromBOM) |
m_resource->setEncoding("windows-1252"); // This encoding is wrong on purpose. |
ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBlocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); |
- TestScriptResourceClient client; |
- getPendingScript()->watchForLoad(&client); |
+ TestScriptResourceClient* client = new TestScriptResourceClient; |
+ getPendingScript()->watchForLoad(client); |
// \xef\xbb\xbf is the UTF-8 byte order mark. \xec\x92\x81 are the raw bytes |
// for \uc481. |
@@ -374,7 +375,7 @@ TEST_F(ScriptStreamingTest, MAYBE_EncodingFromBOM) |
finish(); |
processTasksUntilStreamingComplete(); |
- EXPECT_TRUE(client.finished()); |
+ EXPECT_TRUE(client->finished()); |
bool errorOccurred = false; |
ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOccurred); |
EXPECT_FALSE(errorOccurred); |