OLD | NEW |
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" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 170 } |
171 | 171 |
172 void testRegisterRejected(const String& scriptURL, | 172 void testRegisterRejected(const String& scriptURL, |
173 const String& scope, | 173 const String& scope, |
174 const ScriptValueTest& valueTest) { | 174 const ScriptValueTest& valueTest) { |
175 // When the registration is rejected, a register call must not reach | 175 // When the registration is rejected, a register call must not reach |
176 // the provider. | 176 // the provider. |
177 provide(WTF::makeUnique<NotReachedWebServiceWorkerProvider>()); | 177 provide(WTF::makeUnique<NotReachedWebServiceWorkerProvider>()); |
178 | 178 |
179 ServiceWorkerContainer* container = | 179 ServiceWorkerContainer* container = |
180 ServiceWorkerContainer::create(getExecutionContext()); | 180 ServiceWorkerContainer::create(getExecutionContext(), nullptr); |
181 ScriptState::Scope scriptScope(getScriptState()); | 181 ScriptState::Scope scriptScope(getScriptState()); |
182 RegistrationOptions options; | 182 RegistrationOptions options; |
183 options.setScope(scope); | 183 options.setScope(scope); |
184 ScriptPromise promise = | 184 ScriptPromise promise = |
185 container->registerServiceWorker(getScriptState(), scriptURL, options); | 185 container->registerServiceWorker(getScriptState(), scriptURL, options); |
186 expectRejected(getScriptState(), promise, valueTest); | 186 expectRejected(getScriptState(), promise, valueTest); |
187 } | 187 } |
188 | 188 |
189 void testGetRegistrationRejected(const String& documentURL, | 189 void testGetRegistrationRejected(const String& documentURL, |
190 const ScriptValueTest& valueTest) { | 190 const ScriptValueTest& valueTest) { |
191 provide(WTF::makeUnique<NotReachedWebServiceWorkerProvider>()); | 191 provide(WTF::makeUnique<NotReachedWebServiceWorkerProvider>()); |
192 | 192 |
193 ServiceWorkerContainer* container = | 193 ServiceWorkerContainer* container = |
194 ServiceWorkerContainer::create(getExecutionContext()); | 194 ServiceWorkerContainer::create(getExecutionContext(), nullptr); |
195 ScriptState::Scope scriptScope(getScriptState()); | 195 ScriptState::Scope scriptScope(getScriptState()); |
196 ScriptPromise promise = | 196 ScriptPromise promise = |
197 container->getRegistration(getScriptState(), documentURL); | 197 container->getRegistration(getScriptState(), documentURL); |
198 expectRejected(getScriptState(), promise, valueTest); | 198 expectRejected(getScriptState(), promise, valueTest); |
199 } | 199 } |
200 | 200 |
201 private: | 201 private: |
202 std::unique_ptr<DummyPageHolder> m_page; | 202 std::unique_ptr<DummyPageHolder> m_page; |
203 }; | 203 }; |
204 | 204 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 }; | 325 }; |
326 | 326 |
327 TEST_F(ServiceWorkerContainerTest, | 327 TEST_F(ServiceWorkerContainerTest, |
328 RegisterUnregister_NonHttpsSecureOriginDelegatesToProvider) { | 328 RegisterUnregister_NonHttpsSecureOriginDelegatesToProvider) { |
329 setPageURL("http://localhost/x/index.html"); | 329 setPageURL("http://localhost/x/index.html"); |
330 | 330 |
331 StubWebServiceWorkerProvider stubProvider; | 331 StubWebServiceWorkerProvider stubProvider; |
332 provide(stubProvider.provider()); | 332 provide(stubProvider.provider()); |
333 | 333 |
334 ServiceWorkerContainer* container = | 334 ServiceWorkerContainer* container = |
335 ServiceWorkerContainer::create(getExecutionContext()); | 335 ServiceWorkerContainer::create(getExecutionContext(), nullptr); |
336 | 336 |
337 // register | 337 // register |
338 { | 338 { |
339 ScriptState::Scope scriptScope(getScriptState()); | 339 ScriptState::Scope scriptScope(getScriptState()); |
340 RegistrationOptions options; | 340 RegistrationOptions options; |
341 options.setScope("y/"); | 341 options.setScope("y/"); |
342 container->registerServiceWorker(getScriptState(), "/x/y/worker.js", | 342 container->registerServiceWorker(getScriptState(), "/x/y/worker.js", |
343 options); | 343 options); |
344 | 344 |
345 EXPECT_EQ(1ul, stubProvider.registerCallCount()); | 345 EXPECT_EQ(1ul, stubProvider.registerCallCount()); |
346 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/")), | 346 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/")), |
347 stubProvider.registerScope()); | 347 stubProvider.registerScope()); |
348 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/worker.js")), | 348 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/worker.js")), |
349 stubProvider.registerScriptURL()); | 349 stubProvider.registerScriptURL()); |
350 } | 350 } |
351 } | 351 } |
352 | 352 |
353 TEST_F(ServiceWorkerContainerTest, | 353 TEST_F(ServiceWorkerContainerTest, |
354 GetRegistration_OmittedDocumentURLDefaultsToPageURL) { | 354 GetRegistration_OmittedDocumentURLDefaultsToPageURL) { |
355 setPageURL("http://localhost/x/index.html"); | 355 setPageURL("http://localhost/x/index.html"); |
356 | 356 |
357 StubWebServiceWorkerProvider stubProvider; | 357 StubWebServiceWorkerProvider stubProvider; |
358 provide(stubProvider.provider()); | 358 provide(stubProvider.provider()); |
359 | 359 |
360 ServiceWorkerContainer* container = | 360 ServiceWorkerContainer* container = |
361 ServiceWorkerContainer::create(getExecutionContext()); | 361 ServiceWorkerContainer::create(getExecutionContext(), nullptr); |
362 | 362 |
363 { | 363 { |
364 ScriptState::Scope scriptScope(getScriptState()); | 364 ScriptState::Scope scriptScope(getScriptState()); |
365 container->getRegistration(getScriptState(), ""); | 365 container->getRegistration(getScriptState(), ""); |
366 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); | 366 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); |
367 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), | 367 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), |
368 stubProvider.getRegistrationURL()); | 368 stubProvider.getRegistrationURL()); |
369 } | 369 } |
370 } | 370 } |
371 | 371 |
372 } // namespace | 372 } // namespace |
373 } // namespace blink | 373 } // namespace blink |
OLD | NEW |