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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 for (int n = 0; n < 2; n++) { | 784 for (int n = 0; n < 2; n++) { |
785 message.raw_data = "testdata"; | 785 message.raw_data = "testdata"; |
786 SendMessageAndWaitUntilHandled(app_identifier, message); | 786 SendMessageAndWaitUntilHandled(app_identifier, message); |
787 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); | 787 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); |
788 EXPECT_EQ("testdata", script_result); | 788 EXPECT_EQ("testdata", script_result); |
789 EXPECT_EQ(0u, notification_manager()->GetNotificationCount()); | 789 EXPECT_EQ(0u, notification_manager()->GetNotificationCount()); |
790 } | 790 } |
791 | 791 |
792 // Open a blank foreground tab so site is no longer visible. | 792 // Open a blank foreground tab so site is no longer visible. |
793 ui_test_utils::NavigateToURLWithDisposition( | 793 ui_test_utils::NavigateToURLWithDisposition( |
794 GetBrowser(), GURL("about:blank"), NEW_FOREGROUND_TAB, | 794 GetBrowser(), GURL("about:blank"), |
| 795 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
795 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 796 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
796 | 797 |
797 // If the Service Worker push event handler shows a notification, we | 798 // If the Service Worker push event handler shows a notification, we |
798 // should not show a forced one. | 799 // should not show a forced one. |
799 message.raw_data = "shownotification"; | 800 message.raw_data = "shownotification"; |
800 SendMessageAndWaitUntilHandled(app_identifier, message); | 801 SendMessageAndWaitUntilHandled(app_identifier, message); |
801 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); | 802 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); |
802 EXPECT_EQ("shownotification", script_result); | 803 EXPECT_EQ("shownotification", script_result); |
803 EXPECT_EQ(1u, notification_manager()->GetNotificationCount()); | 804 EXPECT_EQ(1u, notification_manager()->GetNotificationCount()); |
804 EXPECT_EQ("push_test_tag", | 805 EXPECT_EQ("push_test_tag", |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 | 902 |
902 notification_manager()->CancelAll(); | 903 notification_manager()->CancelAll(); |
903 ASSERT_EQ(0u, notification_manager()->GetNotificationCount()); | 904 ASSERT_EQ(0u, notification_manager()->GetNotificationCount()); |
904 | 905 |
905 // We'll need to specify the web_contents in which to eval script, since we're | 906 // We'll need to specify the web_contents in which to eval script, since we're |
906 // going to run script in a background tab. | 907 // going to run script in a background tab. |
907 content::WebContents* web_contents = | 908 content::WebContents* web_contents = |
908 GetBrowser()->tab_strip_model()->GetActiveWebContents(); | 909 GetBrowser()->tab_strip_model()->GetActiveWebContents(); |
909 | 910 |
910 ui_test_utils::NavigateToURLWithDisposition( | 911 ui_test_utils::NavigateToURLWithDisposition( |
911 GetBrowser(), GURL("about:blank"), NEW_FOREGROUND_TAB, | 912 GetBrowser(), GURL("about:blank"), |
| 913 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
912 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 914 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
913 | 915 |
914 SetSiteEngagementScore(web_contents->GetURL(), 0.0); | 916 SetSiteEngagementScore(web_contents->GetURL(), 0.0); |
915 | 917 |
916 // If the Service Worker push event handler does not show a notification, we | 918 // If the Service Worker push event handler does not show a notification, we |
917 // should show a forced one providing there is no foreground tab and the | 919 // should show a forced one providing there is no foreground tab and the |
918 // origin ran out of budget. | 920 // origin ran out of budget. |
919 gcm::IncomingMessage message; | 921 gcm::IncomingMessage message; |
920 message.sender_id = GetTestApplicationServerKey(); | 922 message.sender_id = GetTestApplicationServerKey(); |
921 message.raw_data = "testdata"; | 923 message.raw_data = "testdata"; |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1575 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
1574 | 1576 |
1575 // After dropping the last subscription background mode is still inactive. | 1577 // After dropping the last subscription background mode is still inactive. |
1576 std::string script_result; | 1578 std::string script_result; |
1577 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | 1579 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); |
1578 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1580 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
1579 EXPECT_EQ("unsubscribe result: true", script_result); | 1581 EXPECT_EQ("unsubscribe result: true", script_result); |
1580 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1582 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
1581 } | 1583 } |
1582 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1584 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
OLD | NEW |