Chromium Code Reviews| Index: chrome/browser/push_messaging/push_messaging_browsertest.cc |
| diff --git a/chrome/browser/push_messaging/push_messaging_browsertest.cc b/chrome/browser/push_messaging/push_messaging_browsertest.cc |
| index 6768fc3f23b327ce14033602b014a09b71482885..3af8474022b61fb5c8c58f82c57a4c90e006216b 100644 |
| --- a/chrome/browser/push_messaging/push_messaging_browsertest.cc |
| +++ b/chrome/browser/push_messaging/push_messaging_browsertest.cc |
| @@ -11,6 +11,9 @@ |
| #include "base/message_loop/message_loop.h" |
| #include "base/run_loop.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "chrome/browser/browsing_data/browsing_data_helper.h" |
| +#include "chrome/browser/browsing_data/browsing_data_remover.h" |
| +#include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| #include "chrome/browser/infobars/infobar_service.h" |
| #include "chrome/browser/notifications/notification_test_util.h" |
| #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| @@ -1024,3 +1027,44 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| EXPECT_EQ("true - registered", script_result); |
| } |
| + |
| +// Checks that automatically unsubscribing due to a revoked permission is |
| +// handled well if the sender ID needed to unregister was already deleted. |
| +IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| + ResetPushPermissionAfterClearingSiteData) { |
| + std::string script_result; |
| + |
| + TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); |
| + |
| + PushMessagingApplicationId app_id = GetServiceWorkerAppId(0LL); |
| + EXPECT_EQ(app_id.app_id_guid(), gcm_service()->last_registered_app_id()); |
| + PushMessagingApplicationId stored_app_id = PushMessagingApplicationId::Get( |
| + browser()->profile(), app_id.app_id_guid()); |
| + EXPECT_TRUE(stored_app_id.IsValid()); |
| + |
| + // Simulate a user clearing site data (including Service Workers, crucially). |
| + BrowsingDataRemover* remover = |
| + BrowsingDataRemover::CreateForUnboundedRange(browser()->profile()); |
| + BrowsingDataRemoverCompletionObserver observer(remover); |
| + remover->Remove(BrowsingDataRemover::REMOVE_SITE_DATA, |
| + BrowsingDataHelper::UNPROTECTED_WEB); |
| + observer.BlockUntilCompletion(); |
| + // BrowsingDataRemover deletes itself. |
| + |
| + base::RunLoop run_loop; |
| + push_service()->SetContentSettingChangedCallbackForTesting( |
| + run_loop.QuitClosure()); |
| + |
| + // This shouldn't (asynchronously) cause a DCHECK. |
| + // TODO(johnme): Get this test running on Android, since that's where the |
| + // DCHECK occurred (crbug.com/464328). |
|
mlamouri (slow - plz ping)
2015/03/13 16:25:49
Are you going to fix that bug with that CL?
Also,
johnme
2015/03/13 17:21:12
Yes, this CL fixes that bug. I've changed the comm
|
| + browser()->profile()->GetHostContentSettingsMap()-> |
| + ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING); |
| + |
| + run_loop.Run(); |
| + |
| + // app_id should no longer be stored in prefs |
| + PushMessagingApplicationId stored_app_id2 = PushMessagingApplicationId::Get( |
| + browser()->profile(), app_id.app_id_guid()); |
| + EXPECT_FALSE(stored_app_id2.IsValid()); |
| +} |