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); | |
|
johnme
2015/06/03 14:14:35
Nit: Isn't this the default now?
felt
2015/06/03 20:44:54
I've been going back and forth with some test fail
| |
| 80 | 82 |
| 81 InProcessBrowserTest::SetUpCommandLine(command_line); | 83 InProcessBrowserTest::SetUpCommandLine(command_line); |
| 82 } | 84 } |
| 83 | 85 |
| 84 // InProcessBrowserTest: | 86 // InProcessBrowserTest: |
| 85 void SetUp() override { | 87 void SetUp() override { |
| 86 https_server_.reset(new net::SpawnedTestServer( | 88 https_server_.reset(new net::SpawnedTestServer( |
| 87 net::SpawnedTestServer::TYPE_HTTPS, | 89 net::SpawnedTestServer::TYPE_HTTPS, |
| 88 net::BaseTestServer::SSLOptions( | 90 net::BaseTestServer::SSLOptions( |
| 89 net::BaseTestServer::SSLOptions::CERT_OK), | 91 net::BaseTestServer::SSLOptions::CERT_OK), |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 138 |
| 137 bool RunScript(const std::string& script, std::string* result, | 139 bool RunScript(const std::string& script, std::string* result, |
| 138 content::WebContents* web_contents) { | 140 content::WebContents* web_contents) { |
| 139 if (!web_contents) | 141 if (!web_contents) |
| 140 web_contents = GetBrowser()->tab_strip_model()->GetActiveWebContents(); | 142 web_contents = GetBrowser()->tab_strip_model()->GetActiveWebContents(); |
| 141 return content::ExecuteScriptAndExtractString(web_contents->GetMainFrame(), | 143 return content::ExecuteScriptAndExtractString(web_contents->GetMainFrame(), |
| 142 script, | 144 script, |
| 143 result); | 145 result); |
| 144 } | 146 } |
| 145 | 147 |
| 148 void RequestAndAcceptPermission(); | |
| 149 void RequestAndDenyPermission(); | |
| 150 | |
| 146 void TryToSubscribeSuccessfully( | 151 void TryToSubscribeSuccessfully( |
| 147 const std::string& expected_push_subscription_id); | 152 const std::string& expected_push_subscription_id); |
| 148 | 153 |
| 149 std::string GetEndpointForSubscriptionId(const std::string& subscription_id) { | 154 std::string GetEndpointForSubscriptionId(const std::string& subscription_id) { |
| 150 return std::string(kPushMessagingEndpoint) + "/" + subscription_id; | 155 return std::string(kPushMessagingEndpoint) + "/" + subscription_id; |
| 151 } | 156 } |
| 152 | 157 |
| 153 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( | 158 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( |
| 154 int64 service_worker_registration_id); | 159 int64 service_worker_registration_id); |
| 155 | 160 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 185 | 190 |
| 186 PushMessagingServiceImpl* push_service() const { return push_service_; } | 191 PushMessagingServiceImpl* push_service() const { return push_service_; } |
| 187 | 192 |
| 188 protected: | 193 protected: |
| 189 virtual std::string GetTestURL() { | 194 virtual std::string GetTestURL() { |
| 190 return "files/push_messaging/test.html"; | 195 return "files/push_messaging/test.html"; |
| 191 } | 196 } |
| 192 | 197 |
| 193 virtual Browser* GetBrowser() const { return browser(); } | 198 virtual Browser* GetBrowser() const { return browser(); } |
| 194 | 199 |
| 195 InfoBarService* GetInfoBarService() { | |
| 196 return InfoBarService::FromWebContents( | |
| 197 GetBrowser()->tab_strip_model()->GetActiveWebContents()); | |
| 198 } | |
| 199 | |
| 200 private: | 200 private: |
| 201 scoped_ptr<net::SpawnedTestServer> https_server_; | 201 scoped_ptr<net::SpawnedTestServer> https_server_; |
| 202 gcm::FakeGCMProfileService* gcm_service_; | 202 gcm::FakeGCMProfileService* gcm_service_; |
| 203 PushMessagingServiceImpl* push_service_; | 203 PushMessagingServiceImpl* push_service_; |
| 204 | 204 |
| 205 #if defined(ENABLE_NOTIFICATIONS) | 205 #if defined(ENABLE_NOTIFICATIONS) |
| 206 scoped_ptr<StubNotificationUIManager> notification_manager_; | 206 scoped_ptr<StubNotificationUIManager> notification_manager_; |
| 207 #endif | 207 #endif |
| 208 | 208 |
| 209 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest); | 209 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest); |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 class PushMessagingBrowserTestEmptySubscriptionOptions | 212 class PushMessagingBrowserTestEmptySubscriptionOptions |
| 213 : public PushMessagingBrowserTest { | 213 : public PushMessagingBrowserTest { |
| 214 std::string GetTestURL() override { | 214 std::string GetTestURL() override { |
| 215 return "files/push_messaging/test_no_subscription_options.html"; | 215 return "files/push_messaging/test_no_subscription_options.html"; |
| 216 } | 216 } |
| 217 }; | 217 }; |
| 218 | 218 |
| 219 void PushMessagingBrowserTest::RequestAndAcceptPermission() { | |
| 220 std::string script_result; | |
| 221 | |
| 222 EXPECT_TRUE(PermissionBubbleManager::Enabled()); | |
| 223 | |
| 224 PermissionBubbleManager* bubble_manager = | |
| 225 PermissionBubbleManager::FromWebContents( | |
| 226 GetBrowser()->tab_strip_model()->GetActiveWebContents()); | |
| 227 scoped_ptr<PermissionBubbleResponder> bubble_accept_responder( | |
| 228 new PermissionBubbleResponder(bubble_manager, | |
| 229 PermissionBubbleResponder::ACCEPT_ALL)); | |
| 230 EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 231 EXPECT_EQ("permission status - granted", script_result); | |
| 232 } | |
| 233 | |
| 234 void PushMessagingBrowserTest::RequestAndDenyPermission() { | |
| 235 std::string script_result; | |
| 236 | |
| 237 EXPECT_TRUE(PermissionBubbleManager::Enabled()); | |
| 238 | |
| 239 PermissionBubbleManager* bubble_manager = | |
| 240 PermissionBubbleManager::FromWebContents( | |
| 241 GetBrowser()->tab_strip_model()->GetActiveWebContents()); | |
| 242 scoped_ptr<PermissionBubbleResponder> bubble_deny_responder( | |
| 243 new PermissionBubbleResponder(bubble_manager, | |
| 244 PermissionBubbleResponder::DENY_ALL)); | |
| 245 EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 246 EXPECT_EQ("permission status - denied", script_result); | |
| 247 } | |
| 248 | |
| 219 void PushMessagingBrowserTest::TryToSubscribeSuccessfully( | 249 void PushMessagingBrowserTest::TryToSubscribeSuccessfully( |
| 220 const std::string& expected_push_subscription_id) { | 250 const std::string& expected_push_subscription_id) { |
| 221 std::string script_result; | 251 std::string script_result; |
| 222 | 252 |
| 223 EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 253 EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 224 EXPECT_EQ("ok - service worker registered", script_result); | 254 EXPECT_EQ("ok - service worker registered", script_result); |
| 225 | 255 |
| 226 InfoBarResponder accepting_responder(GetInfoBarService(), true); | 256 RequestAndAcceptPermission(); |
| 227 EXPECT_TRUE(RunScript("requestNotificationPermission()", &script_result)); | |
| 228 EXPECT_EQ("permission status - granted", script_result); | |
| 229 | 257 |
| 230 EXPECT_TRUE(RunScript("subscribePush()", &script_result)); | 258 EXPECT_TRUE(RunScript("subscribePush()", &script_result)); |
| 231 EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_id), | 259 EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_id), |
| 232 script_result); | 260 script_result); |
| 233 } | 261 } |
| 234 | 262 |
| 235 PushMessagingAppIdentifier | 263 PushMessagingAppIdentifier |
| 236 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( | 264 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( |
| 237 int64 service_worker_registration_id) { | 265 int64 service_worker_registration_id) { |
| 238 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); | 266 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]); | 290 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); |
| 263 } | 291 } |
| 264 | 292 |
| 265 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 293 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 266 SubscribeSuccessNotificationsPrompt) { | 294 SubscribeSuccessNotificationsPrompt) { |
| 267 std::string script_result; | 295 std::string script_result; |
| 268 | 296 |
| 269 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 297 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 270 ASSERT_EQ("ok - service worker registered", script_result); | 298 ASSERT_EQ("ok - service worker registered", script_result); |
| 271 | 299 |
| 272 InfoBarResponder accepting_responder(GetInfoBarService(), true); | 300 RequestAndAcceptPermission(); |
|
johnme
2015/06/03 14:14:35
Actually, I think the point of this test is that i
felt
2015/06/03 20:44:54
Ah, I missed the point of this test. Fixed.
| |
| 301 | |
| 273 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); | 302 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); |
| 274 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), | 303 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), |
| 275 script_result); | 304 script_result); |
| 276 | 305 |
| 277 PushMessagingAppIdentifier app_identifier = | 306 PushMessagingAppIdentifier app_identifier = |
| 278 GetAppIdentifierForServiceWorkerRegistration(0LL); | 307 GetAppIdentifierForServiceWorkerRegistration(0LL); |
| 279 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | 308 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); |
| 280 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); | 309 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); |
| 281 } | 310 } |
| 282 | 311 |
| 283 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 312 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 284 SubscribeFailureNotificationsBlocked) { | 313 SubscribeFailureNotificationsBlocked) { |
| 285 std::string script_result; | 314 std::string script_result; |
| 286 | 315 |
| 287 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 316 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 288 ASSERT_EQ("ok - service worker registered", script_result); | 317 ASSERT_EQ("ok - service worker registered", script_result); |
| 289 | 318 |
| 290 InfoBarResponder cancelling_responder(GetInfoBarService(), false); | 319 RequestAndDenyPermission(); |
| 291 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 292 ASSERT_EQ("permission status - denied", script_result); | |
| 293 | 320 |
| 294 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); | 321 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); |
| 295 EXPECT_EQ("AbortError - Registration failed - permission denied", | 322 EXPECT_EQ("AbortError - Registration failed - permission denied", |
| 296 script_result); | 323 script_result); |
| 297 } | 324 } |
| 298 | 325 |
| 299 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeFailureNoManifest) { | 326 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeFailureNoManifest) { |
| 300 std::string script_result; | 327 std::string script_result; |
| 301 | 328 |
| 302 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 329 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 303 ASSERT_EQ("ok - service worker registered", script_result); | 330 ASSERT_EQ("ok - service worker registered", script_result); |
| 304 | 331 |
| 305 InfoBarResponder accepting_responder(GetInfoBarService(), true); | 332 RequestAndAcceptPermission(); |
| 306 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 307 ASSERT_EQ("permission status - granted", script_result); | |
| 308 | 333 |
| 309 ASSERT_TRUE(RunScript("removeManifest()", &script_result)); | 334 ASSERT_TRUE(RunScript("removeManifest()", &script_result)); |
| 310 ASSERT_EQ("manifest removed", script_result); | 335 ASSERT_EQ("manifest removed", script_result); |
| 311 | 336 |
| 312 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); | 337 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); |
| 313 EXPECT_EQ("AbortError - Registration failed - no sender id provided", | 338 EXPECT_EQ("AbortError - Registration failed - no sender id provided", |
| 314 script_result); | 339 script_result); |
| 315 } | 340 } |
| 316 | 341 |
| 317 // TODO(johnme): Test subscribing from a worker - see https://crbug.com/437298. | 342 // TODO(johnme): Test subscribing from a worker - see https://crbug.com/437298. |
| 318 | 343 |
| 319 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTestEmptySubscriptionOptions, | 344 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTestEmptySubscriptionOptions, |
| 320 RegisterFailureEmptyPushSubscriptionOptions) { | 345 RegisterFailureEmptyPushSubscriptionOptions) { |
| 321 std::string script_result; | 346 std::string script_result; |
| 322 | 347 |
| 323 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 348 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 324 ASSERT_EQ("ok - service worker registered", script_result); | 349 ASSERT_EQ("ok - service worker registered", script_result); |
| 325 | 350 |
| 326 InfoBarResponder accepting_responder(GetInfoBarService(), true); | 351 RequestAndAcceptPermission(); |
| 327 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 328 ASSERT_EQ("permission status - granted", script_result); | |
| 329 | 352 |
| 330 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); | 353 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); |
| 331 EXPECT_EQ("AbortError - Registration failed - permission denied", | 354 EXPECT_EQ("AbortError - Registration failed - permission denied", |
| 332 script_result); | 355 script_result); |
| 333 } | 356 } |
| 334 | 357 |
| 335 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribePersisted) { | 358 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribePersisted) { |
| 336 std::string script_result; | 359 std::string script_result; |
| 337 | 360 |
| 338 // First, test that Service Worker registration IDs are assigned in order of | 361 // 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)); | 692 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
| 670 ASSERT_EQ("permission status - prompt", script_result); | 693 ASSERT_EQ("permission status - prompt", script_result); |
| 671 } | 694 } |
| 672 | 695 |
| 673 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysGranted) { | 696 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysGranted) { |
| 674 std::string script_result; | 697 std::string script_result; |
| 675 | 698 |
| 676 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 699 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 677 ASSERT_EQ("ok - service worker registered", script_result); | 700 ASSERT_EQ("ok - service worker registered", script_result); |
| 678 | 701 |
| 679 InfoBarResponder accepting_responder(GetInfoBarService(), true); | 702 RequestAndAcceptPermission(); |
| 680 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 681 EXPECT_EQ("permission status - granted", script_result); | |
| 682 | 703 |
| 683 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); | 704 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); |
| 684 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), | 705 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), |
| 685 script_result); | 706 script_result); |
| 686 | 707 |
| 687 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 708 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
| 688 EXPECT_EQ("permission status - granted", script_result); | 709 EXPECT_EQ("permission status - granted", script_result); |
| 689 } | 710 } |
| 690 | 711 |
| 691 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysDenied) { | 712 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysDenied) { |
| 692 std::string script_result; | 713 std::string script_result; |
| 693 | 714 |
| 694 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 715 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 695 ASSERT_EQ("ok - service worker registered", script_result); | 716 ASSERT_EQ("ok - service worker registered", script_result); |
| 696 | 717 |
| 697 InfoBarResponder cancelling_responder(GetInfoBarService(), false); | 718 RequestAndDenyPermission(); |
| 698 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 699 EXPECT_EQ("permission status - denied", script_result); | |
| 700 | 719 |
| 701 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); | 720 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); |
| 702 EXPECT_EQ("AbortError - Registration failed - permission denied", | 721 EXPECT_EQ("AbortError - Registration failed - permission denied", |
| 703 script_result); | 722 script_result); |
| 704 | 723 |
| 705 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 724 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
| 706 EXPECT_EQ("permission status - denied", script_result); | 725 EXPECT_EQ("permission status - denied", script_result); |
| 707 } | 726 } |
| 708 | 727 |
| 709 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnsubscribeSuccess) { | 728 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; | 1130 std::string script_result; |
| 1112 | 1131 |
| 1113 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 1132 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 1114 ASSERT_EQ("ok - service worker registered", script_result); | 1133 ASSERT_EQ("ok - service worker registered", script_result); |
| 1115 | 1134 |
| 1116 // In Incognito mode the promise returned by getSubscription should not hang, | 1135 // In Incognito mode the promise returned by getSubscription should not hang, |
| 1117 // it should just fulfill with null. | 1136 // it should just fulfill with null. |
| 1118 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1137 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
| 1119 ASSERT_EQ("false - not subscribed", script_result); | 1138 ASSERT_EQ("false - not subscribed", script_result); |
| 1120 } | 1139 } |
| OLD | NEW |