Chromium Code Reviews| Index: content/browser/service_worker/service_worker_dispatcher_host_unittest.cc |
| diff --git a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc |
| index 6f7f25d0e8081b7da901b0d23e139e2aef5fcac4..8897ae3825d0d658ad3605ed828632ec811a6dce 100644 |
| --- a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc |
| +++ b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc |
| @@ -186,6 +186,34 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_NonSecureTransportLocalhost) { |
| ServiceWorkerMsg_ServiceWorkerRegistered::ID); |
| } |
| +TEST_F(ServiceWorkerDispatcherHostTest, |
| + Register_DifferentDirectoryThanScriptShouldFail) { |
| + const int64 kProviderId = 99; // Dummy value |
| + scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
| + kRenderProcessId, kProviderId, context()->AsWeakPtr(), NULL)); |
| + host->SetDocumentUrl(GURL("https://www.example.com/foo")); |
| + context()->AddProviderHost(host.Pass()); |
| + |
| + SendRegister(kProviderId, |
| + GURL("https://www.example.com/hoge/piyo"), |
| + GURL("https://www.example.com/bar/hoge.js")); |
| + EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
| +} |
| + |
| +TEST_F(ServiceWorkerDispatcherHostTest, |
| + Register_SameDirectoryAsScriptButNoSlashShouldFail) { |
| + const int64 kProviderId = 99; // Dummy value |
| + scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
| + kRenderProcessId, kProviderId, context()->AsWeakPtr(), NULL)); |
| + host->SetDocumentUrl(GURL("https://www.example.com/foo")); |
| + context()->AddProviderHost(host.Pass()); |
| + |
| + SendRegister(kProviderId, |
| + GURL("https://www.example.com/bar"), |
| + GURL("https://www.example.com/bar/hoge.js")); |
| + EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
| +} |
| + |
|
falken
2014/10/27 03:54:17
Can you add checks for invalid GURLs too, like the
|
| TEST_F(ServiceWorkerDispatcherHostTest, Register_NonSecureOriginShouldFail) { |
| const int64 kProviderId = 99; // Dummy value |
| scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |