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/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" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 ~PushMessagingBrowserTest() override {} | 81 ~PushMessagingBrowserTest() override {} |
82 | 82 |
83 // InProcessBrowserTest: | 83 // InProcessBrowserTest: |
84 void SetUpCommandLine(base::CommandLine* command_line) override { | 84 void SetUpCommandLine(base::CommandLine* command_line) override { |
85 command_line->AppendSwitch(switches::kEnablePushMessagePayload); | 85 command_line->AppendSwitch(switches::kEnablePushMessagePayload); |
86 InProcessBrowserTest::SetUpCommandLine(command_line); | 86 InProcessBrowserTest::SetUpCommandLine(command_line); |
87 } | 87 } |
88 | 88 |
89 // InProcessBrowserTest: | 89 // InProcessBrowserTest: |
90 void SetUp() override { | 90 void SetUp() override { |
91 https_server_.reset(new net::SpawnedTestServer( | 91 https_server_.reset( |
92 net::SpawnedTestServer::TYPE_HTTPS, | 92 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); |
93 net::BaseTestServer::SSLOptions( | 93 https_server_->ServeFilesFromSourceDirectory("chrome/test/data"); |
94 net::BaseTestServer::SSLOptions::CERT_OK), | |
95 base::FilePath(FILE_PATH_LITERAL("chrome/test/data/")))); | |
96 ASSERT_TRUE(https_server_->Start()); | 94 ASSERT_TRUE(https_server_->Start()); |
97 | 95 |
98 #if defined(ENABLE_NOTIFICATIONS) | 96 #if defined(ENABLE_NOTIFICATIONS) |
99 notification_manager_.reset(new StubNotificationUIManager); | 97 notification_manager_.reset(new StubNotificationUIManager); |
100 notification_service()->SetNotificationUIManagerForTesting( | 98 notification_service()->SetNotificationUIManagerForTesting( |
101 notification_manager()); | 99 notification_manager()); |
102 #endif | 100 #endif |
103 | 101 |
104 InProcessBrowserTest::SetUp(); | 102 InProcessBrowserTest::SetUp(); |
105 } | 103 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 return std::string(kPushMessagingEndpoint) + "/" + subscription_id; | 176 return std::string(kPushMessagingEndpoint) + "/" + subscription_id; |
179 } | 177 } |
180 | 178 |
181 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( | 179 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( |
182 int64 service_worker_registration_id); | 180 int64 service_worker_registration_id); |
183 | 181 |
184 void SendMessageAndWaitUntilHandled( | 182 void SendMessageAndWaitUntilHandled( |
185 const PushMessagingAppIdentifier& app_identifier, | 183 const PushMessagingAppIdentifier& app_identifier, |
186 const gcm::IncomingMessage& message); | 184 const gcm::IncomingMessage& message); |
187 | 185 |
188 net::SpawnedTestServer* https_server() const { return https_server_.get(); } | 186 net::EmbeddedTestServer* https_server() const { return https_server_.get(); } |
189 | 187 |
190 gcm::FakeGCMProfileService* gcm_service() const { return gcm_service_; } | 188 gcm::FakeGCMProfileService* gcm_service() const { return gcm_service_; } |
191 | 189 |
192 #if defined(ENABLE_NOTIFICATIONS) | 190 #if defined(ENABLE_NOTIFICATIONS) |
193 // To be called when delivery of a push message has finished. The |run_loop| | 191 // To be called when delivery of a push message has finished. The |run_loop| |
194 // will be told to quit after |messages_required| messages were received. | 192 // will be told to quit after |messages_required| messages were received. |
195 void OnDeliveryFinished(std::vector<size_t>* number_of_notifications_shown, | 193 void OnDeliveryFinished(std::vector<size_t>* number_of_notifications_shown, |
196 const base::Closure& done_closure) { | 194 const base::Closure& done_closure) { |
197 DCHECK(number_of_notifications_shown); | 195 DCHECK(number_of_notifications_shown); |
198 | 196 |
199 number_of_notifications_shown->push_back( | 197 number_of_notifications_shown->push_back( |
200 notification_manager_->GetNotificationCount()); | 198 notification_manager_->GetNotificationCount()); |
201 | 199 |
202 done_closure.Run(); | 200 done_closure.Run(); |
203 } | 201 } |
204 | 202 |
205 StubNotificationUIManager* notification_manager() const { | 203 StubNotificationUIManager* notification_manager() const { |
206 return notification_manager_.get(); | 204 return notification_manager_.get(); |
207 } | 205 } |
208 | 206 |
209 PlatformNotificationServiceImpl* notification_service() const { | 207 PlatformNotificationServiceImpl* notification_service() const { |
210 return PlatformNotificationServiceImpl::GetInstance(); | 208 return PlatformNotificationServiceImpl::GetInstance(); |
211 } | 209 } |
212 #endif | 210 #endif |
213 | 211 |
214 PushMessagingServiceImpl* push_service() const { return push_service_; } | 212 PushMessagingServiceImpl* push_service() const { return push_service_; } |
215 | 213 |
216 protected: | 214 protected: |
217 virtual std::string GetTestURL() { | 215 virtual std::string GetTestURL() { return "/push_messaging/test.html"; } |
218 return "files/push_messaging/test.html"; | |
219 } | |
220 | 216 |
221 virtual Browser* GetBrowser() const { return browser(); } | 217 virtual Browser* GetBrowser() const { return browser(); } |
222 | 218 |
223 private: | 219 private: |
224 scoped_ptr<net::SpawnedTestServer> https_server_; | 220 scoped_ptr<net::EmbeddedTestServer> https_server_; |
225 gcm::FakeGCMProfileService* gcm_service_; | 221 gcm::FakeGCMProfileService* gcm_service_; |
226 PushMessagingServiceImpl* push_service_; | 222 PushMessagingServiceImpl* push_service_; |
227 | 223 |
228 #if defined(ENABLE_NOTIFICATIONS) | 224 #if defined(ENABLE_NOTIFICATIONS) |
229 scoped_ptr<StubNotificationUIManager> notification_manager_; | 225 scoped_ptr<StubNotificationUIManager> notification_manager_; |
230 #endif | 226 #endif |
231 | 227 |
232 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest); | 228 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest); |
233 }; | 229 }; |
234 | 230 |
235 class PushMessagingBrowserTestEmptySubscriptionOptions | 231 class PushMessagingBrowserTestEmptySubscriptionOptions |
236 : public PushMessagingBrowserTest { | 232 : public PushMessagingBrowserTest { |
237 std::string GetTestURL() override { | 233 std::string GetTestURL() override { |
238 return "files/push_messaging/test_no_subscription_options.html"; | 234 return "/push_messaging/test_no_subscription_options.html"; |
239 } | 235 } |
240 }; | 236 }; |
241 | 237 |
242 void PushMessagingBrowserTest::RequestAndAcceptPermission() { | 238 void PushMessagingBrowserTest::RequestAndAcceptPermission() { |
243 std::string script_result; | 239 std::string script_result; |
244 GetPermissionBubbleManager()->set_auto_response_for_test( | 240 GetPermissionBubbleManager()->set_auto_response_for_test( |
245 PermissionBubbleManager::ACCEPT_ALL); | 241 PermissionBubbleManager::ACCEPT_ALL); |
246 EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | 242 EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result)); |
247 EXPECT_EQ("permission status - granted", script_result); | 243 EXPECT_EQ("permission status - granted", script_result); |
248 } | 244 } |
(...skipping 16 matching lines...) Expand all Loading... |
265 RequestAndAcceptPermission(); | 261 RequestAndAcceptPermission(); |
266 | 262 |
267 EXPECT_TRUE(RunScript("subscribePush()", &script_result)); | 263 EXPECT_TRUE(RunScript("subscribePush()", &script_result)); |
268 EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_id), | 264 EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_id), |
269 script_result); | 265 script_result); |
270 } | 266 } |
271 | 267 |
272 PushMessagingAppIdentifier | 268 PushMessagingAppIdentifier |
273 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( | 269 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( |
274 int64 service_worker_registration_id) { | 270 int64 service_worker_registration_id) { |
275 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 271 GURL origin = https_server()->GetURL("/").GetOrigin(); |
276 PushMessagingAppIdentifier app_identifier = | 272 PushMessagingAppIdentifier app_identifier = |
277 PushMessagingAppIdentifier::FindByServiceWorker( | 273 PushMessagingAppIdentifier::FindByServiceWorker( |
278 GetBrowser()->profile(), origin, service_worker_registration_id); | 274 GetBrowser()->profile(), origin, service_worker_registration_id); |
279 EXPECT_FALSE(app_identifier.is_null()); | 275 EXPECT_FALSE(app_identifier.is_null()); |
280 return app_identifier; | 276 return app_identifier; |
281 } | 277 } |
282 | 278 |
283 void PushMessagingBrowserTest::SendMessageAndWaitUntilHandled( | 279 void PushMessagingBrowserTest::SendMessageAndWaitUntilHandled( |
284 const PushMessagingAppIdentifier& app_identifier, | 280 const PushMessagingAppIdentifier& app_identifier, |
285 const gcm::IncomingMessage& message) { | 281 const gcm::IncomingMessage& message) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 // First, test that Service Worker registration IDs are assigned in order of | 365 // First, test that Service Worker registration IDs are assigned in order of |
370 // registering the Service Workers, and the (fake) push subscription ids are | 366 // registering the Service Workers, and the (fake) push subscription ids are |
371 // assigned in order of push subscription (even when these orders are | 367 // assigned in order of push subscription (even when these orders are |
372 // different). | 368 // different). |
373 | 369 |
374 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 370 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); |
375 PushMessagingAppIdentifier sw0_identifier = | 371 PushMessagingAppIdentifier sw0_identifier = |
376 GetAppIdentifierForServiceWorkerRegistration(0LL); | 372 GetAppIdentifierForServiceWorkerRegistration(0LL); |
377 EXPECT_EQ(sw0_identifier.app_id(), gcm_service()->last_registered_app_id()); | 373 EXPECT_EQ(sw0_identifier.app_id(), gcm_service()->last_registered_app_id()); |
378 | 374 |
379 LoadTestPage("files/push_messaging/subscope1/test.html"); | 375 LoadTestPage("/push_messaging/subscope1/test.html"); |
380 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 376 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
381 ASSERT_EQ("ok - service worker registered", script_result); | 377 ASSERT_EQ("ok - service worker registered", script_result); |
382 | 378 |
383 LoadTestPage("files/push_messaging/subscope2/test.html"); | 379 LoadTestPage("/push_messaging/subscope2/test.html"); |
384 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 380 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
385 ASSERT_EQ("ok - service worker registered", script_result); | 381 ASSERT_EQ("ok - service worker registered", script_result); |
386 | 382 |
387 // Note that we need to reload the page after registering, otherwise | 383 // Note that we need to reload the page after registering, otherwise |
388 // navigator.serviceWorker.ready is going to be resolved with the parent | 384 // navigator.serviceWorker.ready is going to be resolved with the parent |
389 // Service Worker which still controls the page. | 385 // Service Worker which still controls the page. |
390 LoadTestPage("files/push_messaging/subscope2/test.html"); | 386 LoadTestPage("/push_messaging/subscope2/test.html"); |
391 TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */); | 387 TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */); |
392 PushMessagingAppIdentifier sw2_identifier = | 388 PushMessagingAppIdentifier sw2_identifier = |
393 GetAppIdentifierForServiceWorkerRegistration(2LL); | 389 GetAppIdentifierForServiceWorkerRegistration(2LL); |
394 EXPECT_EQ(sw2_identifier.app_id(), gcm_service()->last_registered_app_id()); | 390 EXPECT_EQ(sw2_identifier.app_id(), gcm_service()->last_registered_app_id()); |
395 | 391 |
396 LoadTestPage("files/push_messaging/subscope1/test.html"); | 392 LoadTestPage("/push_messaging/subscope1/test.html"); |
397 TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */); | 393 TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */); |
398 PushMessagingAppIdentifier sw1_identifier = | 394 PushMessagingAppIdentifier sw1_identifier = |
399 GetAppIdentifierForServiceWorkerRegistration(1LL); | 395 GetAppIdentifierForServiceWorkerRegistration(1LL); |
400 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); | 396 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); |
401 | 397 |
402 // Now test that the Service Worker registration IDs and push subscription IDs | 398 // Now test that the Service Worker registration IDs and push subscription IDs |
403 // generated above were persisted to SW storage, by checking that they are | 399 // generated above were persisted to SW storage, by checking that they are |
404 // unchanged despite requesting them in a different order. | 400 // unchanged despite requesting them in a different order. |
405 // TODO(johnme): Ideally we would restart the browser at this point to check | 401 // TODO(johnme): Ideally we would restart the browser at this point to check |
406 // they were persisted to disk, but that's not currently possible since the | 402 // they were persisted to disk, but that's not currently possible since the |
407 // test server uses random port numbers for each test (even PRE_Foo and Foo), | 403 // test server uses random port numbers for each test (even PRE_Foo and Foo), |
408 // so we wouldn't be able to load the test pages with the same origin. | 404 // so we wouldn't be able to load the test pages with the same origin. |
409 | 405 |
410 LoadTestPage("files/push_messaging/subscope1/test.html"); | 406 LoadTestPage("/push_messaging/subscope1/test.html"); |
411 TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */); | 407 TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */); |
412 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); | 408 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); |
413 | 409 |
414 LoadTestPage("files/push_messaging/subscope2/test.html"); | 410 LoadTestPage("/push_messaging/subscope2/test.html"); |
415 TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */); | 411 TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */); |
416 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); | 412 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); |
417 | 413 |
418 LoadTestPage(); | 414 LoadTestPage(); |
419 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 415 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); |
420 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); | 416 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); |
421 } | 417 } |
422 | 418 |
423 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, AppHandlerOnlyIfSubscribed) { | 419 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, AppHandlerOnlyIfSubscribed) { |
424 // This test restarts the push service to simulate restarting the browser. | 420 // This test restarts the push service to simulate restarting the browser. |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 EXPECT_EQ("true - subscribed", script_result); | 839 EXPECT_EQ("true - subscribed", script_result); |
844 | 840 |
845 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 841 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
846 EXPECT_EQ("permission status - granted", script_result); | 842 EXPECT_EQ("permission status - granted", script_result); |
847 | 843 |
848 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 844 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
849 new content::MessageLoopRunner; | 845 new content::MessageLoopRunner; |
850 push_service()->SetContentSettingChangedCallbackForTesting( | 846 push_service()->SetContentSettingChangedCallbackForTesting( |
851 message_loop_runner->QuitClosure()); | 847 message_loop_runner->QuitClosure()); |
852 | 848 |
853 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 849 GURL origin = https_server()->GetURL("/").GetOrigin(); |
854 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) | 850 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) |
855 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), | 851 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), |
856 ContentSettingsPattern::FromURLNoWildcard(origin), | 852 ContentSettingsPattern::FromURLNoWildcard(origin), |
857 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 853 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
858 std::string(), | 854 std::string(), |
859 CONTENT_SETTING_DEFAULT); | 855 CONTENT_SETTING_DEFAULT); |
860 | 856 |
861 message_loop_runner->Run(); | 857 message_loop_runner->Run(); |
862 | 858 |
863 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 859 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
(...skipping 13 matching lines...) Expand all Loading... |
877 EXPECT_EQ("true - subscribed", script_result); | 873 EXPECT_EQ("true - subscribed", script_result); |
878 | 874 |
879 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 875 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
880 EXPECT_EQ("permission status - granted", script_result); | 876 EXPECT_EQ("permission status - granted", script_result); |
881 | 877 |
882 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 878 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
883 new content::MessageLoopRunner; | 879 new content::MessageLoopRunner; |
884 push_service()->SetContentSettingChangedCallbackForTesting( | 880 push_service()->SetContentSettingChangedCallbackForTesting( |
885 message_loop_runner->QuitClosure()); | 881 message_loop_runner->QuitClosure()); |
886 | 882 |
887 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 883 GURL origin = https_server()->GetURL("/").GetOrigin(); |
888 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) | 884 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) |
889 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), | 885 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), |
890 ContentSettingsPattern::FromURLNoWildcard(origin), | 886 ContentSettingsPattern::FromURLNoWildcard(origin), |
891 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 887 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
892 std::string(), | 888 std::string(), |
893 CONTENT_SETTING_BLOCK); | 889 CONTENT_SETTING_BLOCK); |
894 | 890 |
895 message_loop_runner->Run(); | 891 message_loop_runner->Run(); |
896 | 892 |
897 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 893 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 EXPECT_EQ("true - subscribed", script_result); | 936 EXPECT_EQ("true - subscribed", script_result); |
941 | 937 |
942 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 938 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
943 EXPECT_EQ("permission status - granted", script_result); | 939 EXPECT_EQ("permission status - granted", script_result); |
944 | 940 |
945 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 941 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
946 new content::MessageLoopRunner; | 942 new content::MessageLoopRunner; |
947 push_service()->SetContentSettingChangedCallbackForTesting( | 943 push_service()->SetContentSettingChangedCallbackForTesting( |
948 message_loop_runner->QuitClosure()); | 944 message_loop_runner->QuitClosure()); |
949 | 945 |
950 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 946 GURL origin = https_server()->GetURL("/").GetOrigin(); |
951 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) | 947 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) |
952 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), | 948 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), |
953 ContentSettingsPattern::Wildcard(), | 949 ContentSettingsPattern::Wildcard(), |
954 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 950 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
955 std::string(), | 951 std::string(), |
956 CONTENT_SETTING_DEFAULT); | 952 CONTENT_SETTING_DEFAULT); |
957 | 953 |
958 message_loop_runner->Run(); | 954 message_loop_runner->Run(); |
959 | 955 |
960 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 956 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
(...skipping 13 matching lines...) Expand all Loading... |
974 EXPECT_EQ("true - subscribed", script_result); | 970 EXPECT_EQ("true - subscribed", script_result); |
975 | 971 |
976 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 972 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
977 EXPECT_EQ("permission status - granted", script_result); | 973 EXPECT_EQ("permission status - granted", script_result); |
978 | 974 |
979 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 975 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
980 new content::MessageLoopRunner; | 976 new content::MessageLoopRunner; |
981 push_service()->SetContentSettingChangedCallbackForTesting( | 977 push_service()->SetContentSettingChangedCallbackForTesting( |
982 message_loop_runner->QuitClosure()); | 978 message_loop_runner->QuitClosure()); |
983 | 979 |
984 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 980 GURL origin = https_server()->GetURL("/").GetOrigin(); |
985 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) | 981 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) |
986 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), | 982 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), |
987 ContentSettingsPattern::Wildcard(), | 983 ContentSettingsPattern::Wildcard(), |
988 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 984 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
989 std::string(), | 985 std::string(), |
990 CONTENT_SETTING_BLOCK); | 986 CONTENT_SETTING_BLOCK); |
991 | 987 |
992 message_loop_runner->Run(); | 988 message_loop_runner->Run(); |
993 | 989 |
994 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 990 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
(...skipping 13 matching lines...) Expand all Loading... |
1008 EXPECT_EQ("true - subscribed", script_result); | 1004 EXPECT_EQ("true - subscribed", script_result); |
1009 | 1005 |
1010 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 1006 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
1011 EXPECT_EQ("permission status - granted", script_result); | 1007 EXPECT_EQ("permission status - granted", script_result); |
1012 | 1008 |
1013 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 1009 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
1014 new content::MessageLoopRunner; | 1010 new content::MessageLoopRunner; |
1015 push_service()->SetContentSettingChangedCallbackForTesting( | 1011 push_service()->SetContentSettingChangedCallbackForTesting( |
1016 base::BarrierClosure(2, message_loop_runner->QuitClosure())); | 1012 base::BarrierClosure(2, message_loop_runner->QuitClosure())); |
1017 | 1013 |
1018 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 1014 GURL origin = https_server()->GetURL("/").GetOrigin(); |
1019 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) | 1015 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) |
1020 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), | 1016 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), |
1021 ContentSettingsPattern::Wildcard(), | 1017 ContentSettingsPattern::Wildcard(), |
1022 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 1018 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
1023 std::string(), | 1019 std::string(), |
1024 CONTENT_SETTING_ALLOW); | 1020 CONTENT_SETTING_ALLOW); |
1025 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) | 1021 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) |
1026 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), | 1022 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), |
1027 ContentSettingsPattern::FromURLNoWildcard(origin), | 1023 ContentSettingsPattern::FromURLNoWildcard(origin), |
1028 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 1024 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
(...skipping 23 matching lines...) Expand all Loading... |
1052 EXPECT_EQ("true - subscribed", script_result); | 1048 EXPECT_EQ("true - subscribed", script_result); |
1053 | 1049 |
1054 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 1050 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
1055 EXPECT_EQ("permission status - granted", script_result); | 1051 EXPECT_EQ("permission status - granted", script_result); |
1056 | 1052 |
1057 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 1053 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
1058 new content::MessageLoopRunner; | 1054 new content::MessageLoopRunner; |
1059 push_service()->SetContentSettingChangedCallbackForTesting( | 1055 push_service()->SetContentSettingChangedCallbackForTesting( |
1060 base::BarrierClosure(4, message_loop_runner->QuitClosure())); | 1056 base::BarrierClosure(4, message_loop_runner->QuitClosure())); |
1061 | 1057 |
1062 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 1058 GURL origin = https_server()->GetURL("/").GetOrigin(); |
1063 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) | 1059 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) |
1064 ->SetContentSetting(ContentSettingsPattern::Wildcard(), | 1060 ->SetContentSetting(ContentSettingsPattern::Wildcard(), |
1065 ContentSettingsPattern::Wildcard(), | 1061 ContentSettingsPattern::Wildcard(), |
1066 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 1062 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
1067 std::string(), | 1063 std::string(), |
1068 CONTENT_SETTING_ALLOW); | 1064 CONTENT_SETTING_ALLOW); |
1069 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) | 1065 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) |
1070 ->SetContentSetting(ContentSettingsPattern::FromString("https://*"), | 1066 ->SetContentSetting(ContentSettingsPattern::FromString("https://*"), |
1071 ContentSettingsPattern::FromString("https://*"), | 1067 ContentSettingsPattern::FromString("https://*"), |
1072 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, | 1068 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1271 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
1276 | 1272 |
1277 // After dropping the last subscription background mode is still inactive. | 1273 // After dropping the last subscription background mode is still inactive. |
1278 std::string script_result; | 1274 std::string script_result; |
1279 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | 1275 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); |
1280 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1276 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
1281 EXPECT_EQ("unsubscribe result: true", script_result); | 1277 EXPECT_EQ("unsubscribe result: true", script_result); |
1282 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1278 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
1283 } | 1279 } |
1284 #endif // defined(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1280 #endif // defined(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
OLD | NEW |