| 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 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 | 1613 |
| 1614 // The initial version should not pause after download. | 1614 // The initial version should not pause after download. |
| 1615 scoped_refptr<ServiceWorkerRegistration> registration = | 1615 scoped_refptr<ServiceWorkerRegistration> registration = |
| 1616 update_helper->SetupInitialRegistration(kNewVersionOrigin); | 1616 update_helper->SetupInitialRegistration(kNewVersionOrigin); |
| 1617 { | 1617 { |
| 1618 const IPC::Message* start_msg = | 1618 const IPC::Message* start_msg = |
| 1619 sink->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID); | 1619 sink->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID); |
| 1620 ASSERT_TRUE(start_msg); | 1620 ASSERT_TRUE(start_msg); |
| 1621 EmbeddedWorkerMsg_StartWorker::Param param; | 1621 EmbeddedWorkerMsg_StartWorker::Param param; |
| 1622 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); | 1622 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); |
| 1623 EmbeddedWorkerMsg_StartWorker_Params start_params = std::get<0>(param); | 1623 const EmbeddedWorkerStartParams& start_params = std::get<0>(param); |
| 1624 EXPECT_FALSE(start_params.pause_after_download); | 1624 EXPECT_FALSE(start_params.pause_after_download); |
| 1625 sink->ClearMessages(); | 1625 sink->ClearMessages(); |
| 1626 } | 1626 } |
| 1627 | 1627 |
| 1628 // The updated version should pause after download. | 1628 // The updated version should pause after download. |
| 1629 registration->AddListener(update_helper); | 1629 registration->AddListener(update_helper); |
| 1630 registration->active_version()->StartUpdate(); | 1630 registration->active_version()->StartUpdate(); |
| 1631 base::RunLoop().RunUntilIdle(); | 1631 base::RunLoop().RunUntilIdle(); |
| 1632 { | 1632 { |
| 1633 const IPC::Message* start_msg = | 1633 const IPC::Message* start_msg = |
| 1634 sink->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID); | 1634 sink->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID); |
| 1635 ASSERT_TRUE(start_msg); | 1635 ASSERT_TRUE(start_msg); |
| 1636 EmbeddedWorkerMsg_StartWorker::Param param; | 1636 EmbeddedWorkerMsg_StartWorker::Param param; |
| 1637 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); | 1637 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); |
| 1638 EmbeddedWorkerMsg_StartWorker_Params start_params = std::get<0>(param); | 1638 const EmbeddedWorkerStartParams& start_params = std::get<0>(param); |
| 1639 EXPECT_TRUE(start_params.pause_after_download); | 1639 EXPECT_TRUE(start_params.pause_after_download); |
| 1640 sink->ClearMessages(); | 1640 sink->ClearMessages(); |
| 1641 } | 1641 } |
| 1642 } | 1642 } |
| 1643 | 1643 |
| 1644 // Test that activation doesn't complete if it's triggered by removing a | 1644 // Test that activation doesn't complete if it's triggered by removing a |
| 1645 // controllee and starting the worker failed due to shutdown. | 1645 // controllee and starting the worker failed due to shutdown. |
| 1646 TEST_F(ServiceWorkerJobTest, ActivateCancelsOnShutdown) { | 1646 TEST_F(ServiceWorkerJobTest, ActivateCancelsOnShutdown) { |
| 1647 UpdateJobTestHelper* update_helper = new UpdateJobTestHelper; | 1647 UpdateJobTestHelper* update_helper = new UpdateJobTestHelper; |
| 1648 helper_.reset(update_helper); | 1648 helper_.reset(update_helper); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 // should not be promoted to ACTIVATED because failure occur | 1692 // should not be promoted to ACTIVATED because failure occur |
| 1693 // during shutdown. | 1693 // during shutdown. |
| 1694 runner->RunUntilIdle(); | 1694 runner->RunUntilIdle(); |
| 1695 base::RunLoop().RunUntilIdle(); | 1695 base::RunLoop().RunUntilIdle(); |
| 1696 EXPECT_EQ(new_version.get(), registration->active_version()); | 1696 EXPECT_EQ(new_version.get(), registration->active_version()); |
| 1697 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); | 1697 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); |
| 1698 registration->RemoveListener(update_helper); | 1698 registration->RemoveListener(update_helper); |
| 1699 } | 1699 } |
| 1700 | 1700 |
| 1701 } // namespace content | 1701 } // namespace content |
| OLD | NEW |