| 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 "bindings/core/v8/ScriptStreamer.h" | 6 #include "bindings/core/v8/ScriptStreamer.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptSourceCode.h" | 8 #include "bindings/core/v8/ScriptSourceCode.h" |
| 9 #include "bindings/core/v8/ScriptStreamerThread.h" | 9 #include "bindings/core/v8/ScriptStreamerThread.h" |
| 10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| 11 #include "bindings/core/v8/V8BindingForTesting.h" | 11 #include "bindings/core/v8/V8BindingForTesting.h" |
| 12 #include "bindings/core/v8/V8ScriptRunner.h" | 12 #include "bindings/core/v8/V8ScriptRunner.h" |
| 13 #include "core/dom/Element.h" | 13 #include "core/dom/Element.h" |
| 14 #include "core/dom/PendingScript.h" | 14 #include "core/dom/PendingScript.h" |
| 15 #include "core/frame/Settings.h" | 15 #include "core/frame/Settings.h" |
| 16 #include "platform/heap/Handle.h" | 16 #include "platform/heap/Handle.h" |
| 17 #include "platform/testing/UnitTestHelpers.h" | 17 #include "platform/testing/UnitTestHelpers.h" |
| 18 #include "public/platform/Platform.h" | 18 #include "public/platform/Platform.h" |
| 19 #include "public/platform/WebScheduler.h" | 19 #include "public/platform/WebScheduler.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include <memory> |
| 21 #include <v8.h> | 22 #include <v8.h> |
| 22 | 23 |
| 23 namespace blink { | 24 namespace blink { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 class ScriptStreamingTest : public ::testing::Test { | 28 class ScriptStreamingTest : public ::testing::Test { |
| 28 public: | 29 public: |
| 29 ScriptStreamingTest() | 30 ScriptStreamingTest() |
| 30 : m_loadingTaskRunner(Platform::current()->currentThread()->scheduler()-
>loadingTaskRunner()) | 31 : m_loadingTaskRunner(Platform::current()->currentThread()->scheduler()-
>loadingTaskRunner()) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 while (ScriptStreamerThread::shared()->isRunningTask()) { | 83 while (ScriptStreamerThread::shared()->isRunningTask()) { |
| 83 testing::runPendingTasks(); | 84 testing::runPendingTasks(); |
| 84 } | 85 } |
| 85 // Once more, because the "streaming complete" notification might only | 86 // Once more, because the "streaming complete" notification might only |
| 86 // now be in the task queue. | 87 // now be in the task queue. |
| 87 testing::runPendingTasks(); | 88 testing::runPendingTasks(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 WebTaskRunner* m_loadingTaskRunner; // NOT OWNED | 91 WebTaskRunner* m_loadingTaskRunner; // NOT OWNED |
| 91 V8TestingScope m_scope; | 92 V8TestingScope m_scope; |
| 92 OwnPtr<Settings> m_settings; | 93 std::unique_ptr<Settings> m_settings; |
| 93 // The Resource and PendingScript where we stream from. These don't really | 94 // The Resource and PendingScript where we stream from. These don't really |
| 94 // fetch any data outside the test; the test controls the data by calling | 95 // fetch any data outside the test; the test controls the data by calling |
| 95 // ScriptResource::appendData. | 96 // ScriptResource::appendData. |
| 96 ResourceRequest m_resourceRequest; | 97 ResourceRequest m_resourceRequest; |
| 97 Persistent<ScriptResource> m_resource; | 98 Persistent<ScriptResource> m_resource; |
| 98 Persistent<PendingScript> m_pendingScript; | 99 Persistent<PendingScript> m_pendingScript; |
| 99 }; | 100 }; |
| 100 | 101 |
| 101 class TestScriptResourceClient : public GarbageCollectedFinalized<TestScriptReso
urceClient>, public ScriptResourceClient { | 102 class TestScriptResourceClient : public GarbageCollectedFinalized<TestScriptReso
urceClient>, public ScriptResourceClient { |
| 102 USING_GARBAGE_COLLECTED_MIXIN(TestScriptResourceClient); | 103 USING_GARBAGE_COLLECTED_MIXIN(TestScriptResourceClient); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 EXPECT_TRUE(sourceCode.streamer()); | 383 EXPECT_TRUE(sourceCode.streamer()); |
| 383 v8::TryCatch tryCatch(isolate()); | 384 v8::TryCatch tryCatch(isolate()); |
| 384 v8::Local<v8::Script> script; | 385 v8::Local<v8::Script> script; |
| 385 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc
ript)); | 386 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc
ript)); |
| 386 EXPECT_FALSE(tryCatch.HasCaught()); | 387 EXPECT_FALSE(tryCatch.HasCaught()); |
| 387 } | 388 } |
| 388 | 389 |
| 389 } // namespace | 390 } // namespace |
| 390 | 391 |
| 391 } // namespace blink | 392 } // namespace blink |
| OLD | NEW |