| 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 "config.h" | 6 #include "config.h" |
| 7 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 7 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
| 8 | 8 |
| 9 #include "bindings/core/v8/Dictionary.h" | 9 #include "bindings/core/v8/Dictionary.h" |
| 10 #include "bindings/core/v8/ScriptFunction.h" | 10 #include "bindings/core/v8/ScriptFunction.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 private: | 208 private: |
| 209 OwnPtr<DummyPageHolder> m_page; | 209 OwnPtr<DummyPageHolder> m_page; |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 TEST_F(ServiceWorkerContainerTest, Register_NonSecureOriginIsRejected) | 212 TEST_F(ServiceWorkerContainerTest, Register_NonSecureOriginIsRejected) |
| 213 { | 213 { |
| 214 setPageURL("http://www.example.com/"); | 214 setPageURL("http://www.example.com/"); |
| 215 testRegisterRejected( | 215 testRegisterRejected( |
| 216 "http://www.example.com/worker.js", | 216 "http://www.example.com/worker.js", |
| 217 "http://www.example.com/", | 217 "http://www.example.com/", |
| 218 ExpectDOMException("NotSupportedError", "Only secure origins are allowed
(see: https://goo.gl/Y0ZkNV).")); | 218 ExpectDOMException("SecurityError", "Only secure origins are allowed (se
e: https://goo.gl/Y0ZkNV).")); |
| 219 } | 219 } |
| 220 | 220 |
| 221 TEST_F(ServiceWorkerContainerTest, Register_CrossOriginScriptIsRejected) | 221 TEST_F(ServiceWorkerContainerTest, Register_CrossOriginScriptIsRejected) |
| 222 { | 222 { |
| 223 setPageURL("https://www.example.com"); | 223 setPageURL("https://www.example.com"); |
| 224 testRegisterRejected( | 224 testRegisterRejected( |
| 225 "https://www.example.com:8080/", // Differs by port | 225 "https://www.example.com:8080/", // Differs by port |
| 226 "https://www.example.com/", | 226 "https://www.example.com/", |
| 227 ExpectDOMException("SecurityError", "Failed to register a ServiceWorker:
The origin of the provided scriptURL ('https://www.example.com:8080') does not
match the current origin ('https://www.example.com').")); | 227 ExpectDOMException("SecurityError", "Failed to register a ServiceWorker:
The origin of the provided scriptURL ('https://www.example.com:8080') does not
match the current origin ('https://www.example.com').")); |
| 228 } | 228 } |
| 229 | 229 |
| 230 TEST_F(ServiceWorkerContainerTest, Register_CrossOriginScopeIsRejected) | 230 TEST_F(ServiceWorkerContainerTest, Register_CrossOriginScopeIsRejected) |
| 231 { | 231 { |
| 232 setPageURL("https://www.example.com"); | 232 setPageURL("https://www.example.com"); |
| 233 testRegisterRejected( | 233 testRegisterRejected( |
| 234 "https://www.example.com", | 234 "https://www.example.com", |
| 235 "wss://www.example.com/", // Differs by protocol | 235 "wss://www.example.com/", // Differs by protocol |
| 236 ExpectDOMException("SecurityError", "Failed to register a ServiceWorker:
The origin of the provided scope ('wss://www.example.com') does not match the c
urrent origin ('https://www.example.com').")); | 236 ExpectDOMException("SecurityError", "Failed to register a ServiceWorker:
The origin of the provided scope ('wss://www.example.com') does not match the c
urrent origin ('https://www.example.com').")); |
| 237 } | 237 } |
| 238 | 238 |
| 239 TEST_F(ServiceWorkerContainerTest, GetRegistration_NonSecureOriginIsRejected) | 239 TEST_F(ServiceWorkerContainerTest, GetRegistration_NonSecureOriginIsRejected) |
| 240 { | 240 { |
| 241 setPageURL("http://www.example.com/"); | 241 setPageURL("http://www.example.com/"); |
| 242 testGetRegistrationRejected( | 242 testGetRegistrationRejected( |
| 243 "http://www.example.com/", | 243 "http://www.example.com/", |
| 244 ExpectDOMException("NotSupportedError", "Only secure origins are allowed
(see: https://goo.gl/Y0ZkNV).")); | 244 ExpectDOMException("SecurityError", "Only secure origins are allowed (se
e: https://goo.gl/Y0ZkNV).")); |
| 245 } | 245 } |
| 246 | 246 |
| 247 TEST_F(ServiceWorkerContainerTest, GetRegistration_CrossOriginURLIsRejected) | 247 TEST_F(ServiceWorkerContainerTest, GetRegistration_CrossOriginURLIsRejected) |
| 248 { | 248 { |
| 249 setPageURL("https://www.example.com/"); | 249 setPageURL("https://www.example.com/"); |
| 250 testGetRegistrationRejected( | 250 testGetRegistrationRejected( |
| 251 "https://foo.example.com/", // Differs by host | 251 "https://foo.example.com/", // Differs by host |
| 252 ExpectDOMException("SecurityError", "Failed to get a ServiceWorkerRegist
ration: The origin of the provided documentURL ('https://foo.example.com') does
not match the current origin ('https://www.example.com').")); | 252 ExpectDOMException("SecurityError", "Failed to get a ServiceWorkerRegist
ration: The origin of the provided documentURL ('https://foo.example.com') does
not match the current origin ('https://www.example.com').")); |
| 253 } | 253 } |
| 254 | 254 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 container->getRegistration(scriptState(), ""); | 357 container->getRegistration(scriptState(), ""); |
| 358 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); | 358 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); |
| 359 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); | 359 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); |
| 360 } | 360 } |
| 361 | 361 |
| 362 container->willBeDetachedFromFrame(); | 362 container->willBeDetachedFromFrame(); |
| 363 } | 363 } |
| 364 | 364 |
| 365 } // namespace | 365 } // namespace |
| 366 } // namespace blink | 366 } // namespace blink |
| OLD | NEW |