Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1139)

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Make changes requested by danakj, fix a few more headers Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Copyright 2014 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 #include "modules/serviceworkers/ServiceWorkerContainer.h" 6 #include "modules/serviceworkers/ServiceWorkerContainer.h"
7 7
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "bindings/core/v8/ScriptFunction.h" 9 #include "bindings/core/v8/ScriptFunction.h"
10 #include "bindings/core/v8/ScriptPromise.h" 10 #include "bindings/core/v8/ScriptPromise.h"
11 #include "bindings/core/v8/ScriptState.h" 11 #include "bindings/core/v8/ScriptState.h"
12 #include "bindings/core/v8/V8DOMException.h" 12 #include "bindings/core/v8/V8DOMException.h"
13 #include "bindings/core/v8/V8GCController.h" 13 #include "bindings/core/v8/V8GCController.h"
14 #include "core/dom/DOMException.h" 14 #include "core/dom/DOMException.h"
15 #include "core/dom/Document.h" 15 #include "core/dom/Document.h"
16 #include "core/dom/ExecutionContext.h" 16 #include "core/dom/ExecutionContext.h"
17 #include "core/page/FocusController.h" 17 #include "core/page/FocusController.h"
18 #include "core/testing/DummyPageHolder.h" 18 #include "core/testing/DummyPageHolder.h"
19 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 19 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
20 #include "platform/weborigin/KURL.h" 20 #include "platform/weborigin/KURL.h"
21 #include "platform/weborigin/SecurityOrigin.h" 21 #include "platform/weborigin/SecurityOrigin.h"
22 #include "public/platform/WebURL.h" 22 #include "public/platform/WebURL.h"
23 #include "public/platform/modules/serviceworker/WebServiceWorkerClientsInfo.h" 23 #include "public/platform/modules/serviceworker/WebServiceWorkerClientsInfo.h"
24 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" 24 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 #include "wtf/PtrUtil.h" 26 #include "wtf/PtrUtil.h"
27 #include "wtf/text/WTFString.h" 27 #include "wtf/text/WTFString.h"
28 #include <memory> 28 #include <memory>
29 #include <utility>
29 #include <v8.h> 30 #include <v8.h>
30 31
31 namespace blink { 32 namespace blink {
32 namespace { 33 namespace {
33 34
34 // Promise-related test support. 35 // Promise-related test support.
35 36
36 struct StubScriptFunction { 37 struct StubScriptFunction {
37 public: 38 public:
38 StubScriptFunction() : m_callCount(0) {} 39 StubScriptFunction() : m_callCount(0) {}
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 120
120 // Service Worker-specific tests. 121 // Service Worker-specific tests.
121 122
122 class NotReachedWebServiceWorkerProvider : public WebServiceWorkerProvider { 123 class NotReachedWebServiceWorkerProvider : public WebServiceWorkerProvider {
123 public: 124 public:
124 ~NotReachedWebServiceWorkerProvider() override {} 125 ~NotReachedWebServiceWorkerProvider() override {}
125 126
126 void registerServiceWorker( 127 void registerServiceWorker(
127 const WebURL& pattern, 128 const WebURL& pattern,
128 const WebURL& scriptURL, 129 const WebURL& scriptURL,
129 WebServiceWorkerRegistrationCallbacks* callbacks) override { 130 std::unique_ptr<WebServiceWorkerRegistrationCallbacks> callbacks)
131 override {
130 ADD_FAILURE() 132 ADD_FAILURE()
131 << "the provider should not be called to register a Service Worker"; 133 << "the provider should not be called to register a Service Worker";
132 delete callbacks;
133 } 134 }
134 135
135 bool validateScopeAndScriptURL(const WebURL& scope, 136 bool validateScopeAndScriptURL(const WebURL& scope,
136 const WebURL& scriptURL, 137 const WebURL& scriptURL,
137 WebString* errorMessage) { 138 WebString* errorMessage) {
138 return true; 139 return true;
139 } 140 }
140 }; 141 };
141 142
142 class ServiceWorkerContainerTest : public ::testing::Test { 143 class ServiceWorkerContainerTest : public ::testing::Test {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 class WebServiceWorkerProviderImpl : public WebServiceWorkerProvider { 278 class WebServiceWorkerProviderImpl : public WebServiceWorkerProvider {
278 public: 279 public:
279 WebServiceWorkerProviderImpl(StubWebServiceWorkerProvider& owner) 280 WebServiceWorkerProviderImpl(StubWebServiceWorkerProvider& owner)
280 : m_owner(owner) {} 281 : m_owner(owner) {}
281 282
282 ~WebServiceWorkerProviderImpl() override {} 283 ~WebServiceWorkerProviderImpl() override {}
283 284
284 void registerServiceWorker( 285 void registerServiceWorker(
285 const WebURL& pattern, 286 const WebURL& pattern,
286 const WebURL& scriptURL, 287 const WebURL& scriptURL,
287 WebServiceWorkerRegistrationCallbacks* callbacks) override { 288 std::unique_ptr<WebServiceWorkerRegistrationCallbacks> callbacks)
289 override {
288 m_owner.m_registerCallCount++; 290 m_owner.m_registerCallCount++;
289 m_owner.m_registerScope = pattern; 291 m_owner.m_registerScope = pattern;
290 m_owner.m_registerScriptURL = scriptURL; 292 m_owner.m_registerScriptURL = scriptURL;
291 m_registrationCallbacksToDelete.append(wrapUnique(callbacks)); 293 m_registrationCallbacksToDelete.append(std::move(callbacks));
292 } 294 }
293 295
294 void getRegistration( 296 void getRegistration(
295 const WebURL& documentURL, 297 const WebURL& documentURL,
296 WebServiceWorkerGetRegistrationCallbacks* callbacks) override { 298 std::unique_ptr<WebServiceWorkerGetRegistrationCallbacks> callbacks)
299 override {
297 m_owner.m_getRegistrationCallCount++; 300 m_owner.m_getRegistrationCallCount++;
298 m_owner.m_getRegistrationURL = documentURL; 301 m_owner.m_getRegistrationURL = documentURL;
299 m_getRegistrationCallbacksToDelete.append(wrapUnique(callbacks)); 302 m_getRegistrationCallbacksToDelete.append(std::move(callbacks));
300 } 303 }
301 304
302 bool validateScopeAndScriptURL(const WebURL& scope, 305 bool validateScopeAndScriptURL(const WebURL& scope,
303 const WebURL& scriptURL, 306 const WebURL& scriptURL,
304 WebString* errorMessage) { 307 WebString* errorMessage) {
305 return true; 308 return true;
306 } 309 }
307 310
308 private: 311 private:
309 StubWebServiceWorkerProvider& m_owner; 312 StubWebServiceWorkerProvider& m_owner;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 ScriptState::Scope scriptScope(getScriptState()); 364 ScriptState::Scope scriptScope(getScriptState());
362 container->getRegistration(getScriptState(), ""); 365 container->getRegistration(getScriptState(), "");
363 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); 366 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount());
364 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), 367 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")),
365 stubProvider.getRegistrationURL()); 368 stubProvider.getRegistrationURL());
366 } 369 }
367 } 370 }
368 371
369 } // namespace 372 } // namespace
370 } // namespace blink 373 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698