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

Unified Diff: chrome/browser/push_messaging/push_messaging_browsertest.cc

Issue 990283002: Push API: Prevent DCHECK when clear permissions after clear SW DB (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@retrycallback
Patch Set: Fix typo Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_service_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 912e54429817f68a35ed57f6f140e9a3fd28dc54..397d05b7bdc0e9efd9d938050095c37c74afc7de 100644
--- a/chrome/browser/push_messaging/push_messaging_browsertest.cc
+++ b/chrome/browser/push_messaging/push_messaging_browsertest.cc
@@ -9,7 +9,11 @@
#include "base/bind.h"
#include "base/command_line.h"
#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"
@@ -1037,3 +1041,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, which has a different
+ // codepath due to sender_id being required for unregistering there.
+ 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());
+}
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698