| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/dom/TaskRunnerHelper.h" | 5 #include "core/dom/TaskRunnerHelper.h" |
| 6 #include "core/inspector/ConsoleMessageStorage.h" | 6 #include "core/inspector/ConsoleMessageStorage.h" |
| 7 #include "core/testing/DummyPageHolder.h" | 7 #include "core/testing/DummyPageHolder.h" |
| 8 #include "core/workers/ThreadedWorkletGlobalScope.h" | 8 #include "core/workers/ThreadedWorkletGlobalScope.h" |
| 9 #include "core/workers/ThreadedWorkletMessagingProxy.h" | 9 #include "core/workers/ThreadedWorkletMessagingProxy.h" |
| 10 #include "core/workers/ThreadedWorkletObjectProxy.h" | 10 #include "core/workers/ThreadedWorkletObjectProxy.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 ->Get(TaskType::kUnspecedTimer) | 84 ->Get(TaskType::kUnspecedTimer) |
| 85 ->PostTask(BLINK_FROM_HERE, CrossThreadBind(&testing::ExitRunLoop)); | 85 ->PostTask(BLINK_FROM_HERE, CrossThreadBind(&testing::ExitRunLoop)); |
| 86 } | 86 } |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 class ThreadedWorkletMessagingProxyForTest | 89 class ThreadedWorkletMessagingProxyForTest |
| 90 : public ThreadedWorkletMessagingProxy { | 90 : public ThreadedWorkletMessagingProxy { |
| 91 public: | 91 public: |
| 92 ThreadedWorkletMessagingProxyForTest(ExecutionContext* execution_context) | 92 ThreadedWorkletMessagingProxyForTest(ExecutionContext* execution_context) |
| 93 : ThreadedWorkletMessagingProxy(execution_context) { | 93 : ThreadedWorkletMessagingProxy(execution_context) { |
| 94 mock_worker_loader_proxy_provider_ = | 94 worker_loader_proxy_provider_ = |
| 95 WTF::MakeUnique<MockWorkerLoaderProxyProvider>(); | 95 WTF::MakeUnique<WorkerLoaderProxyProvider>(); |
| 96 worker_thread_ = WTF::MakeUnique<ThreadedWorkletThreadForTest>( | 96 worker_thread_ = WTF::MakeUnique<ThreadedWorkletThreadForTest>( |
| 97 mock_worker_loader_proxy_provider_.get(), WorkletObjectProxy()); | 97 worker_loader_proxy_provider_.get(), WorkletObjectProxy()); |
| 98 ThreadedWorkletThreadForTest::EnsureSharedBackingThread(); | 98 ThreadedWorkletThreadForTest::EnsureSharedBackingThread(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 ~ThreadedWorkletMessagingProxyForTest() override { | 101 ~ThreadedWorkletMessagingProxyForTest() override { |
| 102 worker_thread_->GetWorkerLoaderProxy()->DetachProvider( | 102 worker_thread_->GetWorkerLoaderProxy()->DetachProvider( |
| 103 mock_worker_loader_proxy_provider_.get()); | 103 worker_loader_proxy_provider_.get()); |
| 104 worker_thread_->TerminateAndWait(); | 104 worker_thread_->TerminateAndWait(); |
| 105 ThreadedWorkletThreadForTest::ClearSharedBackingThread(); | 105 ThreadedWorkletThreadForTest::ClearSharedBackingThread(); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 void Start() { | 108 void Start() { |
| 109 KURL script_url(kParsedURLString, "http://fake.url/"); | 109 KURL script_url(kParsedURLString, "http://fake.url/"); |
| 110 std::unique_ptr<Vector<char>> cached_meta_data = nullptr; | 110 std::unique_ptr<Vector<char>> cached_meta_data = nullptr; |
| 111 Vector<CSPHeaderAndType> content_security_policy_headers; | 111 Vector<CSPHeaderAndType> content_security_policy_headers; |
| 112 String referrer_policy = ""; | 112 String referrer_policy = ""; |
| 113 security_origin_ = SecurityOrigin::Create(script_url); | 113 security_origin_ = SecurityOrigin::Create(script_url); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 129 | 129 |
| 130 protected: | 130 protected: |
| 131 std::unique_ptr<WorkerThread> CreateWorkerThread(double origin_time) final { | 131 std::unique_ptr<WorkerThread> CreateWorkerThread(double origin_time) final { |
| 132 NOTREACHED(); | 132 NOTREACHED(); |
| 133 return nullptr; | 133 return nullptr; |
| 134 } | 134 } |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 friend class ThreadedWorkletTest; | 137 friend class ThreadedWorkletTest; |
| 138 | 138 |
| 139 std::unique_ptr<MockWorkerLoaderProxyProvider> | 139 std::unique_ptr<WorkerLoaderProxyProvider> worker_loader_proxy_provider_; |
| 140 mock_worker_loader_proxy_provider_; | |
| 141 RefPtr<SecurityOrigin> security_origin_; | 140 RefPtr<SecurityOrigin> security_origin_; |
| 142 }; | 141 }; |
| 143 | 142 |
| 144 class ThreadedWorkletTest : public ::testing::Test { | 143 class ThreadedWorkletTest : public ::testing::Test { |
| 145 public: | 144 public: |
| 146 void SetUp() override { | 145 void SetUp() override { |
| 147 page_ = DummyPageHolder::Create(); | 146 page_ = DummyPageHolder::Create(); |
| 148 messaging_proxy_ = WTF::MakeUnique<ThreadedWorkletMessagingProxyForTest>( | 147 messaging_proxy_ = WTF::MakeUnique<ThreadedWorkletMessagingProxyForTest>( |
| 149 &page_->GetDocument()); | 148 &page_->GetDocument()); |
| 150 } | 149 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, GetWorkerThread()) | 191 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, GetWorkerThread()) |
| 193 ->PostTask( | 192 ->PostTask( |
| 194 BLINK_FROM_HERE, | 193 BLINK_FROM_HERE, |
| 195 CrossThreadBind(&ThreadedWorkletThreadForTest::CountDeprecation, | 194 CrossThreadBind(&ThreadedWorkletThreadForTest::CountDeprecation, |
| 196 CrossThreadUnretained(GetWorkerThread()), kFeature2)); | 195 CrossThreadUnretained(GetWorkerThread()), kFeature2)); |
| 197 testing::EnterRunLoop(); | 196 testing::EnterRunLoop(); |
| 198 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature2)); | 197 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature2)); |
| 199 } | 198 } |
| 200 | 199 |
| 201 } // namespace blink | 200 } // namespace blink |
| OLD | NEW |