| 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 ASSERT_EQ("ok - service worker registered", script_result); | 498 ASSERT_EQ("ok - service worker registered", script_result); |
| 499 | 499 |
| 500 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); | 500 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); |
| 501 | 501 |
| 502 ASSERT_TRUE( | 502 ASSERT_TRUE( |
| 503 RunScript("documentSubscribePushWithEmptyOptions()", &script_result)); | 503 RunScript("documentSubscribePushWithEmptyOptions()", &script_result)); |
| 504 EXPECT_EQ("NotAllowedError - Registration failed - permission denied", | 504 EXPECT_EQ("NotAllowedError - Registration failed - permission denied", |
| 505 script_result); | 505 script_result); |
| 506 } | 506 } |
| 507 | 507 |
| 508 // Flaky on ChromeOS and Linux. See http://crbug.com/657202. | 508 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeWorker) { |
| 509 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | |
| 510 #define MAYBE_SubscribeWorker DISABLED_SubscribeWorker | |
| 511 #else | |
| 512 #define MAYBE_SubscribeWorker SubscribeWorker | |
| 513 #endif | |
| 514 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, MAYBE_SubscribeWorker) { | |
| 515 std::string script_result; | 509 std::string script_result; |
| 516 | 510 |
| 517 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 511 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 518 ASSERT_EQ("ok - service worker registered", script_result); | 512 ASSERT_EQ("ok - service worker registered", script_result); |
| 519 | 513 |
| 520 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); | 514 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); |
| 521 | 515 |
| 522 LoadTestPage(); // Reload to become controlled. | 516 LoadTestPage(); // Reload to become controlled. |
| 523 | 517 |
| 524 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 518 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 547 std::string token2; | 541 std::string token2; |
| 548 ASSERT_NO_FATAL_FAILURE( | 542 ASSERT_NO_FATAL_FAILURE( |
| 549 EndpointToToken(script_result, true /* standard_protocol */, &token2)); | 543 EndpointToToken(script_result, true /* standard_protocol */, &token2)); |
| 550 EXPECT_NE(token1, token2); | 544 EXPECT_NE(token1, token2); |
| 551 | 545 |
| 552 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 546 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 553 EXPECT_EQ("unsubscribe result: true", script_result); | 547 EXPECT_EQ("unsubscribe result: true", script_result); |
| 554 EXPECT_NE(push_service(), GetAppHandler()); | 548 EXPECT_NE(push_service(), GetAppHandler()); |
| 555 } | 549 } |
| 556 | 550 |
| 557 // Flaky on ChromeOS and Linux. See http://crbug.com/657202. | |
| 558 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | |
| 559 #define MAYBE_SubscribeWorkerUsingManifest DISABLED_SubscribeWorkerUsingManifest | |
| 560 #else | |
| 561 #define MAYBE_SubscribeWorkerUsingManifest SubscribeWorkerUsingManifest | |
| 562 #endif | |
| 563 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 551 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 564 MAYBE_SubscribeWorkerUsingManifest) { | 552 SubscribeWorkerUsingManifest) { |
| 565 std::string script_result; | 553 std::string script_result; |
| 566 | 554 |
| 567 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 555 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 568 ASSERT_EQ("ok - service worker registered", script_result); | 556 ASSERT_EQ("ok - service worker registered", script_result); |
| 569 | 557 |
| 570 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); | 558 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); |
| 571 | 559 |
| 572 LoadTestPage(); // Reload to become controlled. | 560 LoadTestPage(); // Reload to become controlled. |
| 573 | 561 |
| 574 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 562 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 600 std::string token2; | 588 std::string token2; |
| 601 ASSERT_NO_FATAL_FAILURE( | 589 ASSERT_NO_FATAL_FAILURE( |
| 602 EndpointToToken(script_result, false /* standard_protocol */, &token2)); | 590 EndpointToToken(script_result, false /* standard_protocol */, &token2)); |
| 603 EXPECT_NE(token1, token2); | 591 EXPECT_NE(token1, token2); |
| 604 | 592 |
| 605 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 593 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 606 EXPECT_EQ("unsubscribe result: true", script_result); | 594 EXPECT_EQ("unsubscribe result: true", script_result); |
| 607 EXPECT_NE(push_service(), GetAppHandler()); | 595 EXPECT_NE(push_service(), GetAppHandler()); |
| 608 } | 596 } |
| 609 | 597 |
| 610 // Disabled on Windows and Linux due to flakiness (http://crbug.com/554003). | 598 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribePersisted) { |
| 611 #if defined(OS_WIN) || defined(OS_LINUX) | |
| 612 #define MAYBE_SubscribePersisted DISABLED_SubscribePersisted | |
| 613 #else | |
| 614 #define MAYBE_SubscribePersisted SubscribePersisted | |
| 615 #endif | |
| 616 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, MAYBE_SubscribePersisted) { | |
| 617 std::string script_result; | 599 std::string script_result; |
| 618 | 600 |
| 619 // First, test that Service Worker registration IDs are assigned in order of | 601 // First, test that Service Worker registration IDs are assigned in order of |
| 620 // registering the Service Workers, and the (fake) push subscription ids are | 602 // registering the Service Workers, and the (fake) push subscription ids are |
| 621 // assigned in order of push subscription (even when these orders are | 603 // assigned in order of push subscription (even when these orders are |
| 622 // different). | 604 // different). |
| 623 | 605 |
| 624 std::string token1; | 606 std::string token1; |
| 625 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully(true /* use_key */, &token1)); | 607 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully(true /* use_key */, &token1)); |
| 626 PushMessagingAppIdentifier sw0_identifier = | 608 PushMessagingAppIdentifier sw0_identifier = |
| (...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1876 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); | 1858 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); |
| 1877 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1859 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1878 | 1860 |
| 1879 // After dropping the last subscription background mode is still inactive. | 1861 // After dropping the last subscription background mode is still inactive. |
| 1880 std::string script_result; | 1862 std::string script_result; |
| 1881 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1863 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 1882 EXPECT_EQ("unsubscribe result: true", script_result); | 1864 EXPECT_EQ("unsubscribe result: true", script_result); |
| 1883 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1865 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1884 } | 1866 } |
| 1885 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1867 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
| OLD | NEW |