| 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 504 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 505 ASSERT_EQ("ok - service worker registered", script_result); | 505 ASSERT_EQ("ok - service worker registered", script_result); |
| 506 | 506 |
| 507 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); | 507 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); |
| 508 | 508 |
| 509 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); | 509 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); |
| 510 EXPECT_EQ("NotAllowedError - Registration failed - permission denied", | 510 EXPECT_EQ("NotAllowedError - Registration failed - permission denied", |
| 511 script_result); | 511 script_result); |
| 512 } | 512 } |
| 513 | 513 |
| 514 // Flaky on ChromeOS and Linux. See http://crbug.com/657202. | 514 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeWorker) { |
| 515 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | |
| 516 #define MAYBE_SubscribeWorker DISABLED_SubscribeWorker | |
| 517 #else | |
| 518 #define MAYBE_SubscribeWorker SubscribeWorker | |
| 519 #endif | |
| 520 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, MAYBE_SubscribeWorker) { | |
| 521 std::string script_result; | 515 std::string script_result; |
| 522 | 516 |
| 523 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 517 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 524 ASSERT_EQ("ok - service worker registered", script_result); | 518 ASSERT_EQ("ok - service worker registered", script_result); |
| 525 | 519 |
| 526 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); | 520 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); |
| 527 | 521 |
| 528 LoadTestPage(); // Reload to become controlled. | 522 LoadTestPage(); // Reload to become controlled. |
| 529 | 523 |
| 530 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 524 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 553 std::string token2; | 547 std::string token2; |
| 554 ASSERT_NO_FATAL_FAILURE( | 548 ASSERT_NO_FATAL_FAILURE( |
| 555 EndpointToToken(script_result, true /* standard_protocol */, &token2)); | 549 EndpointToToken(script_result, true /* standard_protocol */, &token2)); |
| 556 EXPECT_NE(token1, token2); | 550 EXPECT_NE(token1, token2); |
| 557 | 551 |
| 558 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 552 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 559 EXPECT_EQ("unsubscribe result: true", script_result); | 553 EXPECT_EQ("unsubscribe result: true", script_result); |
| 560 EXPECT_NE(push_service(), GetAppHandler()); | 554 EXPECT_NE(push_service(), GetAppHandler()); |
| 561 } | 555 } |
| 562 | 556 |
| 563 // Flaky on ChromeOS and Linux. See http://crbug.com/657202. | |
| 564 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | |
| 565 #define MAYBE_SubscribeWorkerUsingManifest DISABLED_SubscribeWorkerUsingManifest | |
| 566 #else | |
| 567 #define MAYBE_SubscribeWorkerUsingManifest SubscribeWorkerUsingManifest | |
| 568 #endif | |
| 569 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 557 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 570 MAYBE_SubscribeWorkerUsingManifest) { | 558 SubscribeWorkerUsingManifest) { |
| 571 std::string script_result; | 559 std::string script_result; |
| 572 | 560 |
| 573 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 561 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 574 ASSERT_EQ("ok - service worker registered", script_result); | 562 ASSERT_EQ("ok - service worker registered", script_result); |
| 575 | 563 |
| 576 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); | 564 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); |
| 577 | 565 |
| 578 LoadTestPage(); // Reload to become controlled. | 566 LoadTestPage(); // Reload to become controlled. |
| 579 | 567 |
| 580 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 568 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 606 std::string token2; | 594 std::string token2; |
| 607 ASSERT_NO_FATAL_FAILURE( | 595 ASSERT_NO_FATAL_FAILURE( |
| 608 EndpointToToken(script_result, false /* standard_protocol */, &token2)); | 596 EndpointToToken(script_result, false /* standard_protocol */, &token2)); |
| 609 EXPECT_NE(token1, token2); | 597 EXPECT_NE(token1, token2); |
| 610 | 598 |
| 611 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 599 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 612 EXPECT_EQ("unsubscribe result: true", script_result); | 600 EXPECT_EQ("unsubscribe result: true", script_result); |
| 613 EXPECT_NE(push_service(), GetAppHandler()); | 601 EXPECT_NE(push_service(), GetAppHandler()); |
| 614 } | 602 } |
| 615 | 603 |
| 616 // Disabled on Windows and Linux due to flakiness (http://crbug.com/554003). | 604 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribePersisted) { |
| 617 #if defined(OS_WIN) || defined(OS_LINUX) | |
| 618 #define MAYBE_SubscribePersisted DISABLED_SubscribePersisted | |
| 619 #else | |
| 620 #define MAYBE_SubscribePersisted SubscribePersisted | |
| 621 #endif | |
| 622 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, MAYBE_SubscribePersisted) { | |
| 623 std::string script_result; | 605 std::string script_result; |
| 624 | 606 |
| 625 // First, test that Service Worker registration IDs are assigned in order of | 607 // First, test that Service Worker registration IDs are assigned in order of |
| 626 // registering the Service Workers, and the (fake) push subscription ids are | 608 // registering the Service Workers, and the (fake) push subscription ids are |
| 627 // assigned in order of push subscription (even when these orders are | 609 // assigned in order of push subscription (even when these orders are |
| 628 // different). | 610 // different). |
| 629 | 611 |
| 630 std::string token1; | 612 std::string token1; |
| 631 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully(true /* use_key */, &token1)); | 613 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully(true /* use_key */, &token1)); |
| 632 PushMessagingAppIdentifier sw0_identifier = | 614 PushMessagingAppIdentifier sw0_identifier = |
| (...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1882 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); | 1864 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); |
| 1883 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1865 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1884 | 1866 |
| 1885 // After dropping the last subscription background mode is still inactive. | 1867 // After dropping the last subscription background mode is still inactive. |
| 1886 std::string script_result; | 1868 std::string script_result; |
| 1887 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1869 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 1888 EXPECT_EQ("unsubscribe result: true", script_result); | 1870 EXPECT_EQ("unsubscribe result: true", script_result); |
| 1889 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1871 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1890 } | 1872 } |
| 1891 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1873 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
| OLD | NEW |