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

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

Issue 2039743003: Introduce ServiceWorker.ActivatedWorkerPreparationForMainFrame.Time UMA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated the comments Created 4 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 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 <stdint.h> 5 #include <stdint.h>
6 #include <tuple> 6 #include <tuple>
7 7
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/test/test_simple_task_runner.h" 12 #include "base/test/test_simple_task_runner.h"
13 #include "content/browser/browser_thread_impl.h" 13 #include "content/browser/browser_thread_impl.h"
14 #include "content/browser/service_worker/embedded_worker_registry.h" 14 #include "content/browser/service_worker/embedded_worker_registry.h"
15 #include "content/browser/service_worker/embedded_worker_status.h"
15 #include "content/browser/service_worker/embedded_worker_test_helper.h" 16 #include "content/browser/service_worker/embedded_worker_test_helper.h"
16 #include "content/browser/service_worker/service_worker_context_core.h" 17 #include "content/browser/service_worker/service_worker_context_core.h"
17 #include "content/browser/service_worker/service_worker_context_wrapper.h" 18 #include "content/browser/service_worker/service_worker_context_wrapper.h"
18 #include "content/browser/service_worker/service_worker_disk_cache.h" 19 #include "content/browser/service_worker/service_worker_disk_cache.h"
19 #include "content/browser/service_worker/service_worker_job_coordinator.h" 20 #include "content/browser/service_worker/service_worker_job_coordinator.h"
20 #include "content/browser/service_worker/service_worker_registration.h" 21 #include "content/browser/service_worker/service_worker_registration.h"
21 #include "content/browser/service_worker/service_worker_registration_status.h" 22 #include "content/browser/service_worker/service_worker_registration_status.h"
22 #include "content/browser/service_worker/service_worker_test_utils.h" 23 #include "content/browser/service_worker/service_worker_test_utils.h"
23 #include "content/common/service_worker/embedded_worker_messages.h" 24 #include "content/common/service_worker/embedded_worker_messages.h"
24 #include "content/common/service_worker/service_worker_messages.h" 25 #include "content/common/service_worker/service_worker_messages.h"
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( 652 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion(
652 registration.get(), script_url, 1L, helper_->context()->AsWeakPtr()); 653 registration.get(), script_url, 1L, helper_->context()->AsWeakPtr());
653 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 654 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
654 version->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, 655 version->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN,
655 CreateReceiverOnCurrentThread(&status)); 656 CreateReceiverOnCurrentThread(&status));
656 base::RunLoop().RunUntilIdle(); 657 base::RunLoop().RunUntilIdle();
657 ASSERT_EQ(SERVICE_WORKER_OK, status); 658 ASSERT_EQ(SERVICE_WORKER_OK, status);
658 659
659 version->SetStatus(ServiceWorkerVersion::INSTALLED); 660 version->SetStatus(ServiceWorkerVersion::INSTALLED);
660 registration->SetWaitingVersion(version); 661 registration->SetWaitingVersion(version);
661 EXPECT_EQ(ServiceWorkerVersion::RUNNING, 662 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, version->running_status());
662 version->running_status());
663 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, version->status()); 663 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, version->status());
664 664
665 RunUnregisterJob(GURL("http://www.example.com/")); 665 RunUnregisterJob(GURL("http://www.example.com/"));
666 666
667 // The version should be stopped since there is no controllee after 667 // The version should be stopped since there is no controllee after
668 // unregistration. 668 // unregistration.
669 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version->running_status()); 669 EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, version->running_status());
670 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status()); 670 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status());
671 } 671 }
672 672
673 // Tests that the active worker enters the 'redundant' state upon 673 // Tests that the active worker enters the 'redundant' state upon
674 // unregistration. 674 // unregistration.
675 TEST_F(ServiceWorkerJobTest, UnregisterActiveSetsRedundant) { 675 TEST_F(ServiceWorkerJobTest, UnregisterActiveSetsRedundant) {
676 scoped_refptr<ServiceWorkerRegistration> registration = 676 scoped_refptr<ServiceWorkerRegistration> registration =
677 RunRegisterJob(GURL("http://www.example.com/"), 677 RunRegisterJob(GURL("http://www.example.com/"),
678 GURL("http://www.example.com/service_worker.js")); 678 GURL("http://www.example.com/service_worker.js"));
679 ASSERT_TRUE(registration.get()); 679 ASSERT_TRUE(registration.get());
680 680
681 scoped_refptr<ServiceWorkerVersion> version = registration->active_version(); 681 scoped_refptr<ServiceWorkerVersion> version = registration->active_version();
682 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version->running_status()); 682 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, version->running_status());
683 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status()); 683 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status());
684 684
685 RunUnregisterJob(GURL("http://www.example.com/")); 685 RunUnregisterJob(GURL("http://www.example.com/"));
686 686
687 // The version should be stopped since there is no controllee after 687 // The version should be stopped since there is no controllee after
688 // unregistration. 688 // unregistration.
689 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version->running_status()); 689 EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, version->running_status());
690 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status()); 690 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status());
691 } 691 }
692 692
693 // Tests that the active worker enters the 'redundant' state upon 693 // Tests that the active worker enters the 'redundant' state upon
694 // unregistration. 694 // unregistration.
695 TEST_F(ServiceWorkerJobTest, 695 TEST_F(ServiceWorkerJobTest,
696 UnregisterActiveSetsRedundant_WaitForNoControllee) { 696 UnregisterActiveSetsRedundant_WaitForNoControllee) {
697 scoped_refptr<ServiceWorkerRegistration> registration = 697 scoped_refptr<ServiceWorkerRegistration> registration =
698 RunRegisterJob(GURL("http://www.example.com/"), 698 RunRegisterJob(GURL("http://www.example.com/"),
699 GURL("http://www.example.com/service_worker.js")); 699 GURL("http://www.example.com/service_worker.js"));
700 ASSERT_TRUE(registration.get()); 700 ASSERT_TRUE(registration.get());
701 701
702 std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee(); 702 std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee();
703 registration->active_version()->AddControllee(host.get()); 703 registration->active_version()->AddControllee(host.get());
704 704
705 scoped_refptr<ServiceWorkerVersion> version = registration->active_version(); 705 scoped_refptr<ServiceWorkerVersion> version = registration->active_version();
706 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version->running_status()); 706 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, version->running_status());
707 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status()); 707 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status());
708 708
709 RunUnregisterJob(GURL("http://www.example.com/")); 709 RunUnregisterJob(GURL("http://www.example.com/"));
710 710
711 // The version should be running since there is still a controllee. 711 // The version should be running since there is still a controllee.
712 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version->running_status()); 712 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, version->running_status());
713 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status()); 713 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status());
714 714
715 registration->active_version()->RemoveControllee(host.get()); 715 registration->active_version()->RemoveControllee(host.get());
716 base::RunLoop().RunUntilIdle(); 716 base::RunLoop().RunUntilIdle();
717 717
718 // The version should be stopped since there is no controllee. 718 // The version should be stopped since there is no controllee.
719 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version->running_status()); 719 EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, version->running_status());
720 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status()); 720 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status());
721 } 721 }
722 722
723 namespace { // Helpers for the update job tests. 723 namespace { // Helpers for the update job tests.
724 724
725 const GURL kNoChangeOrigin("http://nochange/"); 725 const GURL kNoChangeOrigin("http://nochange/");
726 const GURL kNewVersionOrigin("http://newversion/"); 726 const GURL kNewVersionOrigin("http://newversion/");
727 const std::string kScope("scope/"); 727 const std::string kScope("scope/");
728 const std::string kScript("script.js"); 728 const std::string kScript("script.js");
729 729
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 1246
1247 EXPECT_FALSE(registration->is_uninstalling()); 1247 EXPECT_FALSE(registration->is_uninstalling());
1248 EXPECT_EQ(old_version, registration->active_version()); 1248 EXPECT_EQ(old_version, registration->active_version());
1249 1249
1250 scoped_refptr<ServiceWorkerVersion> new_version = 1250 scoped_refptr<ServiceWorkerVersion> new_version =
1251 registration->waiting_version(); 1251 registration->waiting_version();
1252 1252
1253 // Verify the new version is installed but not activated yet. 1253 // Verify the new version is installed but not activated yet.
1254 EXPECT_EQ(NULL, registration->installing_version()); 1254 EXPECT_EQ(NULL, registration->installing_version());
1255 EXPECT_TRUE(new_version); 1255 EXPECT_TRUE(new_version);
1256 EXPECT_EQ(ServiceWorkerVersion::RUNNING, new_version->running_status()); 1256 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, new_version->running_status());
1257 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, new_version->status()); 1257 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, new_version->status());
1258 1258
1259 old_version->RemoveControllee(host.get()); 1259 old_version->RemoveControllee(host.get());
1260 base::RunLoop().RunUntilIdle(); 1260 base::RunLoop().RunUntilIdle();
1261 1261
1262 EXPECT_FALSE(registration->is_uninstalling()); 1262 EXPECT_FALSE(registration->is_uninstalling());
1263 EXPECT_FALSE(registration->is_uninstalled()); 1263 EXPECT_FALSE(registration->is_uninstalled());
1264 1264
1265 // Verify the new version is activated. 1265 // Verify the new version is activated.
1266 EXPECT_EQ(NULL, registration->installing_version()); 1266 EXPECT_EQ(NULL, registration->installing_version());
1267 EXPECT_EQ(NULL, registration->waiting_version()); 1267 EXPECT_EQ(NULL, registration->waiting_version());
1268 EXPECT_EQ(new_version, registration->active_version()); 1268 EXPECT_EQ(new_version, registration->active_version());
1269 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); 1269 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status());
1270 1270
1271 runner->RunUntilIdle(); 1271 runner->RunUntilIdle();
1272 base::RunLoop().RunUntilIdle(); 1272 base::RunLoop().RunUntilIdle();
1273 EXPECT_EQ(ServiceWorkerVersion::RUNNING, new_version->running_status()); 1273 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, new_version->running_status());
1274 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status()); 1274 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status());
1275 } 1275 }
1276 1276
1277 TEST_F(ServiceWorkerJobTest, RegisterAndUnregisterWhileUninstalling) { 1277 TEST_F(ServiceWorkerJobTest, RegisterAndUnregisterWhileUninstalling) {
1278 GURL pattern("http://www.example.com/one/"); 1278 GURL pattern("http://www.example.com/one/");
1279 GURL script1("http://www.example.com/service_worker.js"); 1279 GURL script1("http://www.example.com/service_worker.js");
1280 GURL script2("http://www.example.com/service_worker.js?new"); 1280 GURL script2("http://www.example.com/service_worker.js?new");
1281 1281
1282 scoped_refptr<ServiceWorkerRegistration> registration = 1282 scoped_refptr<ServiceWorkerRegistration> registration =
1283 RunRegisterJob(pattern, script1); 1283 RunRegisterJob(pattern, script1);
(...skipping 14 matching lines...) Expand all
1298 1298
1299 // Unregister the registration (but it's still live). 1299 // Unregister the registration (but it's still live).
1300 RunUnregisterJob(pattern); 1300 RunUnregisterJob(pattern);
1301 // Now it's not found in the storage. 1301 // Now it's not found in the storage.
1302 RunUnregisterJob(pattern, SERVICE_WORKER_ERROR_NOT_FOUND); 1302 RunUnregisterJob(pattern, SERVICE_WORKER_ERROR_NOT_FOUND);
1303 1303
1304 FindRegistrationForPattern(pattern, SERVICE_WORKER_ERROR_NOT_FOUND); 1304 FindRegistrationForPattern(pattern, SERVICE_WORKER_ERROR_NOT_FOUND);
1305 EXPECT_TRUE(registration->is_uninstalling()); 1305 EXPECT_TRUE(registration->is_uninstalling());
1306 EXPECT_EQ(old_version, registration->active_version()); 1306 EXPECT_EQ(old_version, registration->active_version());
1307 1307
1308 EXPECT_EQ(ServiceWorkerVersion::RUNNING, old_version->running_status()); 1308 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, old_version->running_status());
1309 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, old_version->status()); 1309 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, old_version->status());
1310 EXPECT_EQ(ServiceWorkerVersion::RUNNING, new_version->running_status()); 1310 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, new_version->running_status());
1311 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, new_version->status()); 1311 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, new_version->status());
1312 1312
1313 old_version->RemoveControllee(host.get()); 1313 old_version->RemoveControllee(host.get());
1314 base::RunLoop().RunUntilIdle(); 1314 base::RunLoop().RunUntilIdle();
1315 1315
1316 EXPECT_FALSE(registration->is_uninstalling()); 1316 EXPECT_FALSE(registration->is_uninstalling());
1317 EXPECT_TRUE(registration->is_uninstalled()); 1317 EXPECT_TRUE(registration->is_uninstalled());
1318 1318
1319 EXPECT_EQ(ServiceWorkerVersion::STOPPED, old_version->running_status()); 1319 EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, old_version->running_status());
1320 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status()); 1320 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status());
1321 EXPECT_EQ(ServiceWorkerVersion::STOPPED, new_version->running_status()); 1321 EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, new_version->running_status());
1322 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, new_version->status()); 1322 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, new_version->status());
1323 } 1323 }
1324 1324
1325 TEST_F(ServiceWorkerJobTest, RegisterSameScriptMultipleTimesWhileUninstalling) { 1325 TEST_F(ServiceWorkerJobTest, RegisterSameScriptMultipleTimesWhileUninstalling) {
1326 GURL pattern("http://www.example.com/one/"); 1326 GURL pattern("http://www.example.com/one/");
1327 GURL script1("http://www.example.com/service_worker.js"); 1327 GURL script1("http://www.example.com/service_worker.js");
1328 GURL script2("http://www.example.com/service_worker.js?new"); 1328 GURL script2("http://www.example.com/service_worker.js?new");
1329 1329
1330 scoped_refptr<ServiceWorkerRegistration> registration = 1330 scoped_refptr<ServiceWorkerRegistration> registration =
1331 RunRegisterJob(pattern, script1); 1331 RunRegisterJob(pattern, script1);
(...skipping 30 matching lines...) Expand all
1362 EXPECT_FALSE(registration->is_uninstalled()); 1362 EXPECT_FALSE(registration->is_uninstalled());
1363 1363
1364 // Verify the new version is activated. 1364 // Verify the new version is activated.
1365 EXPECT_EQ(NULL, registration->installing_version()); 1365 EXPECT_EQ(NULL, registration->installing_version());
1366 EXPECT_EQ(NULL, registration->waiting_version()); 1366 EXPECT_EQ(NULL, registration->waiting_version());
1367 EXPECT_EQ(new_version, registration->active_version()); 1367 EXPECT_EQ(new_version, registration->active_version());
1368 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); 1368 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status());
1369 1369
1370 runner->RunUntilIdle(); 1370 runner->RunUntilIdle();
1371 base::RunLoop().RunUntilIdle(); 1371 base::RunLoop().RunUntilIdle();
1372 EXPECT_EQ(ServiceWorkerVersion::RUNNING, new_version->running_status()); 1372 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, new_version->running_status());
1373 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status()); 1373 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status());
1374 } 1374 }
1375 1375
1376 TEST_F(ServiceWorkerJobTest, RegisterMultipleTimesWhileUninstalling) { 1376 TEST_F(ServiceWorkerJobTest, RegisterMultipleTimesWhileUninstalling) {
1377 GURL pattern("http://www.example.com/one/"); 1377 GURL pattern("http://www.example.com/one/");
1378 GURL script1("http://www.example.com/service_worker.js?first"); 1378 GURL script1("http://www.example.com/service_worker.js?first");
1379 GURL script2("http://www.example.com/service_worker.js?second"); 1379 GURL script2("http://www.example.com/service_worker.js?second");
1380 GURL script3("http://www.example.com/service_worker.js?third"); 1380 GURL script3("http://www.example.com/service_worker.js?third");
1381 1381
1382 scoped_refptr<ServiceWorkerRegistration> registration = 1382 scoped_refptr<ServiceWorkerRegistration> registration =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 EXPECT_FALSE(registration->is_uninstalled()); 1418 EXPECT_FALSE(registration->is_uninstalled());
1419 1419
1420 // Verify the new version is activated. 1420 // Verify the new version is activated.
1421 EXPECT_EQ(NULL, registration->installing_version()); 1421 EXPECT_EQ(NULL, registration->installing_version());
1422 EXPECT_EQ(NULL, registration->waiting_version()); 1422 EXPECT_EQ(NULL, registration->waiting_version());
1423 EXPECT_EQ(third_version, registration->active_version()); 1423 EXPECT_EQ(third_version, registration->active_version());
1424 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, third_version->status()); 1424 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, third_version->status());
1425 1425
1426 runner->RunUntilIdle(); 1426 runner->RunUntilIdle();
1427 base::RunLoop().RunUntilIdle(); 1427 base::RunLoop().RunUntilIdle();
1428 EXPECT_EQ(ServiceWorkerVersion::RUNNING, third_version->running_status()); 1428 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, third_version->running_status());
1429 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, third_version->status()); 1429 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, third_version->status());
1430 } 1430 }
1431 1431
1432 class EventCallbackHelper : public EmbeddedWorkerTestHelper { 1432 class EventCallbackHelper : public EmbeddedWorkerTestHelper {
1433 public: 1433 public:
1434 EventCallbackHelper() 1434 EventCallbackHelper()
1435 : EmbeddedWorkerTestHelper(base::FilePath()), 1435 : EmbeddedWorkerTestHelper(base::FilePath()),
1436 install_event_result_(blink::WebServiceWorkerEventResultCompleted), 1436 install_event_result_(blink::WebServiceWorkerEventResultCompleted),
1437 activate_event_result_(blink::WebServiceWorkerEventResultCompleted) {} 1437 activate_event_result_(blink::WebServiceWorkerEventResultCompleted) {}
1438 1438
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 EXPECT_FALSE(registration->is_uninstalling()); 1497 EXPECT_FALSE(registration->is_uninstalling());
1498 EXPECT_FALSE(registration->is_uninstalled()); 1498 EXPECT_FALSE(registration->is_uninstalled());
1499 1499
1500 // Verify the new version is activated. 1500 // Verify the new version is activated.
1501 scoped_refptr<ServiceWorkerVersion> new_version = 1501 scoped_refptr<ServiceWorkerVersion> new_version =
1502 registration->active_version(); 1502 registration->active_version();
1503 EXPECT_NE(old_version, new_version); 1503 EXPECT_NE(old_version, new_version);
1504 EXPECT_EQ(NULL, registration->installing_version()); 1504 EXPECT_EQ(NULL, registration->installing_version());
1505 EXPECT_EQ(NULL, registration->waiting_version()); 1505 EXPECT_EQ(NULL, registration->waiting_version());
1506 EXPECT_EQ(new_version, registration->active_version()); 1506 EXPECT_EQ(new_version, registration->active_version());
1507 EXPECT_EQ(ServiceWorkerVersion::RUNNING, new_version->running_status()); 1507 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, new_version->running_status());
1508 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status()); 1508 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status());
1509 1509
1510 EXPECT_EQ(registration, FindRegistrationForPattern(pattern)); 1510 EXPECT_EQ(registration, FindRegistrationForPattern(pattern));
1511 } 1511 }
1512 1512
1513 TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringRejectedInstall) { 1513 TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringRejectedInstall) {
1514 EventCallbackHelper* helper = new EventCallbackHelper; 1514 EventCallbackHelper* helper = new EventCallbackHelper;
1515 helper_.reset(helper); 1515 helper_.reset(helper);
1516 1516
1517 GURL pattern("http://www.example.com/one/"); 1517 GURL pattern("http://www.example.com/one/");
(...skipping 15 matching lines...) Expand all
1533 helper->set_install_callback( 1533 helper->set_install_callback(
1534 base::Bind(&ServiceWorkerVersion::RemoveControllee, 1534 base::Bind(&ServiceWorkerVersion::RemoveControllee,
1535 old_version, host.get())); 1535 old_version, host.get()));
1536 helper->set_install_event_result(blink::WebServiceWorkerEventResultRejected); 1536 helper->set_install_event_result(blink::WebServiceWorkerEventResultRejected);
1537 EXPECT_EQ(registration, RunRegisterJob(pattern, script2)); 1537 EXPECT_EQ(registration, RunRegisterJob(pattern, script2));
1538 1538
1539 // Verify the registration was uninstalled. 1539 // Verify the registration was uninstalled.
1540 EXPECT_FALSE(registration->is_uninstalling()); 1540 EXPECT_FALSE(registration->is_uninstalling());
1541 EXPECT_TRUE(registration->is_uninstalled()); 1541 EXPECT_TRUE(registration->is_uninstalled());
1542 1542
1543 EXPECT_EQ(ServiceWorkerVersion::STOPPED, old_version->running_status()); 1543 EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, old_version->running_status());
1544 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status()); 1544 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status());
1545 1545
1546 FindRegistrationForPattern(pattern, SERVICE_WORKER_ERROR_NOT_FOUND); 1546 FindRegistrationForPattern(pattern, SERVICE_WORKER_ERROR_NOT_FOUND);
1547 } 1547 }
1548 1548
1549 TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall_RejectActivate) { 1549 TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall_RejectActivate) {
1550 EventCallbackHelper* helper = new EventCallbackHelper; 1550 EventCallbackHelper* helper = new EventCallbackHelper;
1551 helper_.reset(helper); 1551 helper_.reset(helper);
1552 1552
1553 GURL pattern("http://www.example.com/one/"); 1553 GURL pattern("http://www.example.com/one/");
(...skipping 15 matching lines...) Expand all
1569 helper->set_install_callback( 1569 helper->set_install_callback(
1570 base::Bind(&ServiceWorkerVersion::RemoveControllee, 1570 base::Bind(&ServiceWorkerVersion::RemoveControllee,
1571 old_version, host.get())); 1571 old_version, host.get()));
1572 helper->set_activate_event_result(blink::WebServiceWorkerEventResultRejected); 1572 helper->set_activate_event_result(blink::WebServiceWorkerEventResultRejected);
1573 EXPECT_EQ(registration, RunRegisterJob(pattern, script2)); 1573 EXPECT_EQ(registration, RunRegisterJob(pattern, script2));
1574 1574
1575 // Verify the registration remains. 1575 // Verify the registration remains.
1576 EXPECT_FALSE(registration->is_uninstalling()); 1576 EXPECT_FALSE(registration->is_uninstalling());
1577 EXPECT_FALSE(registration->is_uninstalled()); 1577 EXPECT_FALSE(registration->is_uninstalled());
1578 1578
1579 EXPECT_EQ(ServiceWorkerVersion::STOPPED, old_version->running_status()); 1579 EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, old_version->running_status());
1580 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status()); 1580 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status());
1581 1581
1582 FindRegistrationForPattern(pattern, SERVICE_WORKER_OK); 1582 FindRegistrationForPattern(pattern, SERVICE_WORKER_OK);
1583 } 1583 }
1584 1584
1585 TEST_F(ServiceWorkerJobTest, HasFetchHandler) { 1585 TEST_F(ServiceWorkerJobTest, HasFetchHandler) {
1586 EventCallbackHelper* helper = new EventCallbackHelper; 1586 EventCallbackHelper* helper = new EventCallbackHelper;
1587 helper_.reset(helper); 1587 helper_.reset(helper);
1588 1588
1589 GURL pattern("http://www.example.com/"); 1589 GURL pattern("http://www.example.com/");
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 // should not be promoted to ACTIVATED because failure occur 1689 // should not be promoted to ACTIVATED because failure occur
1690 // during shutdown. 1690 // during shutdown.
1691 runner->RunUntilIdle(); 1691 runner->RunUntilIdle();
1692 base::RunLoop().RunUntilIdle(); 1692 base::RunLoop().RunUntilIdle();
1693 EXPECT_EQ(new_version.get(), registration->active_version()); 1693 EXPECT_EQ(new_version.get(), registration->active_version());
1694 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); 1694 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status());
1695 registration->RemoveListener(update_helper); 1695 registration->RemoveListener(update_helper);
1696 } 1696 }
1697 1697
1698 } // namespace content 1698 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698