Chromium Code Reviews| Index: Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp |
| diff --git a/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp b/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp |
| index 73ef62c4c7fb035684857ff1acfadc06217a62d6..d2bb06dcb441017ab584ca4a85e0427bde80c7d3 100644 |
| --- a/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp |
| +++ b/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp |
| @@ -205,6 +205,18 @@ protected: |
| container->willBeDetachedFromFrame(); |
| } |
| + void testGetRegistrationRejected(const String& documentURL, const ScriptValueTest& valueTest) |
| + { |
| + provide(adoptPtr(new NotReachedWebServiceWorkerProvider())); |
| + |
| + ServiceWorkerContainer* container = ServiceWorkerContainer::create(executionContext()); |
| + ScriptState::Scope scriptScope(scriptState()); |
| + ScriptPromise promise = container->getRegistration(scriptState(), documentURL); |
| + expectRejected(scriptState(), promise, valueTest); |
| + |
| + container->willBeDetachedFromFrame(); |
| + } |
| + |
| private: |
| OwnPtr<DummyPageHolder> m_page; |
| }; |
| @@ -252,6 +264,14 @@ TEST_F(ServiceWorkerContainerTest, Unregister_CrossOriginScopeIsRejected) |
| ExpectDOMException("SecurityError", "The scope must match the current origin.")); |
| } |
| +TEST_F(ServiceWorkerContainerTest, GetRegistration_NonSecureOriginIsRejected) |
| +{ |
| + setPageURL("http://www.example.com/"); |
| + testGetRegistrationRejected( |
| + "http://www.example.com/", |
| + ExpectDOMException("NotSupportedError", "Only secure origins are allowed. http://goo.gl/lq4gCo")); |
| +} |
| + |
|
nhiroki
2014/09/10 07:45:04
Can you test the CrossOriginDocument case?
Kunihiko Sakamoto
2014/09/10 09:34:51
Done.
|
| class StubWebServiceWorkerProvider { |
| public: |
| StubWebServiceWorkerProvider() |