Chromium Code Reviews| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/barrier_closure.h" | 11 #include "base/barrier_closure.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/test/histogram_tester.h" | 18 #include "base/test/histogram_tester.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 21 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 22 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 22 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 23 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 23 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 24 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 24 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| 25 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 25 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 26 #include "chrome/browser/engagement/site_engagement_service.h" | 26 #include "chrome/browser/engagement/site_engagement_service.h" |
| 27 #include "chrome/browser/gcm/fake_gcm_profile_service.h" | 27 #include "chrome/browser/gcm/fake_gcm_profile_service.h" |
| 28 #include "chrome/browser/gcm/gcm_profile_service_factory.h" | 28 #include "chrome/browser/gcm/gcm_profile_service_factory.h" |
| 29 #include "chrome/browser/gcm/instance_id/instance_id_profile_service.h" | |
| 30 #include "chrome/browser/gcm/instance_id/instance_id_profile_service_factory.h" | |
| 29 #include "chrome/browser/lifetime/keep_alive_registry.h" | 31 #include "chrome/browser/lifetime/keep_alive_registry.h" |
| 30 #include "chrome/browser/lifetime/keep_alive_types.h" | 32 #include "chrome/browser/lifetime/keep_alive_types.h" |
| 31 #include "chrome/browser/notifications/message_center_display_service.h" | 33 #include "chrome/browser/notifications/message_center_display_service.h" |
| 32 #include "chrome/browser/notifications/notification_test_util.h" | 34 #include "chrome/browser/notifications/notification_test_util.h" |
| 33 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 35 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 34 #include "chrome/browser/permissions/permission_request_manager.h" | 36 #include "chrome/browser/permissions/permission_request_manager.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" | 38 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" |
| 37 #include "chrome/browser/push_messaging/push_messaging_constants.h" | 39 #include "chrome/browser/push_messaging/push_messaging_constants.h" |
| 38 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" | 40 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" |
| 39 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" | 41 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" |
| 40 #include "chrome/browser/ui/browser.h" | 42 #include "chrome/browser/ui/browser.h" |
| 41 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 43 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 42 #include "chrome/common/chrome_switches.h" | 44 #include "chrome/common/chrome_switches.h" |
| 43 #include "chrome/common/features.h" | 45 #include "chrome/common/features.h" |
| 44 #include "chrome/test/base/in_process_browser_test.h" | 46 #include "chrome/test/base/in_process_browser_test.h" |
| 45 #include "chrome/test/base/ui_test_utils.h" | 47 #include "chrome/test/base/ui_test_utils.h" |
| 46 #include "components/content_settings/core/browser/host_content_settings_map.h" | 48 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 47 #include "components/content_settings/core/common/content_settings.h" | 49 #include "components/content_settings/core/common/content_settings.h" |
| 48 #include "components/content_settings/core/common/content_settings_types.h" | 50 #include "components/content_settings/core/common/content_settings_types.h" |
| 49 #include "components/gcm_driver/common/gcm_messages.h" | 51 #include "components/gcm_driver/common/gcm_messages.h" |
| 50 #include "components/gcm_driver/gcm_client.h" | 52 #include "components/gcm_driver/gcm_client.h" |
| 51 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" | 53 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" |
| 54 #include "components/gcm_driver/instance_id/instance_id_driver.h" | |
| 52 #include "content/public/browser/web_contents.h" | 55 #include "content/public/browser/web_contents.h" |
| 53 #include "content/public/common/content_switches.h" | 56 #include "content/public/common/content_switches.h" |
| 54 #include "content/public/common/push_subscription_options.h" | 57 #include "content/public/common/push_subscription_options.h" |
| 55 #include "content/public/test/browser_test_utils.h" | 58 #include "content/public/test/browser_test_utils.h" |
| 56 #include "content/public/test/test_utils.h" | 59 #include "content/public/test/test_utils.h" |
| 57 #include "net/test/embedded_test_server/embedded_test_server.h" | 60 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 58 #include "testing/gmock/include/gmock/gmock.h" | 61 #include "testing/gmock/include/gmock/gmock.h" |
| 59 #include "ui/base/window_open_disposition.h" | 62 #include "ui/base/window_open_disposition.h" |
| 60 | 63 |
| 61 #if BUILDFLAG(ENABLE_BACKGROUND) | 64 #if BUILDFLAG(ENABLE_BACKGROUND) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 void DidRegister(base::Closure done_callback, | 104 void DidRegister(base::Closure done_callback, |
| 102 const std::string& registration_id, | 105 const std::string& registration_id, |
| 103 const std::vector<uint8_t>& p256dh, | 106 const std::vector<uint8_t>& p256dh, |
| 104 const std::vector<uint8_t>& auth, | 107 const std::vector<uint8_t>& auth, |
| 105 content::PushRegistrationStatus status) { | 108 content::PushRegistrationStatus status) { |
| 106 EXPECT_EQ(content::PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE, | 109 EXPECT_EQ(content::PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE, |
| 107 status); | 110 status); |
| 108 done_callback.Run(); | 111 done_callback.Run(); |
| 109 } | 112 } |
| 110 | 113 |
| 114 void InstanceIDResultCallback(base::Closure done_callback, | |
| 115 instance_id::InstanceID::Result* out_result, | |
| 116 instance_id::InstanceID::Result result) { | |
| 117 if (out_result) | |
|
Peter Beverloo
2017/03/20 23:50:13
if -> DCHECK, it's always given
johnme
2017/03/30 18:36:38
Done.
| |
| 118 *out_result = result; | |
| 119 done_callback.Run(); | |
| 120 } | |
| 121 | |
| 111 } // namespace | 122 } // namespace |
| 112 | 123 |
| 113 class PushMessagingBrowserTest : public InProcessBrowserTest { | 124 class PushMessagingBrowserTest : public InProcessBrowserTest { |
| 114 public: | 125 public: |
| 115 PushMessagingBrowserTest() : gcm_service_(nullptr), gcm_driver_(nullptr) {} | 126 PushMessagingBrowserTest() : gcm_service_(nullptr), gcm_driver_(nullptr) {} |
| 116 ~PushMessagingBrowserTest() override {} | 127 ~PushMessagingBrowserTest() override {} |
| 117 | 128 |
| 118 // InProcessBrowserTest: | 129 // InProcessBrowserTest: |
| 119 void SetUp() override { | 130 void SetUp() override { |
| 120 https_server_.reset( | 131 https_server_.reset( |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 // for testing that we maintain support for existing stored registrations. | 245 // for testing that we maintain support for existing stored registrations. |
| 235 // Calls should be wrapped in the ASSERT_NO_FATAL_FAILURE() macro. | 246 // Calls should be wrapped in the ASSERT_NO_FATAL_FAILURE() macro. |
| 236 void LegacySubscribeSuccessfully(std::string* out_subscription_id = nullptr); | 247 void LegacySubscribeSuccessfully(std::string* out_subscription_id = nullptr); |
| 237 | 248 |
| 238 // Strips server URL from a registration endpoint to get subscription token. | 249 // Strips server URL from a registration endpoint to get subscription token. |
| 239 // Calls should be wrapped in the ASSERT_NO_FATAL_FAILURE() macro. | 250 // Calls should be wrapped in the ASSERT_NO_FATAL_FAILURE() macro. |
| 240 void EndpointToToken(const std::string& endpoint, | 251 void EndpointToToken(const std::string& endpoint, |
| 241 bool standard_protocol = true, | 252 bool standard_protocol = true, |
| 242 std::string* out_token = nullptr); | 253 std::string* out_token = nullptr); |
| 243 | 254 |
| 255 // Deletes an Instance ID from the GCM Store but keeps the push subscription | |
| 256 // stored in the PushMessagingAppIdentifier map and Service Worker DB. | |
| 257 // Calls should be wrapped in the ASSERT_NO_FATAL_FAILURE() macro. | |
| 258 void DeleteInstanceIDAsIfGCMStoreReset(const std::string& app_id); | |
| 259 | |
| 244 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( | 260 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( |
| 245 int64_t service_worker_registration_id); | 261 int64_t service_worker_registration_id); |
| 246 | 262 |
| 247 void SendMessageAndWaitUntilHandled( | 263 void SendMessageAndWaitUntilHandled( |
| 248 const PushMessagingAppIdentifier& app_identifier, | 264 const PushMessagingAppIdentifier& app_identifier, |
| 249 const gcm::IncomingMessage& message); | 265 const gcm::IncomingMessage& message); |
| 250 | 266 |
| 251 net::EmbeddedTestServer* https_server() const { return https_server_.get(); } | 267 net::EmbeddedTestServer* https_server() const { return https_server_.get(); } |
| 252 | 268 |
| 253 // To be called when delivery of a push message has finished. The |run_loop| | 269 // To be called when delivery of a push message has finished. The |run_loop| |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 | 387 |
| 372 std::string script_result; | 388 std::string script_result; |
| 373 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 389 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 374 ASSERT_EQ("ok - service worker registered", script_result); | 390 ASSERT_EQ("ok - service worker registered", script_result); |
| 375 | 391 |
| 376 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); | 392 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); |
| 377 | 393 |
| 378 GURL requesting_origin = https_server()->GetURL("/").GetOrigin(); | 394 GURL requesting_origin = https_server()->GetURL("/").GetOrigin(); |
| 379 int64_t service_worker_registration_id = 0LL; | 395 int64_t service_worker_registration_id = 0LL; |
| 380 PushMessagingAppIdentifier app_identifier = | 396 PushMessagingAppIdentifier app_identifier = |
| 381 PushMessagingAppIdentifier::Generate(requesting_origin, | 397 PushMessagingAppIdentifier::LegacyGenerateForTesting( |
| 382 service_worker_registration_id); | 398 requesting_origin, service_worker_registration_id); |
| 383 push_service_->IncreasePushSubscriptionCount(1, true /* is_pending */); | 399 push_service_->IncreasePushSubscriptionCount(1, true /* is_pending */); |
| 384 | 400 |
| 385 std::string subscription_id; | 401 std::string subscription_id; |
| 386 { | 402 { |
| 387 base::RunLoop run_loop; | 403 base::RunLoop run_loop; |
| 388 gcm::GCMClient::Result register_result = gcm::GCMClient::UNKNOWN_ERROR; | 404 gcm::GCMClient::Result register_result = gcm::GCMClient::UNKNOWN_ERROR; |
| 389 gcm_driver_->Register( | 405 gcm_driver_->Register( |
| 390 app_identifier.app_id(), {kManifestSenderId}, | 406 app_identifier.app_id(), {kManifestSenderId}, |
| 391 base::Bind(&LegacyRegisterCallback, run_loop.QuitClosure(), | 407 base::Bind(&LegacyRegisterCallback, run_loop.QuitClosure(), |
| 392 &subscription_id, ®ister_result)); | 408 &subscription_id, ®ister_result)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( | 445 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( |
| 430 int64_t service_worker_registration_id) { | 446 int64_t service_worker_registration_id) { |
| 431 GURL origin = https_server()->GetURL("/").GetOrigin(); | 447 GURL origin = https_server()->GetURL("/").GetOrigin(); |
| 432 PushMessagingAppIdentifier app_identifier = | 448 PushMessagingAppIdentifier app_identifier = |
| 433 PushMessagingAppIdentifier::FindByServiceWorker( | 449 PushMessagingAppIdentifier::FindByServiceWorker( |
| 434 GetBrowser()->profile(), origin, service_worker_registration_id); | 450 GetBrowser()->profile(), origin, service_worker_registration_id); |
| 435 EXPECT_FALSE(app_identifier.is_null()); | 451 EXPECT_FALSE(app_identifier.is_null()); |
| 436 return app_identifier; | 452 return app_identifier; |
| 437 } | 453 } |
| 438 | 454 |
| 455 void PushMessagingBrowserTest::DeleteInstanceIDAsIfGCMStoreReset( | |
| 456 const std::string& app_id) { | |
| 457 // Delete the Instance ID directly, keeping the push subscription stored in | |
| 458 // the PushMessagingAppIdentifier map and the Service Worker database. This | |
| 459 // simulates the GCM Store getting reset but failing to clear push | |
| 460 // subscriptions, either because the store got reset before | |
| 461 // 93ec793ac69a542b2213297737178a55d069fd0d (Chrome 56), or because a race | |
| 462 // condition (e.g. shutdown) prevents PushMessagingServiceImpl::OnStoreReset | |
| 463 // from clearing all subscriptions. | |
| 464 instance_id::InstanceIDProfileService* instance_id_profile_service = | |
| 465 instance_id::InstanceIDProfileServiceFactory::GetForProfile( | |
| 466 GetBrowser()->profile()); | |
| 467 DCHECK(instance_id_profile_service); | |
| 468 instance_id::InstanceIDDriver* instance_id_driver = | |
| 469 instance_id_profile_service->driver(); | |
| 470 DCHECK(instance_id_driver); | |
| 471 instance_id::InstanceID::Result delete_result = | |
| 472 instance_id::InstanceID::UNKNOWN_ERROR; | |
| 473 base::RunLoop run_loop; | |
| 474 instance_id_driver->GetInstanceID(app_id)->DeleteID(base::Bind( | |
| 475 &InstanceIDResultCallback, run_loop.QuitClosure(), &delete_result)); | |
| 476 run_loop.Run(); | |
| 477 ASSERT_EQ(instance_id::InstanceID::SUCCESS, delete_result); | |
| 478 } | |
| 479 | |
| 439 void PushMessagingBrowserTest::SendMessageAndWaitUntilHandled( | 480 void PushMessagingBrowserTest::SendMessageAndWaitUntilHandled( |
| 440 const PushMessagingAppIdentifier& app_identifier, | 481 const PushMessagingAppIdentifier& app_identifier, |
| 441 const gcm::IncomingMessage& message) { | 482 const gcm::IncomingMessage& message) { |
| 442 base::RunLoop run_loop; | 483 base::RunLoop run_loop; |
| 443 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); | 484 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); |
| 444 push_service()->OnMessage(app_identifier.app_id(), message); | 485 push_service()->OnMessage(app_identifier.app_id(), message); |
| 445 run_loop.Run(); | 486 run_loop.Run(); |
| 446 } | 487 } |
| 447 | 488 |
| 448 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 489 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| (...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1745 // We should not be able to look up the app id. | 1786 // We should not be able to look up the app id. |
| 1746 GURL origin = https_server()->GetURL("/").GetOrigin(); | 1787 GURL origin = https_server()->GetURL("/").GetOrigin(); |
| 1747 PushMessagingAppIdentifier app_identifier = | 1788 PushMessagingAppIdentifier app_identifier = |
| 1748 PushMessagingAppIdentifier::FindByServiceWorker( | 1789 PushMessagingAppIdentifier::FindByServiceWorker( |
| 1749 GetBrowser()->profile(), origin, | 1790 GetBrowser()->profile(), origin, |
| 1750 0LL /* service_worker_registration_id */); | 1791 0LL /* service_worker_registration_id */); |
| 1751 EXPECT_TRUE(app_identifier.is_null()); | 1792 EXPECT_TRUE(app_identifier.is_null()); |
| 1752 } | 1793 } |
| 1753 | 1794 |
| 1754 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 1795 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 1796 InvalidGetSubscriptionUnsubscribes) { | |
| 1797 std::string script_result; | |
| 1798 | |
| 1799 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); | |
| 1800 | |
| 1801 GURL origin = https_server()->GetURL("/").GetOrigin(); | |
| 1802 PushMessagingAppIdentifier app_identifier1 = | |
| 1803 PushMessagingAppIdentifier::FindByServiceWorker( | |
| 1804 GetBrowser()->profile(), origin, | |
| 1805 0LL /* service_worker_registration_id */); | |
| 1806 ASSERT_FALSE(app_identifier1.is_null()); | |
| 1807 | |
| 1808 ASSERT_NO_FATAL_FAILURE( | |
| 1809 DeleteInstanceIDAsIfGCMStoreReset(app_identifier1.app_id())); | |
| 1810 | |
| 1811 // Push messaging should not yet be aware of the InstanceID being deleted. | |
| 1812 histogram_tester_.ExpectTotalCount("PushMessaging.UnregistrationReason", 0); | |
| 1813 // We should still be able to look up the app id. | |
| 1814 PushMessagingAppIdentifier app_identifier2 = | |
| 1815 PushMessagingAppIdentifier::FindByServiceWorker( | |
| 1816 GetBrowser()->profile(), origin, | |
| 1817 0LL /* service_worker_registration_id */); | |
| 1818 EXPECT_FALSE(app_identifier2.is_null()); | |
| 1819 EXPECT_EQ(app_identifier1.app_id(), app_identifier2.app_id()); | |
| 1820 | |
| 1821 // Now call PushManager.getSubscription(). It should return null. | |
| 1822 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | |
| 1823 EXPECT_EQ("false - not subscribed", script_result); | |
| 1824 | |
| 1825 // This should have unsubscribed the push subscription. | |
| 1826 histogram_tester_.ExpectUniqueSample( | |
| 1827 "PushMessaging.UnregistrationReason", | |
| 1828 content::PUSH_UNREGISTRATION_REASON_GET_SUBSCRIPTION_STORAGE_CORRUPT, 1); | |
| 1829 // We should no longer be able to look up the app id. | |
| 1830 PushMessagingAppIdentifier app_identifier3 = | |
| 1831 PushMessagingAppIdentifier::FindByServiceWorker( | |
| 1832 GetBrowser()->profile(), origin, | |
| 1833 0LL /* service_worker_registration_id */); | |
| 1834 EXPECT_TRUE(app_identifier3.is_null()); | |
| 1835 } | |
| 1836 | |
| 1837 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, InvalidSubscribeUnsubscribes) { | |
| 1838 std::string script_result; | |
| 1839 | |
| 1840 std::string token1; | |
| 1841 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully(true /* use_key */, &token1)); | |
| 1842 | |
| 1843 GURL origin = https_server()->GetURL("/").GetOrigin(); | |
| 1844 PushMessagingAppIdentifier app_identifier1 = | |
| 1845 PushMessagingAppIdentifier::FindByServiceWorker( | |
| 1846 GetBrowser()->profile(), origin, | |
| 1847 0LL /* service_worker_registration_id */); | |
| 1848 ASSERT_FALSE(app_identifier1.is_null()); | |
| 1849 | |
| 1850 ASSERT_NO_FATAL_FAILURE( | |
| 1851 DeleteInstanceIDAsIfGCMStoreReset(app_identifier1.app_id())); | |
| 1852 | |
| 1853 // Push messaging should not yet be aware of the InstanceID being deleted. | |
| 1854 histogram_tester_.ExpectTotalCount("PushMessaging.UnregistrationReason", 0); | |
| 1855 // We should still be able to look up the app id. | |
| 1856 PushMessagingAppIdentifier app_identifier2 = | |
| 1857 PushMessagingAppIdentifier::FindByServiceWorker( | |
| 1858 GetBrowser()->profile(), origin, | |
| 1859 0LL /* service_worker_registration_id */); | |
| 1860 EXPECT_FALSE(app_identifier2.is_null()); | |
| 1861 EXPECT_EQ(app_identifier1.app_id(), app_identifier2.app_id()); | |
| 1862 | |
| 1863 // Now call PushManager.subscribe() again. It should succeed, but with a | |
| 1864 // *different* token, indicating that it unsubscribed and re-subscribed. | |
| 1865 std::string token2; | |
| 1866 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully(true /* use_key */, &token2)); | |
| 1867 EXPECT_NE(token1, token2); | |
| 1868 | |
| 1869 // This should have unsubscribed the original push subscription. | |
| 1870 histogram_tester_.ExpectUniqueSample( | |
| 1871 "PushMessaging.UnregistrationReason", | |
| 1872 content::PUSH_UNREGISTRATION_REASON_SUBSCRIBE_STORAGE_CORRUPT, 1); | |
| 1873 // Looking up the app id should return a different id. | |
| 1874 PushMessagingAppIdentifier app_identifier3 = | |
| 1875 PushMessagingAppIdentifier::FindByServiceWorker( | |
| 1876 GetBrowser()->profile(), origin, | |
| 1877 0LL /* service_worker_registration_id */); | |
| 1878 EXPECT_FALSE(app_identifier3.is_null()); | |
| 1879 EXPECT_NE(app_identifier2.app_id(), app_identifier3.app_id()); | |
| 1880 } | |
| 1881 | |
| 1882 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | |
| 1755 GlobalResetPushPermissionUnsubscribes) { | 1883 GlobalResetPushPermissionUnsubscribes) { |
| 1756 std::string script_result; | 1884 std::string script_result; |
| 1757 | 1885 |
| 1758 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); | 1886 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); |
| 1759 | 1887 |
| 1760 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1888 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
| 1761 EXPECT_EQ("true - subscribed", script_result); | 1889 EXPECT_EQ("true - subscribed", script_result); |
| 1762 | 1890 |
| 1763 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 1891 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
| 1764 EXPECT_EQ("permission status - granted", script_result); | 1892 EXPECT_EQ("permission status - granted", script_result); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2232 push_service()->SetUnsubscribeCallbackForTesting(run_loop.QuitClosure()); | 2360 push_service()->SetUnsubscribeCallbackForTesting(run_loop.QuitClosure()); |
| 2233 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 2361 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 2234 EXPECT_EQ("unsubscribe result: true", script_result); | 2362 EXPECT_EQ("unsubscribe result: true", script_result); |
| 2235 // Background mode is only guaranteed to have updated once the unsubscribe | 2363 // Background mode is only guaranteed to have updated once the unsubscribe |
| 2236 // callback for testing has been run (PushSubscription.unsubscribe() usually | 2364 // callback for testing has been run (PushSubscription.unsubscribe() usually |
| 2237 // resolves before that, in order to avoid blocking on network retries etc). | 2365 // resolves before that, in order to avoid blocking on network retries etc). |
| 2238 run_loop.Run(); | 2366 run_loop.Run(); |
| 2239 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 2367 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 2240 } | 2368 } |
| 2241 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 2369 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
| OLD | NEW |