Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/service_worker/service_worker_dispatcher_host.h" | 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 GURL("https://www.example.com/temporary/"), | 327 GURL("https://www.example.com/temporary/"), |
| 328 GURL("filesystem:https://www.example.com/temporary/bar")); | 328 GURL("filesystem:https://www.example.com/temporary/bar")); |
| 329 EXPECT_EQ(2, dispatcher_host_->bad_messages_received_count_); | 329 EXPECT_EQ(2, dispatcher_host_->bad_messages_received_count_); |
| 330 | 330 |
| 331 SendRegister(kProviderId, | 331 SendRegister(kProviderId, |
| 332 GURL("filesystem:https://www.example.com/temporary/"), | 332 GURL("filesystem:https://www.example.com/temporary/"), |
| 333 GURL("filesystem:https://www.example.com/temporary/bar")); | 333 GURL("filesystem:https://www.example.com/temporary/bar")); |
| 334 EXPECT_EQ(3, dispatcher_host_->bad_messages_received_count_); | 334 EXPECT_EQ(3, dispatcher_host_->bad_messages_received_count_); |
| 335 } | 335 } |
| 336 | 336 |
| 337 TEST_F(ServiceWorkerDispatcherHostTest, RegisterWithBadCharactersShouldFail) { | |
|
nhiroki
2015/08/10 08:15:51
"Register_BadCharactersShouldFail" seems more cons
nhiroki
2015/08/10 08:15:51
Can you move this test to line 313 because this is
| |
| 338 const int64 kProviderId = 99; // Dummy value | |
| 339 scoped_ptr<ServiceWorkerProviderHost> host( | |
| 340 CreateServiceWorkerProviderHost(kProviderId)); | |
| 341 host->SetDocumentUrl(GURL("https://www.example.com/")); | |
| 342 context()->AddProviderHost(host.Pass()); | |
| 343 | |
| 344 SendRegister(kProviderId, GURL("https://www.example.com/%2f"), | |
| 345 GURL("https://www.example.com/")); | |
| 346 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); | |
| 347 | |
| 348 SendRegister(kProviderId, GURL("https://www.example.com/%2F"), | |
| 349 GURL("https://www.example.com/")); | |
| 350 EXPECT_EQ(2, dispatcher_host_->bad_messages_received_count_); | |
| 351 | |
| 352 SendRegister(kProviderId, GURL("https://www.example.com/"), | |
| 353 GURL("https://www.example.com/%2f")); | |
| 354 EXPECT_EQ(3, dispatcher_host_->bad_messages_received_count_); | |
| 355 | |
| 356 SendRegister(kProviderId, GURL("https://www.example.com/%5c"), | |
| 357 GURL("https://www.example.com/")); | |
| 358 EXPECT_EQ(4, dispatcher_host_->bad_messages_received_count_); | |
| 359 | |
| 360 SendRegister(kProviderId, GURL("https://www.example.com/"), | |
| 361 GURL("https://www.example.com/%5c")); | |
| 362 EXPECT_EQ(5, dispatcher_host_->bad_messages_received_count_); | |
| 363 | |
| 364 SendRegister(kProviderId, GURL("https://www.example.com/"), | |
| 365 GURL("https://www.example.com/%5C")); | |
| 366 EXPECT_EQ(6, dispatcher_host_->bad_messages_received_count_); | |
| 367 } | |
| 368 | |
| 337 TEST_F(ServiceWorkerDispatcherHostTest, | 369 TEST_F(ServiceWorkerDispatcherHostTest, |
| 338 Register_FileSystemScriptOrScopeShouldFail) { | 370 Register_FileSystemScriptOrScopeShouldFail) { |
| 339 const int64 kProviderId = 99; // Dummy value | 371 const int64 kProviderId = 99; // Dummy value |
| 340 scoped_ptr<ServiceWorkerProviderHost> host( | 372 scoped_ptr<ServiceWorkerProviderHost> host( |
| 341 CreateServiceWorkerProviderHost(kProviderId)); | 373 CreateServiceWorkerProviderHost(kProviderId)); |
| 342 host->SetDocumentUrl(GURL("https://www.example.com/temporary/")); | 374 host->SetDocumentUrl(GURL("https://www.example.com/temporary/")); |
| 343 context()->AddProviderHost(host.Pass()); | 375 context()->AddProviderHost(host.Pass()); |
| 344 | 376 |
| 345 SendRegister(kProviderId, | 377 SendRegister(kProviderId, |
| 346 GURL("filesystem:https://www.example.com/temporary/"), | 378 GURL("filesystem:https://www.example.com/temporary/"), |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 | 587 |
| 556 // To show the new dispatcher can operate, simulate provider creation. Since | 588 // To show the new dispatcher can operate, simulate provider creation. Since |
| 557 // the old dispatcher cleaned up the old provider host, the new one won't | 589 // the old dispatcher cleaned up the old provider host, the new one won't |
| 558 // complain. | 590 // complain. |
| 559 new_dispatcher_host->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( | 591 new_dispatcher_host->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( |
| 560 kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW)); | 592 kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW)); |
| 561 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_); | 593 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_); |
| 562 } | 594 } |
| 563 | 595 |
| 564 } // namespace content | 596 } // namespace content |
| OLD | NEW |