Chromium Code Reviews| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 ExpectDOMException("SecurityError", "The origin of the script must match the current origin.")); | 219 ExpectDOMException("SecurityError", "The origin of the script must match the current origin.")); |
| 220 } | 220 } |
| 221 | 221 |
| 222 TEST_F(ServiceWorkerContainerTest, Register_CrossOriginScopeIsRejected) | 222 TEST_F(ServiceWorkerContainerTest, Register_CrossOriginScopeIsRejected) |
| 223 { | 223 { |
| 224 setPageURL("https://www.example.com"); | 224 setPageURL("https://www.example.com"); |
| 225 testRegisterRejected( | 225 testRegisterRejected( |
| 226 "https://www.example.com", | 226 "https://www.example.com", |
| 227 "wss://www.example.com/", // Differs by protocol | 227 "wss://www.example.com/", // Differs by protocol |
| 228 ExpectDOMException("SecurityError", "The scope must match the current or igin.")); | 228 ExpectDOMException("SecurityError", "The scope must match the current or igin.")); |
| 229 } | 229 } |
|
falken
2014/10/24 06:50:44
can you add a test here for Register failing due t
horo
2014/10/24 07:21:43
Done.
| |
| 230 | 230 |
| 231 TEST_F(ServiceWorkerContainerTest, GetRegistration_NonSecureOriginIsRejected) | 231 TEST_F(ServiceWorkerContainerTest, GetRegistration_NonSecureOriginIsRejected) |
| 232 { | 232 { |
| 233 setPageURL("http://www.example.com/"); | 233 setPageURL("http://www.example.com/"); |
| 234 testGetRegistrationRejected( | 234 testGetRegistrationRejected( |
| 235 "http://www.example.com/", | 235 "http://www.example.com/", |
| 236 ExpectDOMException("NotSupportedError", "Only secure origins are allowed . http://goo.gl/lq4gCo")); | 236 ExpectDOMException("NotSupportedError", "Only secure origins are allowed . http://goo.gl/lq4gCo")); |
| 237 } | 237 } |
| 238 | 238 |
| 239 TEST_F(ServiceWorkerContainerTest, GetRegistration_CrossOriginURLIsRejected) | 239 TEST_F(ServiceWorkerContainerTest, GetRegistration_CrossOriginURLIsRejected) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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; | 321 RegistrationOptions options; |
| 322 options.setScope("y/"); | 322 options.setScope("y/"); |
| 323 container->registerServiceWorker(scriptState(), "/z/worker.js", options) ; | 323 container->registerServiceWorker(scriptState(), "/x/y/worker.js", option s); |
| 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/x/y/worker.js")), stubPr ovider.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) |
| 334 { | 334 { |
| 335 setPageURL("http://localhost/x/index.html"); | 335 setPageURL("http://localhost/x/index.html"); |
| 336 | 336 |
| 337 StubWebServiceWorkerProvider stubProvider; | 337 StubWebServiceWorkerProvider stubProvider; |
| 338 provide(stubProvider.provider()); | 338 provide(stubProvider.provider()); |
| 339 | 339 |
| 340 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execution Context()); | 340 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execution Context()); |
| 341 | 341 |
| 342 { | 342 { |
| 343 ScriptState::Scope scriptScope(scriptState()); | 343 ScriptState::Scope scriptScope(scriptState()); |
| 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 |