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 "config.h" | 5 #include "config.h" |
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" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 class NotReachedWebServiceWorkerProvider : public WebServiceWorkerProvider { | 124 class NotReachedWebServiceWorkerProvider : public WebServiceWorkerProvider { |
125 public: | 125 public: |
126 virtual ~NotReachedWebServiceWorkerProvider() OVERRIDE { } | 126 virtual ~NotReachedWebServiceWorkerProvider() OVERRIDE { } |
127 | 127 |
128 virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scri
ptURL, WebServiceWorkerRegistrationCallbacks* callbacks) OVERRIDE | 128 virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scri
ptURL, WebServiceWorkerRegistrationCallbacks* callbacks) OVERRIDE |
129 { | 129 { |
130 ADD_FAILURE() << "the provider should not be called to register a Servic
e Worker"; | 130 ADD_FAILURE() << "the provider should not be called to register a Servic
e Worker"; |
131 delete callbacks; | 131 delete callbacks; |
132 } | 132 } |
133 | 133 |
134 virtual void unregisterServiceWorker(const WebURL& pattern, WebServiceWorker
RegistrationCallbacks* callbacks) OVERRIDE | 134 virtual void unregisterServiceWorker(const WebURL& pattern, WebServiceWorker
UnregistrationCallbacks* callbacks) OVERRIDE |
135 { | 135 { |
136 ADD_FAILURE() << "the provider should not be called to unregister a Serv
ice Worker"; | 136 ADD_FAILURE() << "the provider should not be called to unregister a Serv
ice Worker"; |
137 delete callbacks; | 137 delete callbacks; |
138 } | 138 } |
139 }; | 139 }; |
140 | 140 |
141 class ServiceWorkerContainerTest : public ::testing::Test { | 141 class ServiceWorkerContainerTest : public ::testing::Test { |
142 protected: | 142 protected: |
143 ServiceWorkerContainerTest() | 143 ServiceWorkerContainerTest() |
144 : m_page(DummyPageHolder::create()) | 144 : m_page(DummyPageHolder::create()) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 { | 277 { |
278 } | 278 } |
279 | 279 |
280 virtual ~WebServiceWorkerProviderImpl() OVERRIDE { } | 280 virtual ~WebServiceWorkerProviderImpl() OVERRIDE { } |
281 | 281 |
282 virtual void registerServiceWorker(const WebURL& pattern, const WebURL&
scriptURL, WebServiceWorkerRegistrationCallbacks* callbacks) OVERRIDE | 282 virtual void registerServiceWorker(const WebURL& pattern, const WebURL&
scriptURL, WebServiceWorkerRegistrationCallbacks* callbacks) OVERRIDE |
283 { | 283 { |
284 m_owner.m_registerCallCount++; | 284 m_owner.m_registerCallCount++; |
285 m_owner.m_registerScope = pattern; | 285 m_owner.m_registerScope = pattern; |
286 m_owner.m_registerScriptURL = scriptURL; | 286 m_owner.m_registerScriptURL = scriptURL; |
287 m_callbacksToDelete.append(adoptPtr(callbacks)); | 287 m_registrationCallbacksToDelete.append(adoptPtr(callbacks)); |
288 } | 288 } |
289 | 289 |
290 virtual void unregisterServiceWorker(const WebURL& pattern, WebServiceWo
rkerRegistrationCallbacks* callbacks) OVERRIDE | 290 virtual void unregisterServiceWorker(const WebURL& pattern, WebServiceWo
rkerUnregistrationCallbacks* callbacks) OVERRIDE |
291 { | 291 { |
292 m_owner.m_unregisterCallCount++; | 292 m_owner.m_unregisterCallCount++; |
293 m_owner.m_unregisterScope = pattern; | 293 m_owner.m_unregisterScope = pattern; |
294 m_callbacksToDelete.append(adoptPtr(callbacks)); | 294 m_unregistrationCallbacksToDelete.append(adoptPtr(callbacks)); |
295 } | 295 } |
296 | 296 |
297 private: | 297 private: |
298 StubWebServiceWorkerProvider& m_owner; | 298 StubWebServiceWorkerProvider& m_owner; |
299 Vector<OwnPtr<WebServiceWorkerRegistrationCallbacks> > m_callbacksToDele
te; | 299 Vector<OwnPtr<WebServiceWorkerRegistrationCallbacks> > m_registrationCal
lbacksToDelete; |
| 300 Vector<OwnPtr<WebServiceWorkerUnregistrationCallbacks> > m_unregistratio
nCallbacksToDelete; |
300 }; | 301 }; |
301 | 302 |
302 private: | 303 private: |
303 size_t m_registerCallCount; | 304 size_t m_registerCallCount; |
304 WebURL m_registerScope; | 305 WebURL m_registerScope; |
305 WebURL m_registerScriptURL; | 306 WebURL m_registerScriptURL; |
306 size_t m_unregisterCallCount; | 307 size_t m_unregisterCallCount; |
307 WebURL m_unregisterScope; | 308 WebURL m_unregisterScope; |
308 }; | 309 }; |
309 | 310 |
(...skipping 25 matching lines...) Expand all Loading... |
335 | 336 |
336 EXPECT_EQ(1ul, stubProvider.unregisterCallCount()); | 337 EXPECT_EQ(1ul, stubProvider.unregisterCallCount()); |
337 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/")), stubProvider.un
registerScope()); | 338 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/")), stubProvider.un
registerScope()); |
338 } | 339 } |
339 | 340 |
340 container->willBeDetachedFromFrame(); | 341 container->willBeDetachedFromFrame(); |
341 } | 342 } |
342 | 343 |
343 } // namespace | 344 } // namespace |
344 } // namespace blink | 345 } // namespace blink |
OLD | NEW |