| 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 ASSERT_EQ("ok - service worker registered", script_result); | 440 ASSERT_EQ("ok - service worker registered", script_result); |
| 441 | 441 |
| 442 GetPermissionRequestManager()->set_auto_response_for_test( | 442 GetPermissionRequestManager()->set_auto_response_for_test( |
| 443 PermissionRequestManager::ACCEPT_ALL); | 443 PermissionRequestManager::ACCEPT_ALL); |
| 444 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); | 444 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); |
| 445 // Both of these methods EXPECT that they succeed. | 445 // Both of these methods EXPECT that they succeed. |
| 446 ASSERT_NO_FATAL_FAILURE(EndpointToToken(script_result)); | 446 ASSERT_NO_FATAL_FAILURE(EndpointToToken(script_result)); |
| 447 GetAppIdentifierForServiceWorkerRegistration(0LL); | 447 GetAppIdentifierForServiceWorkerRegistration(0LL); |
| 448 } | 448 } |
| 449 | 449 |
| 450 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeFailureBadKey) { | |
| 451 std::string script_result; | |
| 452 | |
| 453 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | |
| 454 ASSERT_EQ("ok - service worker registered", script_result); | |
| 455 | |
| 456 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); | |
| 457 | |
| 458 ASSERT_TRUE(RunScript("documentSubscribePushBadKey()", &script_result)); | |
| 459 EXPECT_EQ( | |
| 460 "InvalidAccessError - Failed to execute 'subscribe' on 'PushManager': " | |
| 461 "The provided applicationServerKey is not valid.", | |
| 462 script_result); | |
| 463 } | |
| 464 | |
| 465 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 450 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 466 SubscribeFailureNotificationsBlocked) { | 451 SubscribeFailureNotificationsBlocked) { |
| 467 std::string script_result; | 452 std::string script_result; |
| 468 | 453 |
| 469 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 454 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 470 ASSERT_EQ("ok - service worker registered", script_result); | 455 ASSERT_EQ("ok - service worker registered", script_result); |
| 471 | 456 |
| 472 ASSERT_NO_FATAL_FAILURE(RequestAndDenyPermission()); | 457 ASSERT_NO_FATAL_FAILURE(RequestAndDenyPermission()); |
| 473 | 458 |
| 474 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); | 459 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); |
| (...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1884 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); | 1869 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); |
| 1885 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1870 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1886 | 1871 |
| 1887 // After dropping the last subscription background mode is still inactive. | 1872 // After dropping the last subscription background mode is still inactive. |
| 1888 std::string script_result; | 1873 std::string script_result; |
| 1889 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1874 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 1890 EXPECT_EQ("unsubscribe result: true", script_result); | 1875 EXPECT_EQ("unsubscribe result: true", script_result); |
| 1891 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1876 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1892 } | 1877 } |
| 1893 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1878 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
| OLD | NEW |