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

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

Issue 2771823002: Implement updateViaCache flag and no-cache by default for main service worker scripts
Patch Set: fix tests Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_read_from_cache_job.h" 5 #include "content/browser/service_worker/service_worker_read_from_cache_job.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 url_request_context_->Init(); 84 url_request_context_->Init();
85 } 85 }
86 86
87 void InitializeStorage() { 87 void InitializeStorage() {
88 base::RunLoop run_loop; 88 base::RunLoop run_loop;
89 context()->storage()->LazyInitialize(run_loop.QuitClosure()); 89 context()->storage()->LazyInitialize(run_loop.QuitClosure());
90 run_loop.Run(); 90 run_loop.Run();
91 91
92 // Populate a registration in the storage. 92 // Populate a registration in the storage.
93 registration_ = 93 registration_ = new ServiceWorkerRegistration(
94 new ServiceWorkerRegistration(GURL("http://example.com/scope"), 94 GURL("http://example.com/scope"), false /*use_cache */, kRegistrationId,
95 kRegistrationId, context()->AsWeakPtr()); 95 context()->AsWeakPtr());
96 version_ = new ServiceWorkerVersion(registration_.get(), main_script_.url, 96 version_ = new ServiceWorkerVersion(registration_.get(), main_script_.url,
97 kVersionId, context()->AsWeakPtr()); 97 kVersionId, context()->AsWeakPtr());
98 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; 98 std::vector<ServiceWorkerDatabase::ResourceRecord> resources;
99 resources.push_back(main_script_); 99 resources.push_back(main_script_);
100 resources.push_back(imported_script_); 100 resources.push_back(imported_script_);
101 version_->script_cache_map()->SetResources(resources); 101 version_->script_cache_map()->SetResources(resources);
102 version_->set_fetch_handler_existence( 102 version_->set_fetch_handler_existence(
103 ServiceWorkerVersion::FetchHandlerExistence::EXISTS); 103 ServiceWorkerVersion::FetchHandlerExistence::EXISTS);
104 ASSERT_EQ(SERVICE_WORKER_OK, StoreRegistration()); 104 ASSERT_EQ(SERVICE_WORKER_OK, StoreRegistration());
105 ASSERT_TRUE(WriteResource(main_script_.resource_id)); 105 ASSERT_TRUE(WriteResource(main_script_.resource_id));
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 EXPECT_EQ(net::ERR_CACHE_MISS, request->status().error()); 254 EXPECT_EQ(net::ERR_CACHE_MISS, request->status().error());
255 EXPECT_EQ(SERVICE_WORKER_ERROR_DISK_CACHE, 255 EXPECT_EQ(SERVICE_WORKER_ERROR_DISK_CACHE,
256 DeduceStartWorkerFailureReason(SERVICE_WORKER_OK)); 256 DeduceStartWorkerFailureReason(SERVICE_WORKER_OK));
257 257
258 // The version should be doomed by the job. 258 // The version should be doomed by the job.
259 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version_->status()); 259 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version_->status());
260 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, FindRegistration()); 260 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, FindRegistration());
261 } 261 }
262 262
263 } // namespace content 263 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698