Chromium Code Reviews| 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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 14 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 15 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 16 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| 17 #include "chrome/browser/infobars/infobar_responder.h" | |
| 18 #include "chrome/browser/infobars/infobar_service.h" | |
| 19 #include "chrome/browser/notifications/notification_test_util.h" | 17 #include "chrome/browser/notifications/notification_test_util.h" |
| 20 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 18 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" | 20 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" |
| 23 #include "chrome/browser/push_messaging/push_messaging_constants.h" | 21 #include "chrome/browser/push_messaging/push_messaging_constants.h" |
| 24 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" | 22 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" |
| 25 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" | 23 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" |
| 26 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" | 24 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" |
| 27 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 25 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 28 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 29 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 28 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | |
| 29 #include "chrome/browser/ui/website_settings/permission_bubble_responder.h" | |
| 30 #include "chrome/common/chrome_switches.h" | |
| 30 #include "chrome/test/base/in_process_browser_test.h" | 31 #include "chrome/test/base/in_process_browser_test.h" |
| 31 #include "chrome/test/base/ui_test_utils.h" | 32 #include "chrome/test/base/ui_test_utils.h" |
| 32 #include "components/content_settings/core/browser/host_content_settings_map.h" | 33 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 33 #include "components/content_settings/core/common/content_settings.h" | 34 #include "components/content_settings/core/common/content_settings.h" |
| 34 #include "components/content_settings/core/common/content_settings_types.h" | 35 #include "components/content_settings/core/common/content_settings_types.h" |
| 35 #include "components/gcm_driver/gcm_client.h" | 36 #include "components/gcm_driver/gcm_client.h" |
| 36 #include "content/public/browser/web_contents.h" | 37 #include "content/public/browser/web_contents.h" |
| 37 #include "content/public/common/content_switches.h" | 38 #include "content/public/common/content_switches.h" |
| 38 #include "content/public/test/browser_test_utils.h" | 39 #include "content/public/test/browser_test_utils.h" |
| 39 #include "content/public/test/test_utils.h" | 40 #include "content/public/test/test_utils.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 70 } // namespace | 71 } // namespace |
| 71 | 72 |
| 72 class PushMessagingBrowserTest : public InProcessBrowserTest { | 73 class PushMessagingBrowserTest : public InProcessBrowserTest { |
| 73 public: | 74 public: |
| 74 PushMessagingBrowserTest() : gcm_service_(nullptr) {} | 75 PushMessagingBrowserTest() : gcm_service_(nullptr) {} |
| 75 ~PushMessagingBrowserTest() override {} | 76 ~PushMessagingBrowserTest() override {} |
| 76 | 77 |
| 77 // InProcessBrowserTest: | 78 // InProcessBrowserTest: |
| 78 void SetUpCommandLine(base::CommandLine* command_line) override { | 79 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 79 command_line->AppendSwitch(switches::kEnablePushMessagePayload); | 80 command_line->AppendSwitch(switches::kEnablePushMessagePayload); |
| 81 command_line->AppendSwitch(switches::kEnablePermissionsBubbles); | |
|
msw
2015/06/04 01:22:08
Should we continue testing the old code path until
felt
2015/06/05 00:38:21
IMO there isn't a lot of value in testing the old
msw
2015/06/05 01:51:59
Hmm, I worry about dropping testing for an on-by-d
felt
2015/06/05 06:37:29
OK, so I've gone back to my original parameterized
| |
| 82 EXPECT_TRUE(PermissionBubbleManager::Enabled()); | |
| 80 | 83 |
| 81 InProcessBrowserTest::SetUpCommandLine(command_line); | 84 InProcessBrowserTest::SetUpCommandLine(command_line); |
| 82 } | 85 } |
| 83 | 86 |
| 84 // InProcessBrowserTest: | 87 // InProcessBrowserTest: |
| 85 void SetUp() override { | 88 void SetUp() override { |
| 86 https_server_.reset(new net::SpawnedTestServer( | 89 https_server_.reset(new net::SpawnedTestServer( |
| 87 net::SpawnedTestServer::TYPE_HTTPS, | 90 net::SpawnedTestServer::TYPE_HTTPS, |
| 88 net::BaseTestServer::SSLOptions( | 91 net::BaseTestServer::SSLOptions( |
| 89 net::BaseTestServer::SSLOptions::CERT_OK), | 92 net::BaseTestServer::SSLOptions::CERT_OK), |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 139 |
| 137 bool RunScript(const std::string& script, std::string* result, | 140 bool RunScript(const std::string& script, std::string* result, |
| 138 content::WebContents* web_contents) { | 141 content::WebContents* web_contents) { |
| 139 if (!web_contents) | 142 if (!web_contents) |
| 140 web_contents = GetBrowser()->tab_strip_model()->GetActiveWebContents(); | 143 web_contents = GetBrowser()->tab_strip_model()->GetActiveWebContents(); |
| 141 return content::ExecuteScriptAndExtractString(web_contents->GetMainFrame(), | 144 return content::ExecuteScriptAndExtractString(web_contents->GetMainFrame(), |
| 142 script, | 145 script, |
| 143 result); | 146 result); |
| 144 } | 147 } |
| 145 | 148 |
| 149 PermissionBubbleManager* GetPermissionBubbleManager() { | |
| 150 return PermissionBubbleManager::FromWebContents( | |
| 151 GetBrowser()->tab_strip_model()->GetActiveWebContents()); | |
| 152 } | |
| 153 | |
| 154 void RequestAndAcceptPermission(); | |
| 155 void RequestAndDenyPermission(); | |
| 156 | |
| 146 void TryToSubscribeSuccessfully( | 157 void TryToSubscribeSuccessfully( |
| 147 const std::string& expected_push_subscription_id); | 158 const std::string& expected_push_subscription_id); |
| 148 | 159 |
| 149 std::string GetEndpointForSubscriptionId(const std::string& subscription_id) { | 160 std::string GetEndpointForSubscriptionId(const std::string& subscription_id) { |
| 150 return std::string(kPushMessagingEndpoint) + "/" + subscription_id; | 161 return std::string(kPushMessagingEndpoint) + "/" + subscription_id; |
| 151 } | 162 } |
| 152 | 163 |
| 153 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( | 164 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( |
| 154 int64 service_worker_registration_id); | 165 int64 service_worker_registration_id); |
| 155 | 166 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 185 | 196 |
| 186 PushMessagingServiceImpl* push_service() const { return push_service_; } | 197 PushMessagingServiceImpl* push_service() const { return push_service_; } |
| 187 | 198 |
| 188 protected: | 199 protected: |
| 189 virtual std::string GetTestURL() { | 200 virtual std::string GetTestURL() { |
| 190 return "files/push_messaging/test.html"; | 201 return "files/push_messaging/test.html"; |
| 191 } | 202 } |
| 192 | 203 |
| 193 virtual Browser* GetBrowser() const { return browser(); } | 204 virtual Browser* GetBrowser() const { return browser(); } |
| 194 | 205 |
| 195 InfoBarService* GetInfoBarService() { | |
| 196 return InfoBarService::FromWebContents( | |
| 197 GetBrowser()->tab_strip_model()->GetActiveWebContents()); | |
| 198 } | |
| 199 | |
| 200 private: | 206 private: |
| 201 scoped_ptr<net::SpawnedTestServer> https_server_; | 207 scoped_ptr<net::SpawnedTestServer> https_server_; |
| 202 gcm::FakeGCMProfileService* gcm_service_; | 208 gcm::FakeGCMProfileService* gcm_service_; |
| 203 PushMessagingServiceImpl* push_service_; | 209 PushMessagingServiceImpl* push_service_; |
| 204 | 210 |
| 205 #if defined(ENABLE_NOTIFICATIONS) | 211 #if defined(ENABLE_NOTIFICATIONS) |
| 206 scoped_ptr<StubNotificationUIManager> notification_manager_; | 212 scoped_ptr<StubNotificationUIManager> notification_manager_; |
| 207 #endif | 213 #endif |
| 208 | 214 |
| 209 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest); | 215 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest); |
| 210 }; | 216 }; |
| 211 | 217 |
| 212 class PushMessagingBrowserTestEmptySubscriptionOptions | 218 class PushMessagingBrowserTestEmptySubscriptionOptions |
| 213 : public PushMessagingBrowserTest { | 219 : public PushMessagingBrowserTest { |
| 214 std::string GetTestURL() override { | 220 std::string GetTestURL() override { |
| 215 return "files/push_messaging/test_no_subscription_options.html"; | 221 return "files/push_messaging/test_no_subscription_options.html"; |
| 216 } | 222 } |
| 217 }; | 223 }; |
| 218 | 224 |
| 225 void PushMessagingBrowserTest::RequestAndAcceptPermission() { | |
| 226 std::string script_result; | |
| 227 | |
| 228 scoped_ptr<PermissionBubbleResponder> bubble_accept_responder( | |
|
msw
2015/06/04 01:22:08
nit: why scoped_ptr? ditto below.
| |
| 229 new PermissionBubbleResponder(GetPermissionBubbleManager(), | |
| 230 PermissionBubbleResponder::ACCEPT_ALL)); | |
| 231 EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 232 EXPECT_EQ("permission status - granted", script_result); | |
| 233 } | |
| 234 | |
| 235 void PushMessagingBrowserTest::RequestAndDenyPermission() { | |
| 236 std::string script_result; | |
| 237 | |
| 238 scoped_ptr<PermissionBubbleResponder> bubble_deny_responder( | |
| 239 new PermissionBubbleResponder(GetPermissionBubbleManager(), | |
| 240 PermissionBubbleResponder::DENY_ALL)); | |
| 241 EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 242 EXPECT_EQ("permission status - denied", script_result); | |
| 243 } | |
| 244 | |
| 219 void PushMessagingBrowserTest::TryToSubscribeSuccessfully( | 245 void PushMessagingBrowserTest::TryToSubscribeSuccessfully( |
| 220 const std::string& expected_push_subscription_id) { | 246 const std::string& expected_push_subscription_id) { |
| 221 std::string script_result; | 247 std::string script_result; |
| 222 | 248 |
| 223 EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 249 EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 224 EXPECT_EQ("ok - service worker registered", script_result); | 250 EXPECT_EQ("ok - service worker registered", script_result); |
| 225 | 251 |
| 226 InfoBarResponder accepting_responder(GetInfoBarService(), true); | 252 RequestAndAcceptPermission(); |
| 227 EXPECT_TRUE(RunScript("requestNotificationPermission()", &script_result)); | |
| 228 EXPECT_EQ("permission status - granted", script_result); | |
| 229 | 253 |
| 230 EXPECT_TRUE(RunScript("subscribePush()", &script_result)); | 254 EXPECT_TRUE(RunScript("subscribePush()", &script_result)); |
| 231 EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_id), | 255 EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_id), |
| 232 script_result); | 256 script_result); |
| 233 } | 257 } |
| 234 | 258 |
| 235 PushMessagingAppIdentifier | 259 PushMessagingAppIdentifier |
| 236 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( | 260 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( |
| 237 int64 service_worker_registration_id) { | 261 int64 service_worker_registration_id) { |
| 238 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 262 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 262 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); | 286 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); |
| 263 } | 287 } |
| 264 | 288 |
| 265 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 289 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 266 SubscribeSuccessNotificationsPrompt) { | 290 SubscribeSuccessNotificationsPrompt) { |
| 267 std::string script_result; | 291 std::string script_result; |
| 268 | 292 |
| 269 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 293 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 270 ASSERT_EQ("ok - service worker registered", script_result); | 294 ASSERT_EQ("ok - service worker registered", script_result); |
| 271 | 295 |
| 272 InfoBarResponder accepting_responder(GetInfoBarService(), true); | 296 scoped_ptr<PermissionBubbleResponder> bubble_accept_responder( |
| 297 new PermissionBubbleResponder(GetPermissionBubbleManager(), | |
| 298 PermissionBubbleResponder::ACCEPT_ALL)); | |
| 273 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); | 299 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); |
| 274 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), | 300 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), |
| 275 script_result); | 301 script_result); |
| 276 | 302 |
| 277 PushMessagingAppIdentifier app_identifier = | 303 PushMessagingAppIdentifier app_identifier = |
| 278 GetAppIdentifierForServiceWorkerRegistration(0LL); | 304 GetAppIdentifierForServiceWorkerRegistration(0LL); |
| 279 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | 305 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); |
| 280 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); | 306 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); |
| 281 } | 307 } |
| 282 | 308 |
| 283 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 309 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 284 SubscribeFailureNotificationsBlocked) { | 310 SubscribeFailureNotificationsBlocked) { |
| 285 std::string script_result; | 311 std::string script_result; |
| 286 | 312 |
| 287 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 313 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 288 ASSERT_EQ("ok - service worker registered", script_result); | 314 ASSERT_EQ("ok - service worker registered", script_result); |
| 289 | 315 |
| 290 InfoBarResponder cancelling_responder(GetInfoBarService(), false); | 316 RequestAndDenyPermission(); |
| 291 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 292 ASSERT_EQ("permission status - denied", script_result); | |
| 293 | 317 |
| 294 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); | 318 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); |
| 295 EXPECT_EQ("AbortError - Registration failed - permission denied", | 319 EXPECT_EQ("AbortError - Registration failed - permission denied", |
| 296 script_result); | 320 script_result); |
| 297 } | 321 } |
| 298 | 322 |
| 299 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeFailureNoManifest) { | 323 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeFailureNoManifest) { |
| 300 std::string script_result; | 324 std::string script_result; |
| 301 | 325 |
| 302 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 326 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 303 ASSERT_EQ("ok - service worker registered", script_result); | 327 ASSERT_EQ("ok - service worker registered", script_result); |
| 304 | 328 |
| 305 InfoBarResponder accepting_responder(GetInfoBarService(), true); | 329 RequestAndAcceptPermission(); |
| 306 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 307 ASSERT_EQ("permission status - granted", script_result); | |
| 308 | 330 |
| 309 ASSERT_TRUE(RunScript("removeManifest()", &script_result)); | 331 ASSERT_TRUE(RunScript("removeManifest()", &script_result)); |
| 310 ASSERT_EQ("manifest removed", script_result); | 332 ASSERT_EQ("manifest removed", script_result); |
| 311 | 333 |
| 312 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); | 334 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); |
| 313 EXPECT_EQ("AbortError - Registration failed - no sender id provided", | 335 EXPECT_EQ("AbortError - Registration failed - no sender id provided", |
| 314 script_result); | 336 script_result); |
| 315 } | 337 } |
| 316 | 338 |
| 317 // TODO(johnme): Test subscribing from a worker - see https://crbug.com/437298. | 339 // TODO(johnme): Test subscribing from a worker - see https://crbug.com/437298. |
| 318 | 340 |
| 319 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTestEmptySubscriptionOptions, | 341 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTestEmptySubscriptionOptions, |
| 320 RegisterFailureEmptyPushSubscriptionOptions) { | 342 RegisterFailureEmptyPushSubscriptionOptions) { |
| 321 std::string script_result; | 343 std::string script_result; |
| 322 | 344 |
| 323 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 345 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 324 ASSERT_EQ("ok - service worker registered", script_result); | 346 ASSERT_EQ("ok - service worker registered", script_result); |
| 325 | 347 |
| 326 InfoBarResponder accepting_responder(GetInfoBarService(), true); | 348 RequestAndAcceptPermission(); |
| 327 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 328 ASSERT_EQ("permission status - granted", script_result); | |
| 329 | 349 |
| 330 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); | 350 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); |
| 331 EXPECT_EQ("AbortError - Registration failed - permission denied", | 351 EXPECT_EQ("AbortError - Registration failed - permission denied", |
| 332 script_result); | 352 script_result); |
| 333 } | 353 } |
| 334 | 354 |
| 335 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribePersisted) { | 355 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribePersisted) { |
| 336 std::string script_result; | 356 std::string script_result; |
| 337 | 357 |
| 338 // First, test that Service Worker registration IDs are assigned in order of | 358 // First, test that Service Worker registration IDs are assigned in order of |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 689 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
| 670 ASSERT_EQ("permission status - prompt", script_result); | 690 ASSERT_EQ("permission status - prompt", script_result); |
| 671 } | 691 } |
| 672 | 692 |
| 673 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysGranted) { | 693 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysGranted) { |
| 674 std::string script_result; | 694 std::string script_result; |
| 675 | 695 |
| 676 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 696 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 677 ASSERT_EQ("ok - service worker registered", script_result); | 697 ASSERT_EQ("ok - service worker registered", script_result); |
| 678 | 698 |
| 679 InfoBarResponder accepting_responder(GetInfoBarService(), true); | 699 RequestAndAcceptPermission(); |
| 680 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 681 EXPECT_EQ("permission status - granted", script_result); | |
| 682 | 700 |
| 683 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); | 701 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); |
| 684 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), | 702 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), |
| 685 script_result); | 703 script_result); |
| 686 | 704 |
| 687 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 705 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
| 688 EXPECT_EQ("permission status - granted", script_result); | 706 EXPECT_EQ("permission status - granted", script_result); |
| 689 } | 707 } |
| 690 | 708 |
| 691 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysDenied) { | 709 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysDenied) { |
| 692 std::string script_result; | 710 std::string script_result; |
| 693 | 711 |
| 694 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 712 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 695 ASSERT_EQ("ok - service worker registered", script_result); | 713 ASSERT_EQ("ok - service worker registered", script_result); |
| 696 | 714 |
| 697 InfoBarResponder cancelling_responder(GetInfoBarService(), false); | 715 RequestAndDenyPermission(); |
| 698 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 699 EXPECT_EQ("permission status - denied", script_result); | |
| 700 | 716 |
| 701 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); | 717 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); |
| 702 EXPECT_EQ("AbortError - Registration failed - permission denied", | 718 EXPECT_EQ("AbortError - Registration failed - permission denied", |
| 703 script_result); | 719 script_result); |
| 704 | 720 |
| 705 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 721 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
| 706 EXPECT_EQ("permission status - denied", script_result); | 722 EXPECT_EQ("permission status - denied", script_result); |
| 707 } | 723 } |
| 708 | 724 |
| 709 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnsubscribeSuccess) { | 725 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnsubscribeSuccess) { |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1111 std::string script_result; | 1127 std::string script_result; |
| 1112 | 1128 |
| 1113 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 1129 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 1114 ASSERT_EQ("ok - service worker registered", script_result); | 1130 ASSERT_EQ("ok - service worker registered", script_result); |
| 1115 | 1131 |
| 1116 // In Incognito mode the promise returned by getSubscription should not hang, | 1132 // In Incognito mode the promise returned by getSubscription should not hang, |
| 1117 // it should just fulfill with null. | 1133 // it should just fulfill with null. |
| 1118 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1134 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
| 1119 ASSERT_EQ("false - not subscribed", script_result); | 1135 ASSERT_EQ("false - not subscribed", script_result); |
| 1120 } | 1136 } |
| OLD | NEW |