| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.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" |
| 11 #include "content/browser/service_worker/service_worker_context_core.h" | 11 #include "content/browser/service_worker/service_worker_context_core.h" |
| 12 #include "content/browser/service_worker/service_worker_disk_cache.h" | 12 #include "content/browser/service_worker/service_worker_disk_cache.h" |
| 13 #include "content/browser/service_worker/service_worker_job_coordinator.h" |
| 13 #include "content/browser/service_worker/service_worker_registration.h" | 14 #include "content/browser/service_worker/service_worker_registration.h" |
| 14 #include "content/browser/service_worker/service_worker_storage.h" | 15 #include "content/browser/service_worker/service_worker_storage.h" |
| 16 #include "content/browser/service_worker/service_worker_test_utils.h" |
| 15 #include "content/browser/service_worker/service_worker_version.h" | 17 #include "content/browser/service_worker/service_worker_version.h" |
| 16 #include "content/common/service_worker/service_worker_status_code.h" | 18 #include "content/common/service_worker/service_worker_status_code.h" |
| 17 #include "content/public/test/test_browser_thread_bundle.h" | 19 #include "content/public/test/test_browser_thread_bundle.h" |
| 18 #include "net/base/io_buffer.h" | 20 #include "net/base/io_buffer.h" |
| 19 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 20 #include "net/http/http_response_headers.h" | 22 #include "net/http/http_response_headers.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 24 |
| 23 using net::IOBuffer; | 25 using net::IOBuffer; |
| 24 using net::WrappedIOBuffer; | 26 using net::WrappedIOBuffer; |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 542 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
| 541 verify_ids.clear(); | 543 verify_ids.clear(); |
| 542 storage()->DeleteRegistration( | 544 storage()->DeleteRegistration( |
| 543 registration->id(), kScope.GetOrigin(), | 545 registration->id(), kScope.GetOrigin(), |
| 544 base::Bind(&VerifyPurgeableListStatusCallback, | 546 base::Bind(&VerifyPurgeableListStatusCallback, |
| 545 base::Unretained(storage()->database_.get()), | 547 base::Unretained(storage()->database_.get()), |
| 546 &verify_ids, &was_called, &result)); | 548 &verify_ids, &was_called, &result)); |
| 547 base::RunLoop().RunUntilIdle(); | 549 base::RunLoop().RunUntilIdle(); |
| 548 ASSERT_TRUE(was_called); | 550 ASSERT_TRUE(was_called); |
| 549 EXPECT_EQ(SERVICE_WORKER_OK, result); | 551 EXPECT_EQ(SERVICE_WORKER_OK, result); |
| 550 EXPECT_EQ(2u, verify_ids.size()); | 552 EXPECT_EQ(0u, verify_ids.size()); |
| 551 verify_ids.clear(); | 553 verify_ids.clear(); |
| 552 EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, | 554 EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, |
| 553 storage()->database_->GetPurgeableResourceIds(&verify_ids)); | 555 storage()->database_->GetPurgeableResourceIds(&verify_ids)); |
| 554 EXPECT_TRUE(verify_ids.empty()); | 556 EXPECT_TRUE(verify_ids.empty()); |
| 555 | 557 |
| 556 EXPECT_FALSE(VerifyBasicResponse(storage(), kResourceId1, false)); | 558 EXPECT_TRUE(VerifyBasicResponse(storage(), kResourceId1, false)); |
| 557 EXPECT_FALSE(VerifyBasicResponse(storage(), kResourceId2, false)); | 559 EXPECT_TRUE(VerifyBasicResponse(storage(), kResourceId2, false)); |
| 558 } | 560 } |
| 559 | 561 |
| 560 TEST_F(ServiceWorkerStorageTest, FindRegistration_LongestScopeMatch) { | 562 TEST_F(ServiceWorkerStorageTest, FindRegistration_LongestScopeMatch) { |
| 561 const GURL kDocumentUrl("http://www.example.com/scope/foo"); | 563 const GURL kDocumentUrl("http://www.example.com/scope/foo"); |
| 562 scoped_refptr<ServiceWorkerRegistration> found_registration; | 564 scoped_refptr<ServiceWorkerRegistration> found_registration; |
| 563 | 565 |
| 564 // Registration for "/scope/*". | 566 // Registration for "/scope/*". |
| 565 const GURL kScope1("http://www.example.com/scope/*"); | 567 const GURL kScope1("http://www.example.com/scope/*"); |
| 566 const GURL kScript1("http://www.example.com/script1.js"); | 568 const GURL kScript1("http://www.example.com/script1.js"); |
| 567 const int64 kRegistrationId1 = 1; | 569 const int64 kRegistrationId1 = 1; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 storage()->NotifyDoneInstallingRegistration( | 632 storage()->NotifyDoneInstallingRegistration( |
| 631 live_registration3, NULL, SERVICE_WORKER_OK); | 633 live_registration3, NULL, SERVICE_WORKER_OK); |
| 632 | 634 |
| 633 // Find a registration among installed ones. | 635 // Find a registration among installed ones. |
| 634 EXPECT_EQ(SERVICE_WORKER_OK, | 636 EXPECT_EQ(SERVICE_WORKER_OK, |
| 635 FindRegistrationForDocument(kDocumentUrl, &found_registration)); | 637 FindRegistrationForDocument(kDocumentUrl, &found_registration)); |
| 636 EXPECT_EQ(live_registration2, found_registration); | 638 EXPECT_EQ(live_registration2, found_registration); |
| 637 } | 639 } |
| 638 | 640 |
| 639 } // namespace content | 641 } // namespace content |
| OLD | NEW |