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

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: Rebase 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
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/run_loop.h"
13 #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"
14 #include "chrome/browser/infobars/infobar_service.h" 17 #include "chrome/browser/infobars/infobar_service.h"
15 #include "chrome/browser/notifications/notification_test_util.h" 18 #include "chrome/browser/notifications/notification_test_util.h"
16 #include "chrome/browser/notifications/platform_notification_service_impl.h" 19 #include "chrome/browser/notifications/platform_notification_service_impl.h"
17 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/push_messaging/push_messaging_application_id.h" 21 #include "chrome/browser/push_messaging/push_messaging_application_id.h"
19 #include "chrome/browser/push_messaging/push_messaging_constants.h" 22 #include "chrome/browser/push_messaging/push_messaging_constants.h"
20 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" 23 #include "chrome/browser/push_messaging/push_messaging_service_factory.h"
21 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" 24 #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
22 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" 25 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
23 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 26 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 // if the rules it used to have have been reset. 1020 // if the rules it used to have have been reset.
1018 // The Push service should not unsubcribe |origin| because at no point it was 1021 // The Push service should not unsubcribe |origin| because at no point it was
1019 // left without permission to use Push. 1022 // left without permission to use Push.
1020 1023
1021 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); 1024 ASSERT_TRUE(RunScript("hasPermission()", &script_result));
1022 EXPECT_EQ("permission status - granted", script_result); 1025 EXPECT_EQ("permission status - granted", script_result);
1023 1026
1024 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); 1027 ASSERT_TRUE(RunScript("hasRegistration()", &script_result));
1025 EXPECT_EQ("true - registered", script_result); 1028 EXPECT_EQ("true - registered", script_result);
1026 } 1029 }
1030
1031 // Checks that automatically unsubscribing due to a revoked permission is
1032 // handled well if the sender ID needed to unregister was already deleted.
1033 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
1034 ResetPushPermissionAfterClearingSiteData) {
1035 std::string script_result;
1036
1037 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */);
1038
1039 PushMessagingApplicationId app_id = GetServiceWorkerAppId(0LL);
1040 EXPECT_EQ(app_id.app_id_guid(), gcm_service()->last_registered_app_id());
1041 PushMessagingApplicationId stored_app_id = PushMessagingApplicationId::Get(
1042 browser()->profile(), app_id.app_id_guid());
1043 EXPECT_TRUE(stored_app_id.IsValid());
1044
1045 // Simulate a user clearing site data (including Service Workers, crucially).
1046 BrowsingDataRemover* remover =
1047 BrowsingDataRemover::CreateForUnboundedRange(browser()->profile());
1048 BrowsingDataRemoverCompletionObserver observer(remover);
1049 remover->Remove(BrowsingDataRemover::REMOVE_SITE_DATA,
1050 BrowsingDataHelper::UNPROTECTED_WEB);
1051 observer.BlockUntilCompletion();
1052 // BrowsingDataRemover deletes itself.
1053
1054 base::RunLoop run_loop;
1055 push_service()->SetContentSettingChangedCallbackForTesting(
1056 run_loop.QuitClosure());
1057
1058 // This shouldn't (asynchronously) cause a DCHECK.
1059 // TODO(johnme): Get this test running on Android, since that's where the
1060 // 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
1061 browser()->profile()->GetHostContentSettingsMap()->
1062 ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING);
1063
1064 run_loop.Run();
1065
1066 // app_id should no longer be stored in prefs
1067 PushMessagingApplicationId stored_app_id2 = PushMessagingApplicationId::Get(
1068 browser()->profile(), app_id.app_id_guid());
1069 EXPECT_FALSE(stored_app_id2.IsValid());
1070 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698