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

Side by Side Diff: content/browser/background_sync/background_sync_manager_unittest.cc

Issue 2771823002: Implement updateViaCache flag and no-cache by default for main service worker scripts
Patch Set: change useCache to updateViaCache Created 3 years, 6 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/background_sync/background_sync_manager.h" 5 #include "content/browser/background_sync/background_sync_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 void TearDown() override { 152 void TearDown() override {
153 // Restore the network observer functionality for subsequent tests 153 // Restore the network observer functionality for subsequent tests
154 background_sync_test_util::SetIgnoreNetworkChangeNotifier(false); 154 background_sync_test_util::SetIgnoreNetworkChangeNotifier(false);
155 } 155 }
156 156
157 void RegisterServiceWorkers() { 157 void RegisterServiceWorkers() {
158 bool called_1 = false; 158 bool called_1 = false;
159 bool called_2 = false; 159 bool called_2 = false;
160 helper_->context()->RegisterServiceWorker( 160 helper_->context()->RegisterServiceWorker(
161 GURL(kPattern1), GURL(kScript1), NULL, 161 GURL(kScript1), ServiceWorkerRegistrationOptions(GURL(kPattern1)),
162 nullptr,
162 base::Bind(&RegisterServiceWorkerCallback, &called_1, 163 base::Bind(&RegisterServiceWorkerCallback, &called_1,
163 &sw_registration_id_1_)); 164 &sw_registration_id_1_));
164 165
165 helper_->context()->RegisterServiceWorker( 166 helper_->context()->RegisterServiceWorker(
166 GURL(kPattern2), GURL(kScript2), NULL, 167 GURL(kScript2), ServiceWorkerRegistrationOptions(GURL(kPattern2)),
168 nullptr,
167 base::Bind(&RegisterServiceWorkerCallback, &called_2, 169 base::Bind(&RegisterServiceWorkerCallback, &called_2,
168 &sw_registration_id_2_)); 170 &sw_registration_id_2_));
169 base::RunLoop().RunUntilIdle(); 171 base::RunLoop().RunUntilIdle();
170 EXPECT_TRUE(called_1); 172 EXPECT_TRUE(called_1);
171 EXPECT_TRUE(called_2); 173 EXPECT_TRUE(called_2);
172 174
173 // Hang onto the registrations as they need to be "live" when 175 // Hang onto the registrations as they need to be "live" when
174 // calling BackgroundSyncManager::Register. 176 // calling BackgroundSyncManager::Register.
175 helper_->context_wrapper()->FindReadyRegistrationForId( 177 helper_->context_wrapper()->FindReadyRegistrationForId(
176 sw_registration_id_1_, GURL(kPattern1).GetOrigin(), 178 sw_registration_id_1_, GURL(kPattern1).GetOrigin(),
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 // Run it again. 1315 // Run it again.
1314 test_clock_->Advance(test_background_sync_manager_->delayed_task_delta()); 1316 test_clock_->Advance(test_background_sync_manager_->delayed_task_delta());
1315 test_background_sync_manager_->delayed_task().Run(); 1317 test_background_sync_manager_->delayed_task().Run();
1316 base::RunLoop().RunUntilIdle(); 1318 base::RunLoop().RunUntilIdle();
1317 EXPECT_FALSE(GetRegistration(sync_options_1_)); 1319 EXPECT_FALSE(GetRegistration(sync_options_1_));
1318 EXPECT_EQ(blink::mojom::BackgroundSyncEventLastChance::IS_LAST_CHANCE, 1320 EXPECT_EQ(blink::mojom::BackgroundSyncEventLastChance::IS_LAST_CHANCE,
1319 test_background_sync_manager_->last_chance()); 1321 test_background_sync_manager_->last_chance());
1320 } 1322 }
1321 1323
1322 } // namespace content 1324 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698