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 "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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 // When the registration is rejected, a register call must not reach | 181 // When the registration is rejected, a register call must not reach |
182 // the provider. | 182 // the provider. |
183 provide(wrapUnique(new NotReachedWebServiceWorkerProvider())); | 183 provide(wrapUnique(new NotReachedWebServiceWorkerProvider())); |
184 | 184 |
185 ServiceWorkerContainer* container = ServiceWorkerContainer::create(getEx ecutionContext()); | 185 ServiceWorkerContainer* container = ServiceWorkerContainer::create(getEx ecutionContext()); |
186 ScriptState::Scope scriptScope(getScriptState()); | 186 ScriptState::Scope scriptScope(getScriptState()); |
187 RegistrationOptions options; | 187 RegistrationOptions options; |
188 options.setScope(scope); | 188 options.setScope(scope); |
189 ScriptPromise promise = container->registerServiceWorker(getScriptState( ), scriptURL, options); | 189 ScriptPromise promise = container->registerServiceWorker(getScriptState( ), scriptURL, options); |
190 expectRejected(getScriptState(), promise, valueTest); | 190 expectRejected(getScriptState(), promise, valueTest); |
191 | |
192 container->willBeDetachedFromFrame(); | |
haraken
2016/07/14 09:03:53
This is no longer needed because contextDestroyed(
| |
193 } | 191 } |
194 | 192 |
195 void testGetRegistrationRejected(const String& documentURL, const ScriptValu eTest& valueTest) | 193 void testGetRegistrationRejected(const String& documentURL, const ScriptValu eTest& valueTest) |
196 { | 194 { |
197 provide(wrapUnique(new NotReachedWebServiceWorkerProvider())); | 195 provide(wrapUnique(new NotReachedWebServiceWorkerProvider())); |
198 | 196 |
199 ServiceWorkerContainer* container = ServiceWorkerContainer::create(getEx ecutionContext()); | 197 ServiceWorkerContainer* container = ServiceWorkerContainer::create(getEx ecutionContext()); |
200 ScriptState::Scope scriptScope(getScriptState()); | 198 ScriptState::Scope scriptScope(getScriptState()); |
201 ScriptPromise promise = container->getRegistration(getScriptState(), doc umentURL); | 199 ScriptPromise promise = container->getRegistration(getScriptState(), doc umentURL); |
202 expectRejected(getScriptState(), promise, valueTest); | 200 expectRejected(getScriptState(), promise, valueTest); |
203 | |
204 container->willBeDetachedFromFrame(); | |
205 } | 201 } |
206 | 202 |
207 private: | 203 private: |
208 std::unique_ptr<DummyPageHolder> m_page; | 204 std::unique_ptr<DummyPageHolder> m_page; |
209 }; | 205 }; |
210 | 206 |
211 TEST_F(ServiceWorkerContainerTest, Register_NonSecureOriginIsRejected) | 207 TEST_F(ServiceWorkerContainerTest, Register_NonSecureOriginIsRejected) |
212 { | 208 { |
213 setPageURL("http://www.example.com/"); | 209 setPageURL("http://www.example.com/"); |
214 testRegisterRejected( | 210 testRegisterRejected( |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 { | 327 { |
332 ScriptState::Scope scriptScope(getScriptState()); | 328 ScriptState::Scope scriptScope(getScriptState()); |
333 RegistrationOptions options; | 329 RegistrationOptions options; |
334 options.setScope("y/"); | 330 options.setScope("y/"); |
335 container->registerServiceWorker(getScriptState(), "/x/y/worker.js", opt ions); | 331 container->registerServiceWorker(getScriptState(), "/x/y/worker.js", opt ions); |
336 | 332 |
337 EXPECT_EQ(1ul, stubProvider.registerCallCount()); | 333 EXPECT_EQ(1ul, stubProvider.registerCallCount()); |
338 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/")), stubProvider.re gisterScope()); | 334 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/")), stubProvider.re gisterScope()); |
339 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/worker.js")), stubPr ovider.registerScriptURL()); | 335 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/worker.js")), stubPr ovider.registerScriptURL()); |
340 } | 336 } |
341 | |
342 container->willBeDetachedFromFrame(); | |
343 } | 337 } |
344 | 338 |
345 TEST_F(ServiceWorkerContainerTest, GetRegistration_OmittedDocumentURLDefaultsToP ageURL) | 339 TEST_F(ServiceWorkerContainerTest, GetRegistration_OmittedDocumentURLDefaultsToP ageURL) |
346 { | 340 { |
347 setPageURL("http://localhost/x/index.html"); | 341 setPageURL("http://localhost/x/index.html"); |
348 | 342 |
349 StubWebServiceWorkerProvider stubProvider; | 343 StubWebServiceWorkerProvider stubProvider; |
350 provide(stubProvider.provider()); | 344 provide(stubProvider.provider()); |
351 | 345 |
352 ServiceWorkerContainer* container = ServiceWorkerContainer::create(getExecut ionContext()); | 346 ServiceWorkerContainer* container = ServiceWorkerContainer::create(getExecut ionContext()); |
353 | 347 |
354 { | 348 { |
355 ScriptState::Scope scriptScope(getScriptState()); | 349 ScriptState::Scope scriptScope(getScriptState()); |
356 container->getRegistration(getScriptState(), ""); | 350 container->getRegistration(getScriptState(), ""); |
357 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); | 351 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); |
358 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro vider.getRegistrationURL()); | 352 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro vider.getRegistrationURL()); |
359 } | 353 } |
360 | |
361 container->willBeDetachedFromFrame(); | |
362 } | 354 } |
363 | 355 |
364 } // namespace | 356 } // namespace |
365 } // namespace blink | 357 } // namespace blink |
OLD | NEW |