| 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 #include "bindings/core/v8/ScriptStreamer.h" | 5 #include "bindings/core/v8/ScriptStreamer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 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" |
| 11 #include "bindings/core/v8/V8BindingForCore.h" | 11 #include "bindings/core/v8/V8BindingForCore.h" |
| 12 #include "bindings/core/v8/V8BindingForTesting.h" | 12 #include "bindings/core/v8/V8BindingForTesting.h" |
| 13 #include "bindings/core/v8/V8ScriptRunner.h" | 13 #include "bindings/core/v8/V8ScriptRunner.h" |
| 14 #include "core/dom/ClassicPendingScript.h" | 14 #include "core/dom/ClassicPendingScript.h" |
| 15 #include "core/dom/ClassicScript.h" | 15 #include "core/dom/ClassicScript.h" |
| 16 #include "core/dom/MockScriptElementBase.h" |
| 16 #include "core/frame/Settings.h" | 17 #include "core/frame/Settings.h" |
| 17 #include "platform/heap/Handle.h" | 18 #include "platform/heap/Handle.h" |
| 18 #include "platform/testing/UnitTestHelpers.h" | 19 #include "platform/testing/UnitTestHelpers.h" |
| 19 #include "public/platform/Platform.h" | 20 #include "public/platform/Platform.h" |
| 20 #include "public/platform/WebScheduler.h" | 21 #include "public/platform/WebScheduler.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "v8/include/v8.h" | 23 #include "v8/include/v8.h" |
| 23 | 24 |
| 24 namespace blink { | 25 namespace blink { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 class ScriptStreamingTest : public ::testing::Test { | 29 class ScriptStreamingTest : public ::testing::Test { |
| 29 public: | 30 public: |
| 30 ScriptStreamingTest() | 31 ScriptStreamingTest() |
| 31 : loading_task_runner_(Platform::Current() | 32 : loading_task_runner_(Platform::Current() |
| 32 ->CurrentThread() | 33 ->CurrentThread() |
| 33 ->Scheduler() | 34 ->Scheduler() |
| 34 ->LoadingTaskRunner()), | 35 ->LoadingTaskRunner()), |
| 35 settings_(Settings::Create()), | 36 settings_(Settings::Create()), |
| 36 resource_request_("http://www.streaming-test.com/"), | 37 resource_request_("http://www.streaming-test.com/"), |
| 37 resource_(ScriptResource::Create(resource_request_, "UTF-8")), | 38 resource_(ScriptResource::Create(resource_request_, "UTF-8")) { |
| 38 pending_script_( | |
| 39 ClassicPendingScript::CreateForTesting(resource_.Get())) { | |
| 40 resource_->SetStatus(ResourceStatus::kPending); | 39 resource_->SetStatus(ResourceStatus::kPending); |
| 41 pending_script_ = ClassicPendingScript::CreateForTesting(resource_.Get()); | 40 |
| 41 MockScriptElementBase* element = MockScriptElementBase::Create(); |
| 42 // Basically we are not interested in ScriptElementBase* calls, just making |
| 43 // the method(s) to return default values. |
| 44 EXPECT_CALL(*element, IntegrityAttributeValue()) |
| 45 .WillRepeatedly(::testing::Return(String())); |
| 46 |
| 47 pending_script_ = ClassicPendingScript::Create(element, resource_.Get()); |
| 42 ScriptStreamer::SetSmallScriptThresholdForTesting(0); | 48 ScriptStreamer::SetSmallScriptThresholdForTesting(0); |
| 43 } | 49 } |
| 44 | 50 |
| 45 ~ScriptStreamingTest() { | 51 ~ScriptStreamingTest() { |
| 46 if (pending_script_) | 52 if (pending_script_) |
| 47 pending_script_->Dispose(); | 53 pending_script_->Dispose(); |
| 48 } | 54 } |
| 49 | 55 |
| 50 ClassicPendingScript* GetPendingScript() const { | 56 ClassicPendingScript* GetPendingScript() const { |
| 51 return pending_script_.Get(); | 57 return pending_script_.Get(); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 EXPECT_TRUE(V8ScriptRunner::CompileScript(source_code, scope.GetIsolate(), | 413 EXPECT_TRUE(V8ScriptRunner::CompileScript(source_code, scope.GetIsolate(), |
| 408 kSharableCrossOrigin, | 414 kSharableCrossOrigin, |
| 409 kV8CacheOptionsDefault) | 415 kV8CacheOptionsDefault) |
| 410 .ToLocal(&script)); | 416 .ToLocal(&script)); |
| 411 EXPECT_FALSE(try_catch.HasCaught()); | 417 EXPECT_FALSE(try_catch.HasCaught()); |
| 412 } | 418 } |
| 413 | 419 |
| 414 } // namespace | 420 } // namespace |
| 415 | 421 |
| 416 } // namespace blink | 422 } // namespace blink |
| OLD | NEW |