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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/barrier_closure.h" 8 #include "base/barrier_closure.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/browsing_data/browsing_data_helper.h"
15 #include "chrome/browser/browsing_data/browsing_data_remover.h"
16 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h"
13 #include "chrome/browser/infobars/infobar_service.h" 17 #include "chrome/browser/infobars/infobar_service.h"
14 #include "chrome/browser/notifications/notification_test_util.h" 18 #include "chrome/browser/notifications/notification_test_util.h"
15 #include "chrome/browser/notifications/platform_notification_service_impl.h" 19 #include "chrome/browser/notifications/platform_notification_service_impl.h"
16 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/push_messaging/push_messaging_application_id.h" 21 #include "chrome/browser/push_messaging/push_messaging_application_id.h"
18 #include "chrome/browser/push_messaging/push_messaging_constants.h" 22 #include "chrome/browser/push_messaging/push_messaging_constants.h"
19 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" 23 #include "chrome/browser/push_messaging/push_messaging_service_factory.h"
20 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" 24 #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
21 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" 25 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
22 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 26 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 // if the rules it used to have have been reset. 1034 // if the rules it used to have have been reset.
1031 // The Push service should not unsubcribe |origin| because at no point it was 1035 // The Push service should not unsubcribe |origin| because at no point it was
1032 // left without permission to use Push. 1036 // left without permission to use Push.
1033 1037
1034 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); 1038 ASSERT_TRUE(RunScript("hasPermission()", &script_result));
1035 EXPECT_EQ("permission status - granted", script_result); 1039 EXPECT_EQ("permission status - granted", script_result);
1036 1040
1037 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); 1041 ASSERT_TRUE(RunScript("hasRegistration()", &script_result));
1038 EXPECT_EQ("true - registered", script_result); 1042 EXPECT_EQ("true - registered", script_result);
1039 } 1043 }
1044
1045 // Checks that automatically unsubscribing due to a revoked permission is
1046 // handled well if the sender ID needed to unregister was already deleted.
1047 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
1048 ResetPushPermissionAfterClearingSiteData) {
1049 std::string script_result;
1050
1051 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */);
1052
1053 PushMessagingApplicationId app_id = GetServiceWorkerAppId(0LL);
1054 EXPECT_EQ(app_id.app_id_guid(), gcm_service()->last_registered_app_id());
1055 PushMessagingApplicationId stored_app_id = PushMessagingApplicationId::Get(
1056 browser()->profile(), app_id.app_id_guid());
1057 EXPECT_TRUE(stored_app_id.IsValid());
1058
1059 // Simulate a user clearing site data (including Service Workers, crucially).
1060 BrowsingDataRemover* remover =
1061 BrowsingDataRemover::CreateForUnboundedRange(browser()->profile());
1062 BrowsingDataRemoverCompletionObserver observer(remover);
1063 remover->Remove(BrowsingDataRemover::REMOVE_SITE_DATA,
1064 BrowsingDataHelper::UNPROTECTED_WEB);
1065 observer.BlockUntilCompletion();
1066 // BrowsingDataRemover deletes itself.
1067
1068 base::RunLoop run_loop;
1069 push_service()->SetContentSettingChangedCallbackForTesting(
1070 run_loop.QuitClosure());
1071
1072 // This shouldn't (asynchronously) cause a DCHECK.
1073 // TODO(johnme): Get this test running on Android, which has a different
1074 // codepath due to sender_id being required for unregistering there.
1075 browser()->profile()->GetHostContentSettingsMap()->
1076 ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING);
1077
1078 run_loop.Run();
1079
1080 // app_id should no longer be stored in prefs
1081 PushMessagingApplicationId stored_app_id2 = PushMessagingApplicationId::Get(
1082 browser()->profile(), app_id.app_id_guid());
1083 EXPECT_FALSE(stored_app_id2.IsValid());
1084 }
OLDNEW
« 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