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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 class NotReachedWebServiceWorkerProvider : public WebServiceWorkerProvider { | 130 class NotReachedWebServiceWorkerProvider : public WebServiceWorkerProvider { |
131 public: | 131 public: |
132 virtual ~NotReachedWebServiceWorkerProvider() OVERRIDE { } | 132 virtual ~NotReachedWebServiceWorkerProvider() OVERRIDE { } |
133 | 133 |
134 virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scri
ptURL, WebServiceWorkerRegistrationCallbacks* callbacks) OVERRIDE | 134 virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scri
ptURL, WebServiceWorkerRegistrationCallbacks* callbacks) OVERRIDE |
135 { | 135 { |
136 ADD_FAILURE() << "the provider should not be called to register a Servic
e Worker"; | 136 ADD_FAILURE() << "the provider should not be called to register a Servic
e Worker"; |
137 delete callbacks; | 137 delete callbacks; |
138 } | 138 } |
139 | 139 |
140 virtual void unregisterServiceWorker(const WebURL& pattern, WebServiceWorker
RegistrationCallbacks* callbacks) OVERRIDE | 140 virtual void unregisterServiceWorker(const WebURL& pattern, WebServiceWorker
UnregistrationCallbacks* callbacks) OVERRIDE |
141 { | 141 { |
142 ADD_FAILURE() << "the provider should not be called to unregister a Serv
ice Worker"; | 142 ADD_FAILURE() << "the provider should not be called to unregister a Serv
ice Worker"; |
143 delete callbacks; | 143 delete callbacks; |
144 } | 144 } |
145 }; | 145 }; |
146 | 146 |
147 class ServiceWorkerContainerTest : public ::testing::Test { | 147 class ServiceWorkerContainerTest : public ::testing::Test { |
148 protected: | 148 protected: |
149 ServiceWorkerContainerTest() | 149 ServiceWorkerContainerTest() |
150 : m_page(DummyPageHolder::create()) | 150 : m_page(DummyPageHolder::create()) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 { | 283 { |
284 } | 284 } |
285 | 285 |
286 virtual ~WebServiceWorkerProviderImpl() OVERRIDE { } | 286 virtual ~WebServiceWorkerProviderImpl() OVERRIDE { } |
287 | 287 |
288 virtual void registerServiceWorker(const WebURL& pattern, const WebURL&
scriptURL, WebServiceWorkerRegistrationCallbacks* callbacks) OVERRIDE | 288 virtual void registerServiceWorker(const WebURL& pattern, const WebURL&
scriptURL, WebServiceWorkerRegistrationCallbacks* callbacks) OVERRIDE |
289 { | 289 { |
290 m_owner.m_registerCallCount++; | 290 m_owner.m_registerCallCount++; |
291 m_owner.m_registerScope = pattern; | 291 m_owner.m_registerScope = pattern; |
292 m_owner.m_registerScriptURL = scriptURL; | 292 m_owner.m_registerScriptURL = scriptURL; |
293 m_callbacksToDelete.append(adoptPtr(callbacks)); | 293 m_registrationCallbacksToDelete.append(adoptPtr(callbacks)); |
294 } | 294 } |
295 | 295 |
296 virtual void unregisterServiceWorker(const WebURL& pattern, WebServiceWo
rkerRegistrationCallbacks* callbacks) OVERRIDE | 296 virtual void unregisterServiceWorker(const WebURL& pattern, WebServiceWo
rkerUnregistrationCallbacks* callbacks) OVERRIDE |
297 { | 297 { |
298 m_owner.m_unregisterCallCount++; | 298 m_owner.m_unregisterCallCount++; |
299 m_owner.m_unregisterScope = pattern; | 299 m_owner.m_unregisterScope = pattern; |
300 m_callbacksToDelete.append(adoptPtr(callbacks)); | 300 m_unregistrationCallbacksToDelete.append(adoptPtr(callbacks)); |
301 } | 301 } |
302 | 302 |
303 private: | 303 private: |
304 StubWebServiceWorkerProvider& m_owner; | 304 StubWebServiceWorkerProvider& m_owner; |
305 Vector<OwnPtr<WebServiceWorkerRegistrationCallbacks> > m_callbacksToDele
te; | 305 Vector<OwnPtr<WebServiceWorkerRegistrationCallbacks> > m_registrationCal
lbacksToDelete; |
| 306 Vector<OwnPtr<WebServiceWorkerUnregistrationCallbacks> > m_unregistratio
nCallbacksToDelete; |
306 }; | 307 }; |
307 | 308 |
308 private: | 309 private: |
309 size_t m_registerCallCount; | 310 size_t m_registerCallCount; |
310 WebURL m_registerScope; | 311 WebURL m_registerScope; |
311 WebURL m_registerScriptURL; | 312 WebURL m_registerScriptURL; |
312 size_t m_unregisterCallCount; | 313 size_t m_unregisterCallCount; |
313 WebURL m_unregisterScope; | 314 WebURL m_unregisterScope; |
314 }; | 315 }; |
315 | 316 |
(...skipping 25 matching lines...) Expand all Loading... |
341 | 342 |
342 EXPECT_EQ(1ul, stubProvider.unregisterCallCount()); | 343 EXPECT_EQ(1ul, stubProvider.unregisterCallCount()); |
343 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/")), stubProvider.un
registerScope()); | 344 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/")), stubProvider.un
registerScope()); |
344 } | 345 } |
345 | 346 |
346 container->willBeDetachedFromFrame(); | 347 container->willBeDetachedFromFrame(); |
347 } | 348 } |
348 | 349 |
349 } // namespace | 350 } // namespace |
350 } // namespace blink | 351 } // namespace blink |
OLD | NEW |