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 <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" |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( | 650 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( |
651 registration.get(), script_url, 1L, helper_->context()->AsWeakPtr()); | 651 registration.get(), script_url, 1L, helper_->context()->AsWeakPtr()); |
652 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; | 652 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
653 version->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, | 653 version->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, |
654 CreateReceiverOnCurrentThread(&status)); | 654 CreateReceiverOnCurrentThread(&status)); |
655 base::RunLoop().RunUntilIdle(); | 655 base::RunLoop().RunUntilIdle(); |
656 ASSERT_EQ(SERVICE_WORKER_OK, status); | 656 ASSERT_EQ(SERVICE_WORKER_OK, status); |
657 | 657 |
658 version->SetStatus(ServiceWorkerVersion::INSTALLED); | 658 version->SetStatus(ServiceWorkerVersion::INSTALLED); |
659 registration->SetWaitingVersion(version); | 659 registration->SetWaitingVersion(version); |
660 EXPECT_EQ(ServiceWorkerVersion::RUNNING, | 660 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::RUNNING, |
661 version->running_status()); | 661 version->running_status()); |
662 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, version->status()); | 662 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, version->status()); |
663 | 663 |
664 RunUnregisterJob(GURL("http://www.example.com/")); | 664 RunUnregisterJob(GURL("http://www.example.com/")); |
665 | 665 |
666 // The version should be stopped since there is no controllee after | 666 // The version should be stopped since there is no controllee after |
667 // unregistration. | 667 // unregistration. |
668 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version->running_status()); | 668 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::STOPPED, |
| 669 version->running_status()); |
669 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status()); | 670 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status()); |
670 } | 671 } |
671 | 672 |
672 // Tests that the active worker enters the 'redundant' state upon | 673 // Tests that the active worker enters the 'redundant' state upon |
673 // unregistration. | 674 // unregistration. |
674 TEST_F(ServiceWorkerJobTest, UnregisterActiveSetsRedundant) { | 675 TEST_F(ServiceWorkerJobTest, UnregisterActiveSetsRedundant) { |
675 scoped_refptr<ServiceWorkerRegistration> registration = | 676 scoped_refptr<ServiceWorkerRegistration> registration = |
676 RunRegisterJob(GURL("http://www.example.com/"), | 677 RunRegisterJob(GURL("http://www.example.com/"), |
677 GURL("http://www.example.com/service_worker.js")); | 678 GURL("http://www.example.com/service_worker.js")); |
678 ASSERT_TRUE(registration.get()); | 679 ASSERT_TRUE(registration.get()); |
679 | 680 |
680 scoped_refptr<ServiceWorkerVersion> version = registration->active_version(); | 681 scoped_refptr<ServiceWorkerVersion> version = registration->active_version(); |
681 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version->running_status()); | 682 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::RUNNING, |
| 683 version->running_status()); |
682 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status()); | 684 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status()); |
683 | 685 |
684 RunUnregisterJob(GURL("http://www.example.com/")); | 686 RunUnregisterJob(GURL("http://www.example.com/")); |
685 | 687 |
686 // The version should be stopped since there is no controllee after | 688 // The version should be stopped since there is no controllee after |
687 // unregistration. | 689 // unregistration. |
688 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version->running_status()); | 690 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::STOPPED, |
| 691 version->running_status()); |
689 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status()); | 692 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status()); |
690 } | 693 } |
691 | 694 |
692 // Tests that the active worker enters the 'redundant' state upon | 695 // Tests that the active worker enters the 'redundant' state upon |
693 // unregistration. | 696 // unregistration. |
694 TEST_F(ServiceWorkerJobTest, | 697 TEST_F(ServiceWorkerJobTest, |
695 UnregisterActiveSetsRedundant_WaitForNoControllee) { | 698 UnregisterActiveSetsRedundant_WaitForNoControllee) { |
696 scoped_refptr<ServiceWorkerRegistration> registration = | 699 scoped_refptr<ServiceWorkerRegistration> registration = |
697 RunRegisterJob(GURL("http://www.example.com/"), | 700 RunRegisterJob(GURL("http://www.example.com/"), |
698 GURL("http://www.example.com/service_worker.js")); | 701 GURL("http://www.example.com/service_worker.js")); |
699 ASSERT_TRUE(registration.get()); | 702 ASSERT_TRUE(registration.get()); |
700 | 703 |
701 std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee(); | 704 std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee(); |
702 registration->active_version()->AddControllee(host.get()); | 705 registration->active_version()->AddControllee(host.get()); |
703 | 706 |
704 scoped_refptr<ServiceWorkerVersion> version = registration->active_version(); | 707 scoped_refptr<ServiceWorkerVersion> version = registration->active_version(); |
705 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version->running_status()); | 708 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::RUNNING, |
| 709 version->running_status()); |
706 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status()); | 710 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status()); |
707 | 711 |
708 RunUnregisterJob(GURL("http://www.example.com/")); | 712 RunUnregisterJob(GURL("http://www.example.com/")); |
709 | 713 |
710 // The version should be running since there is still a controllee. | 714 // The version should be running since there is still a controllee. |
711 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version->running_status()); | 715 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::RUNNING, |
| 716 version->running_status()); |
712 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status()); | 717 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status()); |
713 | 718 |
714 registration->active_version()->RemoveControllee(host.get()); | 719 registration->active_version()->RemoveControllee(host.get()); |
715 base::RunLoop().RunUntilIdle(); | 720 base::RunLoop().RunUntilIdle(); |
716 | 721 |
717 // The version should be stopped since there is no controllee. | 722 // The version should be stopped since there is no controllee. |
718 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version->running_status()); | 723 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::STOPPED, |
| 724 version->running_status()); |
719 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status()); | 725 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status()); |
720 } | 726 } |
721 | 727 |
722 namespace { // Helpers for the update job tests. | 728 namespace { // Helpers for the update job tests. |
723 | 729 |
724 const GURL kNoChangeOrigin("http://nochange/"); | 730 const GURL kNoChangeOrigin("http://nochange/"); |
725 const GURL kNewVersionOrigin("http://newversion/"); | 731 const GURL kNewVersionOrigin("http://newversion/"); |
726 const std::string kScope("scope/"); | 732 const std::string kScope("scope/"); |
727 const std::string kScript("script.js"); | 733 const std::string kScript("script.js"); |
728 | 734 |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 | 1251 |
1246 EXPECT_FALSE(registration->is_uninstalling()); | 1252 EXPECT_FALSE(registration->is_uninstalling()); |
1247 EXPECT_EQ(old_version, registration->active_version()); | 1253 EXPECT_EQ(old_version, registration->active_version()); |
1248 | 1254 |
1249 scoped_refptr<ServiceWorkerVersion> new_version = | 1255 scoped_refptr<ServiceWorkerVersion> new_version = |
1250 registration->waiting_version(); | 1256 registration->waiting_version(); |
1251 | 1257 |
1252 // Verify the new version is installed but not activated yet. | 1258 // Verify the new version is installed but not activated yet. |
1253 EXPECT_EQ(NULL, registration->installing_version()); | 1259 EXPECT_EQ(NULL, registration->installing_version()); |
1254 EXPECT_TRUE(new_version); | 1260 EXPECT_TRUE(new_version); |
1255 EXPECT_EQ(ServiceWorkerVersion::RUNNING, new_version->running_status()); | 1261 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::RUNNING, |
| 1262 new_version->running_status()); |
1256 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, new_version->status()); | 1263 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, new_version->status()); |
1257 | 1264 |
1258 old_version->RemoveControllee(host.get()); | 1265 old_version->RemoveControllee(host.get()); |
1259 base::RunLoop().RunUntilIdle(); | 1266 base::RunLoop().RunUntilIdle(); |
1260 | 1267 |
1261 EXPECT_FALSE(registration->is_uninstalling()); | 1268 EXPECT_FALSE(registration->is_uninstalling()); |
1262 EXPECT_FALSE(registration->is_uninstalled()); | 1269 EXPECT_FALSE(registration->is_uninstalled()); |
1263 | 1270 |
1264 // Verify the new version is activated. | 1271 // Verify the new version is activated. |
1265 EXPECT_EQ(NULL, registration->installing_version()); | 1272 EXPECT_EQ(NULL, registration->installing_version()); |
1266 EXPECT_EQ(NULL, registration->waiting_version()); | 1273 EXPECT_EQ(NULL, registration->waiting_version()); |
1267 EXPECT_EQ(new_version, registration->active_version()); | 1274 EXPECT_EQ(new_version, registration->active_version()); |
1268 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); | 1275 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); |
1269 | 1276 |
1270 runner->RunUntilIdle(); | 1277 runner->RunUntilIdle(); |
1271 base::RunLoop().RunUntilIdle(); | 1278 base::RunLoop().RunUntilIdle(); |
1272 EXPECT_EQ(ServiceWorkerVersion::RUNNING, new_version->running_status()); | 1279 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::RUNNING, |
| 1280 new_version->running_status()); |
1273 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status()); | 1281 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status()); |
1274 } | 1282 } |
1275 | 1283 |
1276 TEST_F(ServiceWorkerJobTest, RegisterAndUnregisterWhileUninstalling) { | 1284 TEST_F(ServiceWorkerJobTest, RegisterAndUnregisterWhileUninstalling) { |
1277 GURL pattern("http://www.example.com/one/"); | 1285 GURL pattern("http://www.example.com/one/"); |
1278 GURL script1("http://www.example.com/service_worker.js"); | 1286 GURL script1("http://www.example.com/service_worker.js"); |
1279 GURL script2("http://www.example.com/service_worker.js?new"); | 1287 GURL script2("http://www.example.com/service_worker.js?new"); |
1280 | 1288 |
1281 scoped_refptr<ServiceWorkerRegistration> registration = | 1289 scoped_refptr<ServiceWorkerRegistration> registration = |
1282 RunRegisterJob(pattern, script1); | 1290 RunRegisterJob(pattern, script1); |
(...skipping 14 matching lines...) Expand all Loading... |
1297 | 1305 |
1298 // Unregister the registration (but it's still live). | 1306 // Unregister the registration (but it's still live). |
1299 RunUnregisterJob(pattern); | 1307 RunUnregisterJob(pattern); |
1300 // Now it's not found in the storage. | 1308 // Now it's not found in the storage. |
1301 RunUnregisterJob(pattern, SERVICE_WORKER_ERROR_NOT_FOUND); | 1309 RunUnregisterJob(pattern, SERVICE_WORKER_ERROR_NOT_FOUND); |
1302 | 1310 |
1303 FindRegistrationForPattern(pattern, SERVICE_WORKER_ERROR_NOT_FOUND); | 1311 FindRegistrationForPattern(pattern, SERVICE_WORKER_ERROR_NOT_FOUND); |
1304 EXPECT_TRUE(registration->is_uninstalling()); | 1312 EXPECT_TRUE(registration->is_uninstalling()); |
1305 EXPECT_EQ(old_version, registration->active_version()); | 1313 EXPECT_EQ(old_version, registration->active_version()); |
1306 | 1314 |
1307 EXPECT_EQ(ServiceWorkerVersion::RUNNING, old_version->running_status()); | 1315 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::RUNNING, |
| 1316 old_version->running_status()); |
1308 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, old_version->status()); | 1317 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, old_version->status()); |
1309 EXPECT_EQ(ServiceWorkerVersion::RUNNING, new_version->running_status()); | 1318 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::RUNNING, |
| 1319 new_version->running_status()); |
1310 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, new_version->status()); | 1320 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, new_version->status()); |
1311 | 1321 |
1312 old_version->RemoveControllee(host.get()); | 1322 old_version->RemoveControllee(host.get()); |
1313 base::RunLoop().RunUntilIdle(); | 1323 base::RunLoop().RunUntilIdle(); |
1314 | 1324 |
1315 EXPECT_FALSE(registration->is_uninstalling()); | 1325 EXPECT_FALSE(registration->is_uninstalling()); |
1316 EXPECT_TRUE(registration->is_uninstalled()); | 1326 EXPECT_TRUE(registration->is_uninstalled()); |
1317 | 1327 |
1318 EXPECT_EQ(ServiceWorkerVersion::STOPPED, old_version->running_status()); | 1328 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::STOPPED, |
| 1329 old_version->running_status()); |
1319 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status()); | 1330 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status()); |
1320 EXPECT_EQ(ServiceWorkerVersion::STOPPED, new_version->running_status()); | 1331 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::STOPPED, |
| 1332 new_version->running_status()); |
1321 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, new_version->status()); | 1333 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, new_version->status()); |
1322 } | 1334 } |
1323 | 1335 |
1324 TEST_F(ServiceWorkerJobTest, RegisterSameScriptMultipleTimesWhileUninstalling) { | 1336 TEST_F(ServiceWorkerJobTest, RegisterSameScriptMultipleTimesWhileUninstalling) { |
1325 GURL pattern("http://www.example.com/one/"); | 1337 GURL pattern("http://www.example.com/one/"); |
1326 GURL script1("http://www.example.com/service_worker.js"); | 1338 GURL script1("http://www.example.com/service_worker.js"); |
1327 GURL script2("http://www.example.com/service_worker.js?new"); | 1339 GURL script2("http://www.example.com/service_worker.js?new"); |
1328 | 1340 |
1329 scoped_refptr<ServiceWorkerRegistration> registration = | 1341 scoped_refptr<ServiceWorkerRegistration> registration = |
1330 RunRegisterJob(pattern, script1); | 1342 RunRegisterJob(pattern, script1); |
(...skipping 30 matching lines...) Expand all Loading... |
1361 EXPECT_FALSE(registration->is_uninstalled()); | 1373 EXPECT_FALSE(registration->is_uninstalled()); |
1362 | 1374 |
1363 // Verify the new version is activated. | 1375 // Verify the new version is activated. |
1364 EXPECT_EQ(NULL, registration->installing_version()); | 1376 EXPECT_EQ(NULL, registration->installing_version()); |
1365 EXPECT_EQ(NULL, registration->waiting_version()); | 1377 EXPECT_EQ(NULL, registration->waiting_version()); |
1366 EXPECT_EQ(new_version, registration->active_version()); | 1378 EXPECT_EQ(new_version, registration->active_version()); |
1367 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); | 1379 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); |
1368 | 1380 |
1369 runner->RunUntilIdle(); | 1381 runner->RunUntilIdle(); |
1370 base::RunLoop().RunUntilIdle(); | 1382 base::RunLoop().RunUntilIdle(); |
1371 EXPECT_EQ(ServiceWorkerVersion::RUNNING, new_version->running_status()); | 1383 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::RUNNING, |
| 1384 new_version->running_status()); |
1372 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status()); | 1385 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status()); |
1373 } | 1386 } |
1374 | 1387 |
1375 TEST_F(ServiceWorkerJobTest, RegisterMultipleTimesWhileUninstalling) { | 1388 TEST_F(ServiceWorkerJobTest, RegisterMultipleTimesWhileUninstalling) { |
1376 GURL pattern("http://www.example.com/one/"); | 1389 GURL pattern("http://www.example.com/one/"); |
1377 GURL script1("http://www.example.com/service_worker.js?first"); | 1390 GURL script1("http://www.example.com/service_worker.js?first"); |
1378 GURL script2("http://www.example.com/service_worker.js?second"); | 1391 GURL script2("http://www.example.com/service_worker.js?second"); |
1379 GURL script3("http://www.example.com/service_worker.js?third"); | 1392 GURL script3("http://www.example.com/service_worker.js?third"); |
1380 | 1393 |
1381 scoped_refptr<ServiceWorkerRegistration> registration = | 1394 scoped_refptr<ServiceWorkerRegistration> registration = |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 EXPECT_FALSE(registration->is_uninstalled()); | 1430 EXPECT_FALSE(registration->is_uninstalled()); |
1418 | 1431 |
1419 // Verify the new version is activated. | 1432 // Verify the new version is activated. |
1420 EXPECT_EQ(NULL, registration->installing_version()); | 1433 EXPECT_EQ(NULL, registration->installing_version()); |
1421 EXPECT_EQ(NULL, registration->waiting_version()); | 1434 EXPECT_EQ(NULL, registration->waiting_version()); |
1422 EXPECT_EQ(third_version, registration->active_version()); | 1435 EXPECT_EQ(third_version, registration->active_version()); |
1423 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, third_version->status()); | 1436 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, third_version->status()); |
1424 | 1437 |
1425 runner->RunUntilIdle(); | 1438 runner->RunUntilIdle(); |
1426 base::RunLoop().RunUntilIdle(); | 1439 base::RunLoop().RunUntilIdle(); |
1427 EXPECT_EQ(ServiceWorkerVersion::RUNNING, third_version->running_status()); | 1440 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::RUNNING, |
| 1441 third_version->running_status()); |
1428 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, third_version->status()); | 1442 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, third_version->status()); |
1429 } | 1443 } |
1430 | 1444 |
1431 class EventCallbackHelper : public EmbeddedWorkerTestHelper { | 1445 class EventCallbackHelper : public EmbeddedWorkerTestHelper { |
1432 public: | 1446 public: |
1433 EventCallbackHelper() | 1447 EventCallbackHelper() |
1434 : EmbeddedWorkerTestHelper(base::FilePath()), | 1448 : EmbeddedWorkerTestHelper(base::FilePath()), |
1435 install_event_result_(blink::WebServiceWorkerEventResultCompleted), | 1449 install_event_result_(blink::WebServiceWorkerEventResultCompleted), |
1436 activate_event_result_(blink::WebServiceWorkerEventResultCompleted) {} | 1450 activate_event_result_(blink::WebServiceWorkerEventResultCompleted) {} |
1437 | 1451 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1496 EXPECT_FALSE(registration->is_uninstalling()); | 1510 EXPECT_FALSE(registration->is_uninstalling()); |
1497 EXPECT_FALSE(registration->is_uninstalled()); | 1511 EXPECT_FALSE(registration->is_uninstalled()); |
1498 | 1512 |
1499 // Verify the new version is activated. | 1513 // Verify the new version is activated. |
1500 scoped_refptr<ServiceWorkerVersion> new_version = | 1514 scoped_refptr<ServiceWorkerVersion> new_version = |
1501 registration->active_version(); | 1515 registration->active_version(); |
1502 EXPECT_NE(old_version, new_version); | 1516 EXPECT_NE(old_version, new_version); |
1503 EXPECT_EQ(NULL, registration->installing_version()); | 1517 EXPECT_EQ(NULL, registration->installing_version()); |
1504 EXPECT_EQ(NULL, registration->waiting_version()); | 1518 EXPECT_EQ(NULL, registration->waiting_version()); |
1505 EXPECT_EQ(new_version, registration->active_version()); | 1519 EXPECT_EQ(new_version, registration->active_version()); |
1506 EXPECT_EQ(ServiceWorkerVersion::RUNNING, new_version->running_status()); | 1520 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::RUNNING, |
| 1521 new_version->running_status()); |
1507 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status()); | 1522 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status()); |
1508 | 1523 |
1509 EXPECT_EQ(registration, FindRegistrationForPattern(pattern)); | 1524 EXPECT_EQ(registration, FindRegistrationForPattern(pattern)); |
1510 } | 1525 } |
1511 | 1526 |
1512 TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringRejectedInstall) { | 1527 TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringRejectedInstall) { |
1513 EventCallbackHelper* helper = new EventCallbackHelper; | 1528 EventCallbackHelper* helper = new EventCallbackHelper; |
1514 helper_.reset(helper); | 1529 helper_.reset(helper); |
1515 | 1530 |
1516 GURL pattern("http://www.example.com/one/"); | 1531 GURL pattern("http://www.example.com/one/"); |
(...skipping 15 matching lines...) Expand all Loading... |
1532 helper->set_install_callback( | 1547 helper->set_install_callback( |
1533 base::Bind(&ServiceWorkerVersion::RemoveControllee, | 1548 base::Bind(&ServiceWorkerVersion::RemoveControllee, |
1534 old_version, host.get())); | 1549 old_version, host.get())); |
1535 helper->set_install_event_result(blink::WebServiceWorkerEventResultRejected); | 1550 helper->set_install_event_result(blink::WebServiceWorkerEventResultRejected); |
1536 EXPECT_EQ(registration, RunRegisterJob(pattern, script2)); | 1551 EXPECT_EQ(registration, RunRegisterJob(pattern, script2)); |
1537 | 1552 |
1538 // Verify the registration was uninstalled. | 1553 // Verify the registration was uninstalled. |
1539 EXPECT_FALSE(registration->is_uninstalling()); | 1554 EXPECT_FALSE(registration->is_uninstalling()); |
1540 EXPECT_TRUE(registration->is_uninstalled()); | 1555 EXPECT_TRUE(registration->is_uninstalled()); |
1541 | 1556 |
1542 EXPECT_EQ(ServiceWorkerVersion::STOPPED, old_version->running_status()); | 1557 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::STOPPED, |
| 1558 old_version->running_status()); |
1543 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status()); | 1559 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status()); |
1544 | 1560 |
1545 FindRegistrationForPattern(pattern, SERVICE_WORKER_ERROR_NOT_FOUND); | 1561 FindRegistrationForPattern(pattern, SERVICE_WORKER_ERROR_NOT_FOUND); |
1546 } | 1562 } |
1547 | 1563 |
1548 TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall_RejectActivate) { | 1564 TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall_RejectActivate) { |
1549 EventCallbackHelper* helper = new EventCallbackHelper; | 1565 EventCallbackHelper* helper = new EventCallbackHelper; |
1550 helper_.reset(helper); | 1566 helper_.reset(helper); |
1551 | 1567 |
1552 GURL pattern("http://www.example.com/one/"); | 1568 GURL pattern("http://www.example.com/one/"); |
(...skipping 15 matching lines...) Expand all Loading... |
1568 helper->set_install_callback( | 1584 helper->set_install_callback( |
1569 base::Bind(&ServiceWorkerVersion::RemoveControllee, | 1585 base::Bind(&ServiceWorkerVersion::RemoveControllee, |
1570 old_version, host.get())); | 1586 old_version, host.get())); |
1571 helper->set_activate_event_result(blink::WebServiceWorkerEventResultRejected); | 1587 helper->set_activate_event_result(blink::WebServiceWorkerEventResultRejected); |
1572 EXPECT_EQ(registration, RunRegisterJob(pattern, script2)); | 1588 EXPECT_EQ(registration, RunRegisterJob(pattern, script2)); |
1573 | 1589 |
1574 // Verify the registration remains. | 1590 // Verify the registration remains. |
1575 EXPECT_FALSE(registration->is_uninstalling()); | 1591 EXPECT_FALSE(registration->is_uninstalling()); |
1576 EXPECT_FALSE(registration->is_uninstalled()); | 1592 EXPECT_FALSE(registration->is_uninstalled()); |
1577 | 1593 |
1578 EXPECT_EQ(ServiceWorkerVersion::STOPPED, old_version->running_status()); | 1594 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::STOPPED, |
| 1595 old_version->running_status()); |
1579 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status()); | 1596 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status()); |
1580 | 1597 |
1581 FindRegistrationForPattern(pattern, SERVICE_WORKER_OK); | 1598 FindRegistrationForPattern(pattern, SERVICE_WORKER_OK); |
1582 } | 1599 } |
1583 | 1600 |
1584 TEST_F(ServiceWorkerJobTest, HasFetchHandler) { | 1601 TEST_F(ServiceWorkerJobTest, HasFetchHandler) { |
1585 EventCallbackHelper* helper = new EventCallbackHelper; | 1602 EventCallbackHelper* helper = new EventCallbackHelper; |
1586 helper_.reset(helper); | 1603 helper_.reset(helper); |
1587 | 1604 |
1588 GURL pattern("http://www.example.com/"); | 1605 GURL pattern("http://www.example.com/"); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 // should not be promoted to ACTIVATED because failure occur | 1705 // should not be promoted to ACTIVATED because failure occur |
1689 // during shutdown. | 1706 // during shutdown. |
1690 runner->RunUntilIdle(); | 1707 runner->RunUntilIdle(); |
1691 base::RunLoop().RunUntilIdle(); | 1708 base::RunLoop().RunUntilIdle(); |
1692 EXPECT_EQ(new_version.get(), registration->active_version()); | 1709 EXPECT_EQ(new_version.get(), registration->active_version()); |
1693 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); | 1710 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); |
1694 registration->RemoveListener(update_helper); | 1711 registration->RemoveListener(update_helper); |
1695 } | 1712 } |
1696 | 1713 |
1697 } // namespace content | 1714 } // namespace content |
OLD | NEW |