Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: content/browser/service_worker/service_worker_job_unittest.cc

Issue 567903002: ServiceWorker: Change worker script fetch error code(2/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase & fix typo Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698