OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/files/scoped_temp_dir.h" | 5 #include "base/files/scoped_temp_dir.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
9 #include "content/browser/service_worker/embedded_worker_registry.h" | 9 #include "content/browser/service_worker/embedded_worker_registry.h" |
10 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 10 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 const std::string kMockScriptBody = "mock_script"; | 938 const std::string kMockScriptBody = "mock_script"; |
939 ServiceWorkerVersion* version = context()->GetLiveVersion(version_id); | 939 ServiceWorkerVersion* version = context()->GetLiveVersion(version_id); |
940 ASSERT_TRUE(version); | 940 ASSERT_TRUE(version); |
941 version->AddListener(this); | 941 version->AddListener(this); |
942 | 942 |
943 if (!pause_after_download) { | 943 if (!pause_after_download) { |
944 // Spoof caching the script for the initial version. | 944 // Spoof caching the script for the initial version. |
945 int64 resource_id = storage()->NewResourceId(); | 945 int64 resource_id = storage()->NewResourceId(); |
946 version->script_cache_map()->NotifyStartedCaching(script, resource_id); | 946 version->script_cache_map()->NotifyStartedCaching(script, resource_id); |
947 WriteStringResponse(storage(), resource_id, kMockScriptBody); | 947 WriteStringResponse(storage(), resource_id, kMockScriptBody); |
948 version->script_cache_map()->NotifyFinishedCaching(script, true); | 948 version->script_cache_map()->NotifyFinishedCaching( |
| 949 script, net::URLRequestStatus()); |
949 } else { | 950 } else { |
950 // Spoof caching the script for the new version. | 951 // Spoof caching the script for the new version. |
951 int64 resource_id = storage()->NewResourceId(); | 952 int64 resource_id = storage()->NewResourceId(); |
952 version->script_cache_map()->NotifyStartedCaching(script, resource_id); | 953 version->script_cache_map()->NotifyStartedCaching(script, resource_id); |
953 if (script.GetOrigin() == kNoChangeOrigin) | 954 if (script.GetOrigin() == kNoChangeOrigin) |
954 WriteStringResponse(storage(), resource_id, kMockScriptBody); | 955 WriteStringResponse(storage(), resource_id, kMockScriptBody); |
955 else | 956 else |
956 WriteStringResponse(storage(), resource_id, "mock_different_script"); | 957 WriteStringResponse(storage(), resource_id, "mock_different_script"); |
957 version->script_cache_map()->NotifyFinishedCaching(script, true); | 958 version->script_cache_map()->NotifyFinishedCaching( |
| 959 script, net::URLRequestStatus()); |
958 } | 960 } |
959 EmbeddedWorkerTestHelper::OnStartWorker( | 961 EmbeddedWorkerTestHelper::OnStartWorker( |
960 embedded_worker_id, version_id, scope, script, pause_after_download); | 962 embedded_worker_id, version_id, scope, script, pause_after_download); |
961 } | 963 } |
962 | 964 |
963 // ServiceWorkerRegistration::Listener overrides | 965 // ServiceWorkerRegistration::Listener overrides |
964 virtual void OnVersionAttributesChanged( | 966 virtual void OnVersionAttributesChanged( |
965 ServiceWorkerRegistration* registration, | 967 ServiceWorkerRegistration* registration, |
966 ChangedVersionAttributesMask changed_mask, | 968 ChangedVersionAttributesMask changed_mask, |
967 const ServiceWorkerRegistrationInfo& info) OVERRIDE { | 969 const ServiceWorkerRegistrationInfo& info) OVERRIDE { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 EXPECT_TRUE(called); | 1193 EXPECT_TRUE(called); |
1192 | 1194 |
1193 // Verify the registration was not modified by the Update. | 1195 // Verify the registration was not modified by the Update. |
1194 EXPECT_TRUE(registration->is_uninstalling()); | 1196 EXPECT_TRUE(registration->is_uninstalling()); |
1195 EXPECT_EQ(active_version, registration->active_version()); | 1197 EXPECT_EQ(active_version, registration->active_version()); |
1196 EXPECT_EQ(NULL, registration->waiting_version()); | 1198 EXPECT_EQ(NULL, registration->waiting_version()); |
1197 EXPECT_EQ(NULL, registration->installing_version()); | 1199 EXPECT_EQ(NULL, registration->installing_version()); |
1198 } | 1200 } |
1199 | 1201 |
1200 } // namespace content | 1202 } // namespace content |
OLD | NEW |