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