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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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, | 337 TEST_F(ServiceWorkerDispatcherHostTest, |
| 338 Register_FileSystemScriptOrScopeShouldFail) { | 338 Register_FileSystemScriptOrScopeShouldFail) { |
| 339 const int64 kProviderId = 99; // Dummy value | 339 const int64 kProviderId = 99; // Dummy value |
| 340 scoped_ptr<ServiceWorkerProviderHost> host( | 340 scoped_ptr<ServiceWorkerProviderHost> host( |
| 341 CreateServiceWorkerProviderHost(kProviderId)); | 341 CreateServiceWorkerProviderHost(kProviderId)); |
| 342 host->SetDocumentUrl(GURL("https://www.example.com/")); | |
| 343 context()->AddProviderHost(host.Pass()); | |
| 344 | |
| 345 SendRegister(kProviderId, GURL("https://www.example.com/%2f"), | |
| 346 GURL("https://www.example.com/")); | |
| 347 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); | |
| 348 | |
| 349 SendRegister(kProviderId, GURL("https://www.example.com/%2F"), | |
| 350 GURL("https://www.example.com/")); | |
| 351 EXPECT_EQ(2, dispatcher_host_->bad_messages_received_count_); | |
| 352 | |
| 353 SendRegister(kProviderId, GURL("https://www.example.com/"), | |
| 354 GURL("https://www.example.com/%2f")); | |
| 355 EXPECT_EQ(3, dispatcher_host_->bad_messages_received_count_); | |
| 356 | |
| 357 SendRegister(kProviderId, GURL("https://www.example.com/%5c"), | |
| 358 GURL("https://www.example.com/")); | |
| 359 EXPECT_EQ(4, dispatcher_host_->bad_messages_received_count_); | |
| 360 | |
| 361 SendRegister(kProviderId, GURL("https://www.example.com/"), | |
| 362 GURL("https://www.example.com/%5c")); | |
| 363 EXPECT_EQ(5, dispatcher_host_->bad_messages_received_count_); | |
| 364 | |
| 365 SendRegister(kProviderId, GURL("https://www.example.com/"), | |
| 366 GURL("https://www.example.com/%5C")); | |
| 367 EXPECT_EQ(6, dispatcher_host_->bad_messages_received_count_); | |
| 368 } | |
| 369 | |
| 370 TEST_F(ServiceWorkerDispatcherHostTest, RegisterWithBadCharactersShouldFail) { | |
|
falken
2015/08/05 06:55:35
These test names look reversed.
jeremyarcher
2015/08/10 03:29:40
Whoops! Had to stare at it for a second; PTAL.
nhiroki
2015/08/10 08:03:17
I cannot see the updated patchset. Maybe you faile
| |
| 371 const int64 kProviderId = 99; // Dummy value | |
| 372 scoped_ptr<ServiceWorkerProviderHost> host( | |
| 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/"), |
| 347 GURL("https://www.example.com/temporary/bar")); | 379 GURL("https://www.example.com/temporary/bar")); |
| 348 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); | 380 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
| 349 | 381 |
| 350 SendRegister(kProviderId, | 382 SendRegister(kProviderId, |
| 351 GURL("https://www.example.com/temporary/"), | 383 GURL("https://www.example.com/temporary/"), |
| (...skipping 203 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 |