Chromium Code Reviews| 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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/barrier_closure.h" | 8 #include "base/barrier_closure.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 561 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); | 561 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); |
| 562 EXPECT_EQ("testdata", script_result); | 562 EXPECT_EQ("testdata", script_result); |
| 563 | 563 |
| 564 EXPECT_EQ(1u, notification_manager()->GetNotificationCount()); | 564 EXPECT_EQ(1u, notification_manager()->GetNotificationCount()); |
| 565 const Notification& forced_notification = | 565 const Notification& forced_notification = |
| 566 notification_manager()->GetNotificationAt(0); | 566 notification_manager()->GetNotificationAt(0); |
| 567 | 567 |
| 568 EXPECT_EQ(kPushMessagingForcedNotificationTag, forced_notification.tag()); | 568 EXPECT_EQ(kPushMessagingForcedNotificationTag, forced_notification.tag()); |
| 569 EXPECT_TRUE(forced_notification.silent()); | 569 EXPECT_TRUE(forced_notification.silent()); |
| 570 | 570 |
| 571 // Currently, this notification will stick around until the user or webapp | 571 // The notification will be automatically dismissed when the developer shows |
| 572 // explicitly dismisses it (though we may change this later). | 572 // a new notification themselves at a later point in time. |
| 573 message.data["data"] = "shownotification"; | 573 message.data["data"] = "shownotification"; |
| 574 SendMessageAndWaitUntilHandled(app_identifier, message); | 574 SendMessageAndWaitUntilHandled(app_identifier, message); |
| 575 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); | 575 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); |
| 576 EXPECT_EQ("shownotification", script_result); | 576 EXPECT_EQ("shownotification", script_result); |
| 577 EXPECT_EQ(2u, notification_manager()->GetNotificationCount()); | 577 EXPECT_EQ(1u, notification_manager()->GetNotificationCount()); |
|
johnme
2015/06/02 13:43:52
It would be nice to check that the right notificat
Peter Beverloo
2015/06/02 13:58:08
Done.
| |
| 578 | 578 |
| 579 notification_manager()->CancelAll(); | 579 notification_manager()->CancelAll(); |
| 580 EXPECT_EQ(0u, notification_manager()->GetNotificationCount()); | 580 EXPECT_EQ(0u, notification_manager()->GetNotificationCount()); |
| 581 | 581 |
| 582 // However if the Service Worker push event handler shows a notification, we | 582 // However if the Service Worker push event handler shows a notification, we |
| 583 // should not show a forced one. | 583 // should not show a forced one. |
| 584 message.data["data"] = "shownotification"; | 584 message.data["data"] = "shownotification"; |
| 585 for (int n = 0; n < 9; n++) { | 585 for (int n = 0; n < 9; n++) { |
| 586 SendMessageAndWaitUntilHandled(app_identifier, message); | 586 SendMessageAndWaitUntilHandled(app_identifier, message); |
| 587 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); | 587 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1097 std::string script_result; | 1097 std::string script_result; |
| 1098 | 1098 |
| 1099 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 1099 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 1100 ASSERT_EQ("ok - service worker registered", script_result); | 1100 ASSERT_EQ("ok - service worker registered", script_result); |
| 1101 | 1101 |
| 1102 // In Incognito mode the promise returned by getSubscription should not hang, | 1102 // In Incognito mode the promise returned by getSubscription should not hang, |
| 1103 // it should just fulfill with null. | 1103 // it should just fulfill with null. |
| 1104 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1104 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
| 1105 ASSERT_EQ("false - not subscribed", script_result); | 1105 ASSERT_EQ("false - not subscribed", script_result); |
| 1106 } | 1106 } |
| OLD | NEW |