| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 #include "config.h" | 6 #include "config.h" |
| 7 #include "bindings/core/v8/ScriptStreamer.h" | 7 #include "bindings/core/v8/ScriptStreamer.h" |
| 8 | 8 |
| 9 #include "bindings/core/v8/ScriptSourceCode.h" | 9 #include "bindings/core/v8/ScriptSourceCode.h" |
| 10 #include "bindings/core/v8/ScriptStreamerThread.h" | 10 #include "bindings/core/v8/ScriptStreamerThread.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 PendingScript m_pendingScript; | 61 PendingScript m_pendingScript; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 class ScriptStreamingTest : public ::testing::Test { | 64 class ScriptStreamingTest : public ::testing::Test { |
| 65 public: | 65 public: |
| 66 ScriptStreamingTest() | 66 ScriptStreamingTest() |
| 67 : m_scope(v8::Isolate::GetCurrent()) | 67 : m_scope(v8::Isolate::GetCurrent()) |
| 68 , m_settings(Settings::create()) | 68 , m_settings(Settings::create()) |
| 69 , m_resourceRequest("http://www.streaming-test.com/") | 69 , m_resourceRequest("http://www.streaming-test.com/") |
| 70 , m_resource(ScriptResource::create(m_resourceRequest, "UTF-8").leakPtr(
)) | 70 , m_resource(new ScriptResource(m_resourceRequest, "UTF-8")) |
| 71 , m_pendingScript(PendingScriptWrapper::create(0, m_resource)) // Takes
ownership of m_resource. | 71 , m_pendingScript(PendingScriptWrapper::create(0, m_resource.get())) |
| 72 { | 72 { |
| 73 m_resource->setLoading(true); | 73 m_resource->setLoading(true); |
| 74 ScriptStreamer::setSmallScriptThresholdForTesting(0); | 74 ScriptStreamer::setSmallScriptThresholdForTesting(0); |
| 75 } | 75 } |
| 76 | 76 |
| 77 ScriptState* scriptState() const { return m_scope.scriptState(); } | 77 ScriptState* scriptState() const { return m_scope.scriptState(); } |
| 78 v8::Isolate* isolate() const { return m_scope.isolate(); } | 78 v8::Isolate* isolate() const { return m_scope.isolate(); } |
| 79 | 79 |
| 80 PendingScript& pendingScript() const { return m_pendingScript->get(); } | 80 PendingScript& pendingScript() const { return m_pendingScript->get(); } |
| 81 | 81 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // now be in the task queue. | 115 // now be in the task queue. |
| 116 testing::runPendingTasks(); | 116 testing::runPendingTasks(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 V8TestingScope m_scope; | 119 V8TestingScope m_scope; |
| 120 OwnPtr<Settings> m_settings; | 120 OwnPtr<Settings> m_settings; |
| 121 // The Resource and PendingScript where we stream from. These don't really | 121 // The Resource and PendingScript where we stream from. These don't really |
| 122 // fetch any data outside the test; the test controls the data by calling | 122 // fetch any data outside the test; the test controls the data by calling |
| 123 // ScriptResource::appendData. | 123 // ScriptResource::appendData. |
| 124 ResourceRequest m_resourceRequest; | 124 ResourceRequest m_resourceRequest; |
| 125 ScriptResource* m_resource; | 125 ResourcePtr<ScriptResource> m_resource; |
| 126 OwnPtrWillBePersistent<PendingScriptWrapper> m_pendingScript; | 126 OwnPtrWillBePersistent<PendingScriptWrapper> m_pendingScript; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 class TestScriptResourceClient : public ScriptResourceClient { | 129 class TestScriptResourceClient : public ScriptResourceClient { |
| 130 public: | 130 public: |
| 131 TestScriptResourceClient() | 131 TestScriptResourceClient() |
| 132 : m_finished(false) { } | 132 : m_finished(false) { } |
| 133 | 133 |
| 134 virtual void notifyFinished(Resource*) override { m_finished = true; } | 134 virtual void notifyFinished(Resource*) override { m_finished = true; } |
| 135 | 135 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 EXPECT_TRUE(sourceCode.streamer()); | 384 EXPECT_TRUE(sourceCode.streamer()); |
| 385 v8::TryCatch tryCatch; | 385 v8::TryCatch tryCatch; |
| 386 v8::Local<v8::Script> script; | 386 v8::Local<v8::Script> script; |
| 387 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc
ript)); | 387 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc
ript)); |
| 388 EXPECT_FALSE(tryCatch.HasCaught()); | 388 EXPECT_FALSE(tryCatch.HasCaught()); |
| 389 } | 389 } |
| 390 | 390 |
| 391 } // namespace | 391 } // namespace |
| 392 | 392 |
| 393 } // namespace blink | 393 } // namespace blink |
| OLD | NEW |