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