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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_browsertest.cc

Issue 1409163006: Migrating tests to use EmbeddedTestServer (/chrome/browser misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month 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"
(...skipping 22 matching lines...) Expand all
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
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
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
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // First, test that Service Worker registration IDs are assigned in order of 372 // First, test that Service Worker registration IDs are assigned in order of
376 // registering the Service Workers, and the (fake) push subscription ids are 373 // registering the Service Workers, and the (fake) push subscription ids are
377 // assigned in order of push subscription (even when these orders are 374 // assigned in order of push subscription (even when these orders are
378 // different). 375 // different).
379 376
380 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); 377 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */);
381 PushMessagingAppIdentifier sw0_identifier = 378 PushMessagingAppIdentifier sw0_identifier =
382 GetAppIdentifierForServiceWorkerRegistration(0LL); 379 GetAppIdentifierForServiceWorkerRegistration(0LL);
383 EXPECT_EQ(sw0_identifier.app_id(), gcm_service()->last_registered_app_id()); 380 EXPECT_EQ(sw0_identifier.app_id(), gcm_service()->last_registered_app_id());
384 381
385 LoadTestPage("files/push_messaging/subscope1/test.html"); 382 LoadTestPage("/push_messaging/subscope1/test.html");
386 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 383 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
387 ASSERT_EQ("ok - service worker registered", script_result); 384 ASSERT_EQ("ok - service worker registered", script_result);
388 385
389 LoadTestPage("files/push_messaging/subscope2/test.html"); 386 LoadTestPage("/push_messaging/subscope2/test.html");
390 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 387 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
391 ASSERT_EQ("ok - service worker registered", script_result); 388 ASSERT_EQ("ok - service worker registered", script_result);
392 389
393 // Note that we need to reload the page after registering, otherwise 390 // Note that we need to reload the page after registering, otherwise
394 // navigator.serviceWorker.ready is going to be resolved with the parent 391 // navigator.serviceWorker.ready is going to be resolved with the parent
395 // Service Worker which still controls the page. 392 // Service Worker which still controls the page.
396 LoadTestPage("files/push_messaging/subscope2/test.html"); 393 LoadTestPage("/push_messaging/subscope2/test.html");
397 TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */); 394 TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */);
398 PushMessagingAppIdentifier sw2_identifier = 395 PushMessagingAppIdentifier sw2_identifier =
399 GetAppIdentifierForServiceWorkerRegistration(2LL); 396 GetAppIdentifierForServiceWorkerRegistration(2LL);
400 EXPECT_EQ(sw2_identifier.app_id(), gcm_service()->last_registered_app_id()); 397 EXPECT_EQ(sw2_identifier.app_id(), gcm_service()->last_registered_app_id());
401 398
402 LoadTestPage("files/push_messaging/subscope1/test.html"); 399 LoadTestPage("/push_messaging/subscope1/test.html");
403 TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */); 400 TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */);
404 PushMessagingAppIdentifier sw1_identifier = 401 PushMessagingAppIdentifier sw1_identifier =
405 GetAppIdentifierForServiceWorkerRegistration(1LL); 402 GetAppIdentifierForServiceWorkerRegistration(1LL);
406 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); 403 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id());
407 404
408 // Now test that the Service Worker registration IDs and push subscription IDs 405 // Now test that the Service Worker registration IDs and push subscription IDs
409 // generated above were persisted to SW storage, by checking that they are 406 // generated above were persisted to SW storage, by checking that they are
410 // unchanged despite requesting them in a different order. 407 // unchanged despite requesting them in a different order.
411 // TODO(johnme): Ideally we would restart the browser at this point to check 408 // TODO(johnme): Ideally we would restart the browser at this point to check
412 // they were persisted to disk, but that's not currently possible since the 409 // they were persisted to disk, but that's not currently possible since the
413 // test server uses random port numbers for each test (even PRE_Foo and Foo), 410 // test server uses random port numbers for each test (even PRE_Foo and Foo),
414 // so we wouldn't be able to load the test pages with the same origin. 411 // so we wouldn't be able to load the test pages with the same origin.
415 412
416 LoadTestPage("files/push_messaging/subscope1/test.html"); 413 LoadTestPage("/push_messaging/subscope1/test.html");
417 TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */); 414 TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */);
418 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); 415 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id());
419 416
420 LoadTestPage("files/push_messaging/subscope2/test.html"); 417 LoadTestPage("/push_messaging/subscope2/test.html");
421 TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */); 418 TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */);
422 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); 419 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id());
423 420
424 LoadTestPage(); 421 LoadTestPage();
425 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); 422 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */);
426 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); 423 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id());
427 } 424 }
428 425
429 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, AppHandlerOnlyIfSubscribed) { 426 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, AppHandlerOnlyIfSubscribed) {
430 // This test restarts the push service to simulate restarting the browser. 427 // This test restarts the push service to simulate restarting the browser.
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 EXPECT_EQ("true - subscribed", script_result); 846 EXPECT_EQ("true - subscribed", script_result);
850 847
851 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 848 ASSERT_TRUE(RunScript("permissionState()", &script_result));
852 EXPECT_EQ("permission status - granted", script_result); 849 EXPECT_EQ("permission status - granted", script_result);
853 850
854 scoped_refptr<content::MessageLoopRunner> message_loop_runner = 851 scoped_refptr<content::MessageLoopRunner> message_loop_runner =
855 new content::MessageLoopRunner; 852 new content::MessageLoopRunner;
856 push_service()->SetContentSettingChangedCallbackForTesting( 853 push_service()->SetContentSettingChangedCallbackForTesting(
857 message_loop_runner->QuitClosure()); 854 message_loop_runner->QuitClosure());
858 855
859 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); 856 GURL origin = https_server()->GetURL("/").GetOrigin();
860 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) 857 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
861 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), 858 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin),
862 ContentSettingsPattern::FromURLNoWildcard(origin), 859 ContentSettingsPattern::FromURLNoWildcard(origin),
863 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, 860 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
864 std::string(), 861 std::string(),
865 CONTENT_SETTING_DEFAULT); 862 CONTENT_SETTING_DEFAULT);
866 863
867 message_loop_runner->Run(); 864 message_loop_runner->Run();
868 865
869 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 866 ASSERT_TRUE(RunScript("permissionState()", &script_result));
(...skipping 13 matching lines...) Expand all
883 EXPECT_EQ("true - subscribed", script_result); 880 EXPECT_EQ("true - subscribed", script_result);
884 881
885 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 882 ASSERT_TRUE(RunScript("permissionState()", &script_result));
886 EXPECT_EQ("permission status - granted", script_result); 883 EXPECT_EQ("permission status - granted", script_result);
887 884
888 scoped_refptr<content::MessageLoopRunner> message_loop_runner = 885 scoped_refptr<content::MessageLoopRunner> message_loop_runner =
889 new content::MessageLoopRunner; 886 new content::MessageLoopRunner;
890 push_service()->SetContentSettingChangedCallbackForTesting( 887 push_service()->SetContentSettingChangedCallbackForTesting(
891 message_loop_runner->QuitClosure()); 888 message_loop_runner->QuitClosure());
892 889
893 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); 890 GURL origin = https_server()->GetURL("/").GetOrigin();
894 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) 891 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
895 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), 892 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin),
896 ContentSettingsPattern::FromURLNoWildcard(origin), 893 ContentSettingsPattern::FromURLNoWildcard(origin),
897 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, 894 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
898 std::string(), 895 std::string(),
899 CONTENT_SETTING_BLOCK); 896 CONTENT_SETTING_BLOCK);
900 897
901 message_loop_runner->Run(); 898 message_loop_runner->Run();
902 899
903 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 900 ASSERT_TRUE(RunScript("permissionState()", &script_result));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 EXPECT_EQ("true - subscribed", script_result); 943 EXPECT_EQ("true - subscribed", script_result);
947 944
948 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 945 ASSERT_TRUE(RunScript("permissionState()", &script_result));
949 EXPECT_EQ("permission status - granted", script_result); 946 EXPECT_EQ("permission status - granted", script_result);
950 947
951 scoped_refptr<content::MessageLoopRunner> message_loop_runner = 948 scoped_refptr<content::MessageLoopRunner> message_loop_runner =
952 new content::MessageLoopRunner; 949 new content::MessageLoopRunner;
953 push_service()->SetContentSettingChangedCallbackForTesting( 950 push_service()->SetContentSettingChangedCallbackForTesting(
954 message_loop_runner->QuitClosure()); 951 message_loop_runner->QuitClosure());
955 952
956 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); 953 GURL origin = https_server()->GetURL("/").GetOrigin();
957 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) 954 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
958 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), 955 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin),
959 ContentSettingsPattern::Wildcard(), 956 ContentSettingsPattern::Wildcard(),
960 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 957 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
961 std::string(), 958 std::string(),
962 CONTENT_SETTING_DEFAULT); 959 CONTENT_SETTING_DEFAULT);
963 960
964 message_loop_runner->Run(); 961 message_loop_runner->Run();
965 962
966 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 963 ASSERT_TRUE(RunScript("permissionState()", &script_result));
(...skipping 13 matching lines...) Expand all
980 EXPECT_EQ("true - subscribed", script_result); 977 EXPECT_EQ("true - subscribed", script_result);
981 978
982 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 979 ASSERT_TRUE(RunScript("permissionState()", &script_result));
983 EXPECT_EQ("permission status - granted", script_result); 980 EXPECT_EQ("permission status - granted", script_result);
984 981
985 scoped_refptr<content::MessageLoopRunner> message_loop_runner = 982 scoped_refptr<content::MessageLoopRunner> message_loop_runner =
986 new content::MessageLoopRunner; 983 new content::MessageLoopRunner;
987 push_service()->SetContentSettingChangedCallbackForTesting( 984 push_service()->SetContentSettingChangedCallbackForTesting(
988 message_loop_runner->QuitClosure()); 985 message_loop_runner->QuitClosure());
989 986
990 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); 987 GURL origin = https_server()->GetURL("/").GetOrigin();
991 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) 988 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
992 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), 989 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin),
993 ContentSettingsPattern::Wildcard(), 990 ContentSettingsPattern::Wildcard(),
994 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 991 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
995 std::string(), 992 std::string(),
996 CONTENT_SETTING_BLOCK); 993 CONTENT_SETTING_BLOCK);
997 994
998 message_loop_runner->Run(); 995 message_loop_runner->Run();
999 996
1000 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 997 ASSERT_TRUE(RunScript("permissionState()", &script_result));
(...skipping 13 matching lines...) Expand all
1014 EXPECT_EQ("true - subscribed", script_result); 1011 EXPECT_EQ("true - subscribed", script_result);
1015 1012
1016 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 1013 ASSERT_TRUE(RunScript("permissionState()", &script_result));
1017 EXPECT_EQ("permission status - granted", script_result); 1014 EXPECT_EQ("permission status - granted", script_result);
1018 1015
1019 scoped_refptr<content::MessageLoopRunner> message_loop_runner = 1016 scoped_refptr<content::MessageLoopRunner> message_loop_runner =
1020 new content::MessageLoopRunner; 1017 new content::MessageLoopRunner;
1021 push_service()->SetContentSettingChangedCallbackForTesting( 1018 push_service()->SetContentSettingChangedCallbackForTesting(
1022 base::BarrierClosure(2, message_loop_runner->QuitClosure())); 1019 base::BarrierClosure(2, message_loop_runner->QuitClosure()));
1023 1020
1024 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); 1021 GURL origin = https_server()->GetURL("/").GetOrigin();
1025 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) 1022 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
1026 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), 1023 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin),
1027 ContentSettingsPattern::Wildcard(), 1024 ContentSettingsPattern::Wildcard(),
1028 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 1025 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
1029 std::string(), 1026 std::string(),
1030 CONTENT_SETTING_ALLOW); 1027 CONTENT_SETTING_ALLOW);
1031 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) 1028 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
1032 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin), 1029 ->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin),
1033 ContentSettingsPattern::FromURLNoWildcard(origin), 1030 ContentSettingsPattern::FromURLNoWildcard(origin),
1034 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, 1031 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
(...skipping 23 matching lines...) Expand all
1058 EXPECT_EQ("true - subscribed", script_result); 1055 EXPECT_EQ("true - subscribed", script_result);
1059 1056
1060 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 1057 ASSERT_TRUE(RunScript("permissionState()", &script_result));
1061 EXPECT_EQ("permission status - granted", script_result); 1058 EXPECT_EQ("permission status - granted", script_result);
1062 1059
1063 scoped_refptr<content::MessageLoopRunner> message_loop_runner = 1060 scoped_refptr<content::MessageLoopRunner> message_loop_runner =
1064 new content::MessageLoopRunner; 1061 new content::MessageLoopRunner;
1065 push_service()->SetContentSettingChangedCallbackForTesting( 1062 push_service()->SetContentSettingChangedCallbackForTesting(
1066 base::BarrierClosure(4, message_loop_runner->QuitClosure())); 1063 base::BarrierClosure(4, message_loop_runner->QuitClosure()));
1067 1064
1068 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); 1065 GURL origin = https_server()->GetURL("/").GetOrigin();
1069 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) 1066 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
1070 ->SetContentSetting(ContentSettingsPattern::Wildcard(), 1067 ->SetContentSetting(ContentSettingsPattern::Wildcard(),
1071 ContentSettingsPattern::Wildcard(), 1068 ContentSettingsPattern::Wildcard(),
1072 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 1069 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
1073 std::string(), 1070 std::string(),
1074 CONTENT_SETTING_ALLOW); 1071 CONTENT_SETTING_ALLOW);
1075 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) 1072 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
1076 ->SetContentSetting(ContentSettingsPattern::FromString("https://*"), 1073 ->SetContentSetting(ContentSettingsPattern::FromString("https://*"),
1077 ContentSettingsPattern::FromString("https://*"), 1074 ContentSettingsPattern::FromString("https://*"),
1078 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, 1075 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); 1278 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive());
1282 1279
1283 // After dropping the last subscription background mode is still inactive. 1280 // After dropping the last subscription background mode is still inactive.
1284 std::string script_result; 1281 std::string script_result;
1285 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); 1282 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS);
1286 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); 1283 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result));
1287 EXPECT_EQ("unsubscribe result: true", script_result); 1284 EXPECT_EQ("unsubscribe result: true", script_result);
1288 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); 1285 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive());
1289 } 1286 }
1290 #endif // defined(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) 1287 #endif // defined(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698