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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
230 | 230 |
| 231 TEST_F(ServiceWorkerContainerTest, Register_DifferentDirectoryThanScript) |
| 232 { |
| 233 setPageURL("https://www.example.com/"); |
| 234 testRegisterRejected( |
| 235 "https://www.example.com/js/worker.js", |
| 236 "https://www.example.com/", |
| 237 ExpectDOMException("SecurityError", "The scope must be under the directo
ry of the script URL.")); |
| 238 } |
| 239 |
231 TEST_F(ServiceWorkerContainerTest, GetRegistration_NonSecureOriginIsRejected) | 240 TEST_F(ServiceWorkerContainerTest, GetRegistration_NonSecureOriginIsRejected) |
232 { | 241 { |
233 setPageURL("http://www.example.com/"); | 242 setPageURL("http://www.example.com/"); |
234 testGetRegistrationRejected( | 243 testGetRegistrationRejected( |
235 "http://www.example.com/", | 244 "http://www.example.com/", |
236 ExpectDOMException("NotSupportedError", "Only secure origins are allowed
. http://goo.gl/lq4gCo")); | 245 ExpectDOMException("NotSupportedError", "Only secure origins are allowed
. http://goo.gl/lq4gCo")); |
237 } | 246 } |
238 | 247 |
239 TEST_F(ServiceWorkerContainerTest, GetRegistration_CrossOriginURLIsRejected) | 248 TEST_F(ServiceWorkerContainerTest, GetRegistration_CrossOriginURLIsRejected) |
240 { | 249 { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 StubWebServiceWorkerProvider stubProvider; | 322 StubWebServiceWorkerProvider stubProvider; |
314 provide(stubProvider.provider()); | 323 provide(stubProvider.provider()); |
315 | 324 |
316 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execution
Context()); | 325 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execution
Context()); |
317 | 326 |
318 // register | 327 // register |
319 { | 328 { |
320 ScriptState::Scope scriptScope(scriptState()); | 329 ScriptState::Scope scriptScope(scriptState()); |
321 RegistrationOptions options; | 330 RegistrationOptions options; |
322 options.setScope("y/"); | 331 options.setScope("y/"); |
323 container->registerServiceWorker(scriptState(), "/z/worker.js", options)
; | 332 container->registerServiceWorker(scriptState(), "/x/y/worker.js", option
s); |
324 | 333 |
325 EXPECT_EQ(1ul, stubProvider.registerCallCount()); | 334 EXPECT_EQ(1ul, stubProvider.registerCallCount()); |
326 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/")), stubProvider.re
gisterScope()); | 335 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()); | 336 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/worker.js")), stubPr
ovider.registerScriptURL()); |
328 } | 337 } |
329 | 338 |
330 container->willBeDetachedFromFrame(); | 339 container->willBeDetachedFromFrame(); |
331 } | 340 } |
332 | 341 |
333 TEST_F(ServiceWorkerContainerTest, GetRegistration_OmittedDocumentURLDefaultsToP
ageURL) | 342 TEST_F(ServiceWorkerContainerTest, GetRegistration_OmittedDocumentURLDefaultsToP
ageURL) |
334 { | 343 { |
335 setPageURL("http://localhost/x/index.html"); | 344 setPageURL("http://localhost/x/index.html"); |
336 | 345 |
337 StubWebServiceWorkerProvider stubProvider; | 346 StubWebServiceWorkerProvider stubProvider; |
338 provide(stubProvider.provider()); | 347 provide(stubProvider.provider()); |
339 | 348 |
340 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execution
Context()); | 349 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execution
Context()); |
341 | 350 |
342 { | 351 { |
343 ScriptState::Scope scriptScope(scriptState()); | 352 ScriptState::Scope scriptScope(scriptState()); |
344 container->getRegistration(scriptState(), ""); | 353 container->getRegistration(scriptState(), ""); |
345 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); | 354 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); |
346 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); | 355 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); |
347 } | 356 } |
348 | 357 |
349 container->willBeDetachedFromFrame(); | 358 container->willBeDetachedFromFrame(); |
350 } | 359 } |
351 | 360 |
352 } // namespace | 361 } // namespace |
353 } // namespace blink | 362 } // namespace blink |
OLD | NEW |