| 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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/infobars/infobar_service.h" | 13 #include "chrome/browser/infobars/infobar_service.h" |
| 13 #include "chrome/browser/notifications/notification_test_util.h" | 14 #include "chrome/browser/notifications/notification_test_util.h" |
| 14 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 15 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/push_messaging/push_messaging_application_id.h" | 17 #include "chrome/browser/push_messaging/push_messaging_application_id.h" |
| 17 #include "chrome/browser/push_messaging/push_messaging_constants.h" | 18 #include "chrome/browser/push_messaging/push_messaging_constants.h" |
| 18 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" | 19 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 script, | 234 script, |
| 234 result); | 235 result); |
| 235 } | 236 } |
| 236 | 237 |
| 237 void TryToRegisterSuccessfully( | 238 void TryToRegisterSuccessfully( |
| 238 const std::string& expected_push_registration_id); | 239 const std::string& expected_push_registration_id); |
| 239 | 240 |
| 240 PushMessagingApplicationId GetServiceWorkerAppId( | 241 PushMessagingApplicationId GetServiceWorkerAppId( |
| 241 int64 service_worker_registration_id); | 242 int64 service_worker_registration_id); |
| 242 | 243 |
| 244 void WaitForGetUserDataRoundTrip(int64 service_worker_registration_id); |
| 245 |
| 243 net::SpawnedTestServer* https_server() const { return https_server_.get(); } | 246 net::SpawnedTestServer* https_server() const { return https_server_.get(); } |
| 244 | 247 |
| 245 gcm::FakeGCMProfileService* gcm_service() const { return gcm_service_; } | 248 gcm::FakeGCMProfileService* gcm_service() const { return gcm_service_; } |
| 246 | 249 |
| 247 #if defined(ENABLE_NOTIFICATIONS) | 250 #if defined(ENABLE_NOTIFICATIONS) |
| 248 StubNotificationUIManager* notification_manager() const { | 251 StubNotificationUIManager* notification_manager() const { |
| 249 return notification_manager_.get(); | 252 return notification_manager_.get(); |
| 250 } | 253 } |
| 251 | 254 |
| 252 PlatformNotificationServiceImpl* notification_service() const { | 255 PlatformNotificationServiceImpl* notification_service() const { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 311 |
| 309 PushMessagingApplicationId PushMessagingBrowserTest::GetServiceWorkerAppId( | 312 PushMessagingApplicationId PushMessagingBrowserTest::GetServiceWorkerAppId( |
| 310 int64 service_worker_registration_id) { | 313 int64 service_worker_registration_id) { |
| 311 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 314 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); |
| 312 PushMessagingApplicationId application_id = PushMessagingApplicationId::Get( | 315 PushMessagingApplicationId application_id = PushMessagingApplicationId::Get( |
| 313 browser()->profile(), origin, service_worker_registration_id); | 316 browser()->profile(), origin, service_worker_registration_id); |
| 314 EXPECT_TRUE(application_id.IsValid()); | 317 EXPECT_TRUE(application_id.IsValid()); |
| 315 return application_id; | 318 return application_id; |
| 316 } | 319 } |
| 317 | 320 |
| 321 static void WaitForGetUserDataRoundTripCallback( |
| 322 const std::string& data, bool success, bool not_found) { |
| 323 base::MessageLoop::current()->Quit(); |
| 324 } |
| 325 |
| 326 void PushMessagingBrowserTest::WaitForGetUserDataRoundTrip( |
| 327 int64 service_worker_registration_id) { |
| 328 PushMessagingApplicationId app_id = |
| 329 GetServiceWorkerAppId(service_worker_registration_id); |
| 330 push_service()->GetSenderId( |
| 331 browser()->profile(), |
| 332 app_id.origin(), app_id.service_worker_registration_id(), |
| 333 base::Bind(&WaitForGetUserDataRoundTripCallback)); |
| 334 content::RunMessageLoop(); |
| 335 } |
| 336 |
| 318 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 337 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 319 RegisterSuccessNotificationsGranted) { | 338 RegisterSuccessNotificationsGranted) { |
| 320 if (!IsPushSupported()) | 339 if (!IsPushSupported()) |
| 321 return; | 340 return; |
| 322 | 341 |
| 323 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); | 342 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); |
| 324 | 343 |
| 325 PushMessagingApplicationId app_id = GetServiceWorkerAppId(0LL); | 344 PushMessagingApplicationId app_id = GetServiceWorkerAppId(0LL); |
| 326 EXPECT_EQ(app_id.app_id_guid(), gcm_service()->last_registered_app_id()); | 345 EXPECT_EQ(app_id.app_id_guid(), gcm_service()->last_registered_app_id()); |
| 327 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); | 346 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 | 798 |
| 780 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 799 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 781 EXPECT_EQ("true - registered", script_result); | 800 EXPECT_EQ("true - registered", script_result); |
| 782 | 801 |
| 783 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 802 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 784 EXPECT_EQ("permission status - granted", script_result); | 803 EXPECT_EQ("permission status - granted", script_result); |
| 785 | 804 |
| 786 browser()->profile()->GetHostContentSettingsMap()-> | 805 browser()->profile()->GetHostContentSettingsMap()-> |
| 787 ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING); | 806 ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING); |
| 788 | 807 |
| 808 WaitForGetUserDataRoundTrip(0LL); |
| 809 WaitForGetUserDataRoundTrip(0LL); |
| 810 |
| 789 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 811 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 790 EXPECT_EQ("permission status - default", script_result); | 812 EXPECT_EQ("permission status - default", script_result); |
| 791 | 813 |
| 792 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 814 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 793 EXPECT_EQ("false - not registered", script_result); | 815 EXPECT_EQ("false - not registered", script_result); |
| 794 } | 816 } |
| 795 | 817 |
| 796 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 818 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 797 LocalResetPushPermissionUnregisters) { | 819 LocalResetPushPermissionUnregisters) { |
| 798 std::string script_result; | 820 std::string script_result; |
| 799 | 821 |
| 800 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); | 822 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); |
| 801 | 823 |
| 802 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 824 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 803 EXPECT_EQ("true - registered", script_result); | 825 EXPECT_EQ("true - registered", script_result); |
| 804 | 826 |
| 805 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 827 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 806 EXPECT_EQ("permission status - granted", script_result); | 828 EXPECT_EQ("permission status - granted", script_result); |
| 807 | 829 |
| 808 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 830 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); |
| 809 browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( | 831 browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( |
| 810 ContentSettingsPattern::FromURLNoWildcard(origin), | 832 ContentSettingsPattern::FromURLNoWildcard(origin), |
| 811 ContentSettingsPattern::FromURLNoWildcard(origin), | 833 ContentSettingsPattern::FromURLNoWildcard(origin), |
| 812 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 834 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
| 813 std::string(), | 835 std::string(), |
| 814 CONTENT_SETTING_DEFAULT); | 836 CONTENT_SETTING_DEFAULT); |
| 815 | 837 |
| 838 WaitForGetUserDataRoundTrip(0LL); |
| 839 WaitForGetUserDataRoundTrip(0LL); |
| 840 |
| 816 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 841 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 817 EXPECT_EQ("permission status - default", script_result); | 842 EXPECT_EQ("permission status - default", script_result); |
| 818 | 843 |
| 819 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 844 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 820 EXPECT_EQ("false - not registered", script_result); | 845 EXPECT_EQ("false - not registered", script_result); |
| 821 } | 846 } |
| 822 | 847 |
| 823 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 848 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 824 DenyPushPermissionUnregisters) { | 849 DenyPushPermissionUnregisters) { |
| 825 std::string script_result; | 850 std::string script_result; |
| 826 | 851 |
| 827 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); | 852 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); |
| 828 | 853 |
| 829 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 854 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 830 EXPECT_EQ("true - registered", script_result); | 855 EXPECT_EQ("true - registered", script_result); |
| 831 | 856 |
| 832 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 857 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 833 EXPECT_EQ("permission status - granted", script_result); | 858 EXPECT_EQ("permission status - granted", script_result); |
| 834 | 859 |
| 835 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 860 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); |
| 836 browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( | 861 browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( |
| 837 ContentSettingsPattern::FromURLNoWildcard(origin), | 862 ContentSettingsPattern::FromURLNoWildcard(origin), |
| 838 ContentSettingsPattern::FromURLNoWildcard(origin), | 863 ContentSettingsPattern::FromURLNoWildcard(origin), |
| 839 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 864 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
| 840 std::string(), | 865 std::string(), |
| 841 CONTENT_SETTING_BLOCK); | 866 CONTENT_SETTING_BLOCK); |
| 842 | 867 |
| 868 WaitForGetUserDataRoundTrip(0LL); |
| 869 WaitForGetUserDataRoundTrip(0LL); |
| 870 |
| 843 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 871 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 844 EXPECT_EQ("permission status - denied", script_result); | 872 EXPECT_EQ("permission status - denied", script_result); |
| 845 | 873 |
| 846 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 874 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 847 EXPECT_EQ("false - not registered", script_result); | 875 EXPECT_EQ("false - not registered", script_result); |
| 848 } | 876 } |
| 849 | 877 |
| 850 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 878 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 851 GlobalResetNotificationsPermissionUnregisters) { | 879 GlobalResetNotificationsPermissionUnregisters) { |
| 852 std::string script_result; | 880 std::string script_result; |
| 853 | 881 |
| 854 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); | 882 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); |
| 855 | 883 |
| 856 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 884 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 857 EXPECT_EQ("true - registered", script_result); | 885 EXPECT_EQ("true - registered", script_result); |
| 858 | 886 |
| 859 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 887 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 860 EXPECT_EQ("permission status - granted", script_result); | 888 EXPECT_EQ("permission status - granted", script_result); |
| 861 | 889 |
| 862 browser()->profile()->GetHostContentSettingsMap()-> | 890 browser()->profile()->GetHostContentSettingsMap()-> |
| 863 ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 891 ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 864 | 892 |
| 893 WaitForGetUserDataRoundTrip(0LL); |
| 894 WaitForGetUserDataRoundTrip(0LL); |
| 895 |
| 865 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 896 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 866 EXPECT_EQ("permission status - default", script_result); | 897 EXPECT_EQ("permission status - default", script_result); |
| 867 | 898 |
| 868 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 899 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 869 EXPECT_EQ("false - not registered", script_result); | 900 EXPECT_EQ("false - not registered", script_result); |
| 870 } | 901 } |
| 871 | 902 |
| 872 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 903 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 873 LocalResetNotificationsPermissionUnregisters) { | 904 LocalResetNotificationsPermissionUnregisters) { |
| 874 std::string script_result; | 905 std::string script_result; |
| 875 | 906 |
| 876 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); | 907 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); |
| 877 | 908 |
| 878 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 909 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 879 EXPECT_EQ("true - registered", script_result); | 910 EXPECT_EQ("true - registered", script_result); |
| 880 | 911 |
| 881 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 912 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 882 EXPECT_EQ("permission status - granted", script_result); | 913 EXPECT_EQ("permission status - granted", script_result); |
| 883 | 914 |
| 884 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 915 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); |
| 885 browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( | 916 browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( |
| 886 ContentSettingsPattern::FromURLNoWildcard(origin), | 917 ContentSettingsPattern::FromURLNoWildcard(origin), |
| 887 ContentSettingsPattern::Wildcard(), | 918 ContentSettingsPattern::Wildcard(), |
| 888 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 919 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 889 std::string(), | 920 std::string(), |
| 890 CONTENT_SETTING_DEFAULT); | 921 CONTENT_SETTING_DEFAULT); |
| 891 | 922 |
| 923 WaitForGetUserDataRoundTrip(0LL); |
| 924 WaitForGetUserDataRoundTrip(0LL); |
| 925 |
| 892 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 926 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 893 EXPECT_EQ("permission status - default", script_result); | 927 EXPECT_EQ("permission status - default", script_result); |
| 894 | 928 |
| 895 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 929 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 896 EXPECT_EQ("false - not registered", script_result); | 930 EXPECT_EQ("false - not registered", script_result); |
| 897 } | 931 } |
| 898 | 932 |
| 899 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 933 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 900 DenyNotificationsPermissionUnregisters) { | 934 DenyNotificationsPermissionUnregisters) { |
| 901 std::string script_result; | 935 std::string script_result; |
| 902 | 936 |
| 903 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); | 937 TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); |
| 904 | 938 |
| 905 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 939 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 906 EXPECT_EQ("true - registered", script_result); | 940 EXPECT_EQ("true - registered", script_result); |
| 907 | 941 |
| 908 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 942 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 909 EXPECT_EQ("permission status - granted", script_result); | 943 EXPECT_EQ("permission status - granted", script_result); |
| 910 | 944 |
| 911 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 945 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); |
| 912 browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( | 946 browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( |
| 913 ContentSettingsPattern::FromURLNoWildcard(origin), | 947 ContentSettingsPattern::FromURLNoWildcard(origin), |
| 914 ContentSettingsPattern::Wildcard(), | 948 ContentSettingsPattern::Wildcard(), |
| 915 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 949 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 916 std::string(), | 950 std::string(), |
| 917 CONTENT_SETTING_BLOCK); | 951 CONTENT_SETTING_BLOCK); |
| 918 | 952 |
| 953 WaitForGetUserDataRoundTrip(0LL); |
| 954 WaitForGetUserDataRoundTrip(0LL); |
| 955 |
| 919 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 956 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 920 EXPECT_EQ("permission status - denied", script_result); | 957 EXPECT_EQ("permission status - denied", script_result); |
| 921 | 958 |
| 922 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 959 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 923 EXPECT_EQ("false - not registered", script_result); | 960 EXPECT_EQ("false - not registered", script_result); |
| 924 } | 961 } |
| 925 | 962 |
| 926 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 963 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 927 GrantAlreadyGrantedPermissionDoesNotUnregister) { | 964 GrantAlreadyGrantedPermissionDoesNotUnregister) { |
| 928 std::string script_result; | 965 std::string script_result; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 942 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 979 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 943 std::string(), | 980 std::string(), |
| 944 CONTENT_SETTING_ALLOW); | 981 CONTENT_SETTING_ALLOW); |
| 945 browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( | 982 browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( |
| 946 ContentSettingsPattern::FromURLNoWildcard(origin), | 983 ContentSettingsPattern::FromURLNoWildcard(origin), |
| 947 ContentSettingsPattern::FromURLNoWildcard(origin), | 984 ContentSettingsPattern::FromURLNoWildcard(origin), |
| 948 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 985 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
| 949 std::string(), | 986 std::string(), |
| 950 CONTENT_SETTING_ALLOW); | 987 CONTENT_SETTING_ALLOW); |
| 951 | 988 |
| 989 WaitForGetUserDataRoundTrip(0LL); |
| 990 WaitForGetUserDataRoundTrip(0LL); |
| 991 |
| 952 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 992 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 953 EXPECT_EQ("permission status - granted", script_result); | 993 EXPECT_EQ("permission status - granted", script_result); |
| 954 | 994 |
| 955 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 995 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 956 EXPECT_EQ("true - registered", script_result); | 996 EXPECT_EQ("true - registered", script_result); |
| 957 } | 997 } |
| 958 | 998 |
| 959 // This test is testing some non-trivial content settings rules and make sure | 999 // This test is testing some non-trivial content settings rules and make sure |
| 960 // that they are respected with regards to automatic unregistration. In other | 1000 // that they are respected with regards to automatic unregistration. In other |
| 961 // words, it checks that the push service does not end up unregistering origins | 1001 // words, it checks that the push service does not end up unregistering origins |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 ContentSettingsPattern::FromURLNoWildcard(origin), | 1036 ContentSettingsPattern::FromURLNoWildcard(origin), |
| 997 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 1037 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
| 998 std::string(), | 1038 std::string(), |
| 999 CONTENT_SETTING_DEFAULT); | 1039 CONTENT_SETTING_DEFAULT); |
| 1000 | 1040 |
| 1001 // The two first rules should give |origin| the permission to use Push even | 1041 // The two first rules should give |origin| the permission to use Push even |
| 1002 // if the rules it used to have have been reset. | 1042 // if the rules it used to have have been reset. |
| 1003 // The Push service should not unsubcribe |origin| because at no point it was | 1043 // The Push service should not unsubcribe |origin| because at no point it was |
| 1004 // left without permission to use Push. | 1044 // left without permission to use Push. |
| 1005 | 1045 |
| 1046 WaitForGetUserDataRoundTrip(0LL); |
| 1047 WaitForGetUserDataRoundTrip(0LL); |
| 1048 |
| 1006 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 1049 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 1007 EXPECT_EQ("permission status - granted", script_result); | 1050 EXPECT_EQ("permission status - granted", script_result); |
| 1008 | 1051 |
| 1009 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); | 1052 ASSERT_TRUE(RunScript("hasRegistration()", &script_result)); |
| 1010 EXPECT_EQ("true - registered", script_result); | 1053 EXPECT_EQ("true - registered", script_result); |
| 1011 } | 1054 } |
| OLD | NEW |