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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 170 } |
171 | 171 |
172 void testRegisterRejected(const String& scriptURL, const String& scope, cons
t ScriptValueTest& valueTest) | 172 void testRegisterRejected(const String& scriptURL, const String& scope, cons
t ScriptValueTest& valueTest) |
173 { | 173 { |
174 // When the registration is rejected, a register call must not reach | 174 // When the registration is rejected, a register call must not reach |
175 // the provider. | 175 // the provider. |
176 provide(adoptPtr(new NotReachedWebServiceWorkerProvider())); | 176 provide(adoptPtr(new NotReachedWebServiceWorkerProvider())); |
177 | 177 |
178 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execu
tionContext()); | 178 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execu
tionContext()); |
179 ScriptState::Scope scriptScope(scriptState()); | 179 ScriptState::Scope scriptScope(scriptState()); |
180 RegistrationOptions* options = RegistrationOptions::create(); | 180 RegistrationOptions options; |
181 options->setScope(scope); | 181 options.setScope(scope); |
182 ScriptPromise promise = container->registerServiceWorker(scriptState(),
scriptURL, *options); | 182 ScriptPromise promise = container->registerServiceWorker(scriptState(),
scriptURL, options); |
183 expectRejected(scriptState(), promise, valueTest); | 183 expectRejected(scriptState(), promise, valueTest); |
184 | 184 |
185 container->willBeDetachedFromFrame(); | 185 container->willBeDetachedFromFrame(); |
186 } | 186 } |
187 | 187 |
188 void testGetRegistrationRejected(const String& documentURL, const ScriptValu
eTest& valueTest) | 188 void testGetRegistrationRejected(const String& documentURL, const ScriptValu
eTest& valueTest) |
189 { | 189 { |
190 provide(adoptPtr(new NotReachedWebServiceWorkerProvider())); | 190 provide(adoptPtr(new NotReachedWebServiceWorkerProvider())); |
191 | 191 |
192 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execu
tionContext()); | 192 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execu
tionContext()); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 setPageURL("http://localhost/x/index.html"); | 311 setPageURL("http://localhost/x/index.html"); |
312 | 312 |
313 StubWebServiceWorkerProvider stubProvider; | 313 StubWebServiceWorkerProvider stubProvider; |
314 provide(stubProvider.provider()); | 314 provide(stubProvider.provider()); |
315 | 315 |
316 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execution
Context()); | 316 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execution
Context()); |
317 | 317 |
318 // register | 318 // register |
319 { | 319 { |
320 ScriptState::Scope scriptScope(scriptState()); | 320 ScriptState::Scope scriptScope(scriptState()); |
321 RegistrationOptions* options = RegistrationOptions::create(); | 321 RegistrationOptions options; |
322 options->setScope("y/"); | 322 options.setScope("y/"); |
323 container->registerServiceWorker(scriptState(), "/z/worker.js", *options
); | 323 container->registerServiceWorker(scriptState(), "/z/worker.js", options)
; |
324 | 324 |
325 EXPECT_EQ(1ul, stubProvider.registerCallCount()); | 325 EXPECT_EQ(1ul, stubProvider.registerCallCount()); |
326 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/")), stubProvider.re
gisterScope()); | 326 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/")), stubProvider.re
gisterScope()); |
327 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/z/worker.js")), stubProv
ider.registerScriptURL()); | 327 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/z/worker.js")), stubProv
ider.registerScriptURL()); |
328 } | 328 } |
329 | 329 |
330 container->willBeDetachedFromFrame(); | 330 container->willBeDetachedFromFrame(); |
331 } | 331 } |
332 | 332 |
333 TEST_F(ServiceWorkerContainerTest, GetRegistration_OmittedDocumentURLDefaultsToP
ageURL) | 333 TEST_F(ServiceWorkerContainerTest, GetRegistration_OmittedDocumentURLDefaultsToP
ageURL) |
(...skipping 10 matching lines...) Expand all Loading... |
344 container->getRegistration(scriptState(), ""); | 344 container->getRegistration(scriptState(), ""); |
345 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); | 345 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); |
346 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); | 346 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); |
347 } | 347 } |
348 | 348 |
349 container->willBeDetachedFromFrame(); | 349 container->willBeDetachedFromFrame(); |
350 } | 350 } |
351 | 351 |
352 } // namespace | 352 } // namespace |
353 } // namespace blink | 353 } // namespace blink |
OLD | NEW |