| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 PushMessagingServiceImpl* push_service_; | 282 PushMessagingServiceImpl* push_service_; |
| 283 | 283 |
| 284 #if defined(ENABLE_NOTIFICATIONS) | 284 #if defined(ENABLE_NOTIFICATIONS) |
| 285 std::unique_ptr<StubNotificationUIManager> notification_manager_; | 285 std::unique_ptr<StubNotificationUIManager> notification_manager_; |
| 286 std::unique_ptr<MessageCenterDisplayService> display_service_; | 286 std::unique_ptr<MessageCenterDisplayService> display_service_; |
| 287 #endif | 287 #endif |
| 288 | 288 |
| 289 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest); | 289 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest); |
| 290 }; | 290 }; |
| 291 | 291 |
| 292 class PushMessagingBrowserTestEmptySubscriptionOptions | |
| 293 : public PushMessagingBrowserTest { | |
| 294 std::string GetTestURL() override { | |
| 295 return "/push_messaging/test_no_subscription_options.html"; | |
| 296 } | |
| 297 }; | |
| 298 | |
| 299 void PushMessagingBrowserTest::RequestAndAcceptPermission() { | 292 void PushMessagingBrowserTest::RequestAndAcceptPermission() { |
| 300 std::string script_result; | 293 std::string script_result; |
| 301 GetPermissionRequestManager()->set_auto_response_for_test( | 294 GetPermissionRequestManager()->set_auto_response_for_test( |
| 302 PermissionRequestManager::ACCEPT_ALL); | 295 PermissionRequestManager::ACCEPT_ALL); |
| 303 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | 296 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); |
| 304 ASSERT_EQ("permission status - granted", script_result); | 297 ASSERT_EQ("permission status - granted", script_result); |
| 305 } | 298 } |
| 306 | 299 |
| 307 void PushMessagingBrowserTest::RequestAndDenyPermission() { | 300 void PushMessagingBrowserTest::RequestAndDenyPermission() { |
| 308 std::string script_result; | 301 std::string script_result; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 ASSERT_TRUE(RunScript("swapManifestNoSenderId()", &script_result)); | 498 ASSERT_TRUE(RunScript("swapManifestNoSenderId()", &script_result)); |
| 506 ASSERT_EQ("sender id removed from manifest", script_result); | 499 ASSERT_EQ("sender id removed from manifest", script_result); |
| 507 | 500 |
| 508 ASSERT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); | 501 ASSERT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); |
| 509 EXPECT_EQ( | 502 EXPECT_EQ( |
| 510 "AbortError - Registration failed - missing applicationServerKey, and " | 503 "AbortError - Registration failed - missing applicationServerKey, and " |
| 511 "gcm_sender_id not found in manifest", | 504 "gcm_sender_id not found in manifest", |
| 512 script_result); | 505 script_result); |
| 513 } | 506 } |
| 514 | 507 |
| 515 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTestEmptySubscriptionOptions, | 508 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 516 RegisterFailureEmptyPushSubscriptionOptions) { | 509 RegisterFailureEmptyPushSubscriptionOptions) { |
| 517 std::string script_result; | 510 std::string script_result; |
| 518 | 511 |
| 519 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 512 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 520 ASSERT_EQ("ok - service worker registered", script_result); | 513 ASSERT_EQ("ok - service worker registered", script_result); |
| 521 | 514 |
| 522 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); | 515 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); |
| 523 | 516 |
| 524 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); | 517 ASSERT_TRUE( |
| 518 RunScript("documentSubscribePushWithEmptyOptions()", &script_result)); |
| 525 EXPECT_EQ("NotAllowedError - Registration failed - permission denied", | 519 EXPECT_EQ("NotAllowedError - Registration failed - permission denied", |
| 526 script_result); | 520 script_result); |
| 527 } | 521 } |
| 528 | 522 |
| 529 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeWorker) { | 523 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeWorker) { |
| 530 std::string script_result; | 524 std::string script_result; |
| 531 | 525 |
| 532 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 526 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 533 ASSERT_EQ("ok - service worker registered", script_result); | 527 ASSERT_EQ("ok - service worker registered", script_result); |
| 534 | 528 |
| (...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1884 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); | 1878 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); |
| 1885 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1879 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1886 | 1880 |
| 1887 // After dropping the last subscription background mode is still inactive. | 1881 // After dropping the last subscription background mode is still inactive. |
| 1888 std::string script_result; | 1882 std::string script_result; |
| 1889 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1883 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 1890 EXPECT_EQ("unsubscribe result: true", script_result); | 1884 EXPECT_EQ("unsubscribe result: true", script_result); |
| 1891 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1885 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1892 } | 1886 } |
| 1893 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1887 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
| OLD | NEW |