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/events/MessageEvent.h" | 5 #include "core/events/MessageEvent.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/DedicatedWorkerGlobalScope.h" | 8 #include "core/workers/DedicatedWorkerGlobalScope.h" |
9 #include "core/workers/DedicatedWorkerThread.h" | 9 #include "core/workers/DedicatedWorkerThread.h" |
10 #include "core/workers/InProcessWorkerMessagingProxy.h" | 10 #include "core/workers/InProcessWorkerMessagingProxy.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 return new DedicatedWorkerGlobalScope( | 51 return new DedicatedWorkerGlobalScope( |
52 startupData->m_scriptURL, startupData->m_userAgent, this, m_timeOrigin, | 52 startupData->m_scriptURL, startupData->m_userAgent, this, m_timeOrigin, |
53 std::move(startupData->m_starterOriginPrivilegeData), | 53 std::move(startupData->m_starterOriginPrivilegeData), |
54 std::move(startupData->m_workerClients)); | 54 std::move(startupData->m_workerClients)); |
55 } | 55 } |
56 | 56 |
57 // Emulates API use on DedicatedWorkerGlobalScope. | 57 // Emulates API use on DedicatedWorkerGlobalScope. |
58 void countFeature(UseCounter::Feature feature) { | 58 void countFeature(UseCounter::Feature feature) { |
59 EXPECT_TRUE(isCurrentThread()); | 59 EXPECT_TRUE(isCurrentThread()); |
60 globalScope()->countFeature(feature); | 60 globalScope()->countFeature(feature); |
61 getParentFrameTaskRunners() | 61 FrameTaskRunnerHelper::get(TaskType::UnspecedTimer, globalScope()) |
62 ->get(TaskType::UnspecedTimer) | |
63 ->postTask(BLINK_FROM_HERE, crossThreadBind(&testing::exitRunLoop)); | 62 ->postTask(BLINK_FROM_HERE, crossThreadBind(&testing::exitRunLoop)); |
64 } | 63 } |
65 | 64 |
66 // Emulates deprecated API use on DedicatedWorkerGlobalScope. | 65 // Emulates deprecated API use on DedicatedWorkerGlobalScope. |
67 void countDeprecation(UseCounter::Feature feature) { | 66 void countDeprecation(UseCounter::Feature feature) { |
68 EXPECT_TRUE(isCurrentThread()); | 67 EXPECT_TRUE(isCurrentThread()); |
69 EXPECT_EQ(0u, consoleMessageStorage()->size()); | 68 EXPECT_EQ(0u, consoleMessageStorage()->size()); |
70 globalScope()->countDeprecation(feature); | 69 globalScope()->countDeprecation(feature); |
71 | 70 |
72 // countDeprecation() should add a warning message. | 71 // countDeprecation() should add a warning message. |
73 EXPECT_EQ(1u, consoleMessageStorage()->size()); | 72 EXPECT_EQ(1u, consoleMessageStorage()->size()); |
74 String consoleMessage = consoleMessageStorage()->at(0)->message(); | 73 String consoleMessage = consoleMessageStorage()->at(0)->message(); |
75 EXPECT_TRUE(consoleMessage.contains("deprecated")); | 74 EXPECT_TRUE(consoleMessage.contains("deprecated")); |
76 | 75 |
77 getParentFrameTaskRunners() | 76 FrameTaskRunnerHelper::get(TaskType::UnspecedTimer, globalScope()) |
78 ->get(TaskType::UnspecedTimer) | |
79 ->postTask(BLINK_FROM_HERE, crossThreadBind(&testing::exitRunLoop)); | 77 ->postTask(BLINK_FROM_HERE, crossThreadBind(&testing::exitRunLoop)); |
80 } | 78 } |
81 }; | 79 }; |
82 | 80 |
83 class InProcessWorkerMessagingProxyForTest | 81 class InProcessWorkerMessagingProxyForTest |
84 : public InProcessWorkerMessagingProxy { | 82 : public InProcessWorkerMessagingProxy { |
85 public: | 83 public: |
86 InProcessWorkerMessagingProxyForTest(ExecutionContext* executionContext) | 84 InProcessWorkerMessagingProxyForTest(ExecutionContext* executionContext) |
87 : InProcessWorkerMessagingProxy(executionContext, | 85 : InProcessWorkerMessagingProxy(executionContext, |
88 nullptr /* workerObject */, | 86 nullptr /* workerObject */, |
(...skipping 28 matching lines...) Expand all Loading... |
117 ContentSecurityPolicyHeaderTypeReport); | 115 ContentSecurityPolicyHeaderTypeReport); |
118 headers->push_back(headerAndType); | 116 headers->push_back(headerAndType); |
119 workerThread()->start( | 117 workerThread()->start( |
120 WorkerThreadStartupData::create( | 118 WorkerThreadStartupData::create( |
121 scriptURL, "fake user agent", source, nullptr /* cachedMetaData */, | 119 scriptURL, "fake user agent", source, nullptr /* cachedMetaData */, |
122 DontPauseWorkerGlobalScopeOnStart, headers.get(), | 120 DontPauseWorkerGlobalScopeOnStart, headers.get(), |
123 "" /* referrerPolicy */, m_securityOrigin.get(), | 121 "" /* referrerPolicy */, m_securityOrigin.get(), |
124 nullptr /* workerClients */, WebAddressSpaceLocal, | 122 nullptr /* workerClients */, WebAddressSpaceLocal, |
125 nullptr /* originTrialTokens */, nullptr /* workerSettings */, | 123 nullptr /* originTrialTokens */, nullptr /* workerSettings */, |
126 WorkerV8Settings::Default()), | 124 WorkerV8Settings::Default()), |
127 getParentFrameTaskRunners()); | 125 FrameTaskRunnersHolder::create( |
| 126 toDocument(getExecutionContext())->frame())); |
128 | 127 |
129 workerInspectorProxy()->workerThreadCreated( | 128 workerInspectorProxy()->workerThreadCreated( |
130 toDocument(getExecutionContext()), m_workerThread.get(), scriptURL); | 129 toDocument(getExecutionContext()), m_workerThread.get(), scriptURL); |
131 workerThreadCreated(); | 130 workerThreadCreated(); |
132 } | 131 } |
133 | 132 |
134 enum class Notification { | 133 enum class Notification { |
135 MessageConfirmed, | 134 MessageConfirmed, |
136 PendingActivityReported, | 135 PendingActivityReported, |
137 ThreadTerminated, | 136 ThreadTerminated, |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 EXPECT_FALSE(UseCounter::isCounted(document(), feature2)); | 398 EXPECT_FALSE(UseCounter::isCounted(document(), feature2)); |
400 workerThread()->postTask( | 399 workerThread()->postTask( |
401 BLINK_FROM_HERE, | 400 BLINK_FROM_HERE, |
402 crossThreadBind(&DedicatedWorkerThreadForTest::countDeprecation, | 401 crossThreadBind(&DedicatedWorkerThreadForTest::countDeprecation, |
403 crossThreadUnretained(workerThread()), feature2)); | 402 crossThreadUnretained(workerThread()), feature2)); |
404 testing::enterRunLoop(); | 403 testing::enterRunLoop(); |
405 EXPECT_TRUE(UseCounter::isCounted(document(), feature2)); | 404 EXPECT_TRUE(UseCounter::isCounted(document(), feature2)); |
406 } | 405 } |
407 | 406 |
408 } // namespace blink | 407 } // namespace blink |
OLD | NEW |