Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Unified Diff: chrome/browser/notifications/notification_browsertest.cc

Issue 752533002: Add a browser test to verify that double-closing a notification does not crash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/notifications/notification-double-close.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/notifications/notification_browsertest.cc
diff --git a/chrome/browser/notifications/notification_browsertest.cc b/chrome/browser/notifications/notification_browsertest.cc
index 3cead0397846f9fe3da2ecc7e6a9c8d9371f65d9..72c77dfa9218a39083da7702f8deac601e40d20b 100644
--- a/chrome/browser/notifications/notification_browsertest.cc
+++ b/chrome/browser/notifications/notification_browsertest.cc
@@ -150,9 +150,13 @@ class NotificationsTest : public InProcessBrowserTest {
bool CheckOriginInSetting(const ContentSettingsForOneType& settings,
const GURL& origin);
- GURL GetTestPageURL() const {
+ GURL GetTestPageURLForFile(const std::string& file) const {
return embedded_test_server()->GetURL(
- "/notifications/notification_tester.html");
+ std::string("/notifications/") + file);
+ }
+
+ GURL GetTestPageURL() const {
+ return GetTestPageURLForFile("notification_tester.html");
}
private:
@@ -889,3 +893,31 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestNotificationInvalidIcon) {
notification = *notifications.rbegin();
EXPECT_TRUE(notification->icon().IsEmpty());
}
+
+IN_PROC_BROWSER_TEST_F(NotificationsTest, TestNotificationDoubleClose) {
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+ AllowAllOrigins();
+
+ ui_test_utils::NavigateToURL(
+ browser(), GetTestPageURLForFile("notification-double-close.html"));
+ ASSERT_EQ(0, GetNotificationPopupCount());
+
+ std::string result = CreateNotification(
+ browser(), true, "", "Title1", "Body1", "chat");
+ EXPECT_NE("-1", result);
+
+ ASSERT_EQ(1, GetNotificationCount());
+ message_center::NotificationList::Notifications notifications =
+ message_center::MessageCenter::Get()->GetVisibleNotifications();
+ message_center::MessageCenter::Get()->RemoveNotification(
+ (*notifications.rbegin())->id(),
+ true); // by_user
+
+ ASSERT_EQ(0, GetNotificationCount());
+
+ // Calling WebContents::IsCrashed() will return FALSE here, even if the WC did
+ // crash. Work around this timing issue by creating another notification,
+ // which requires interaction with the renderer process.
+ result = CreateNotification(browser(), true, "", "Title1", "Body1", "chat");
+ EXPECT_NE("-1", result);
+}
« no previous file with comments | « no previous file | chrome/test/data/notifications/notification-double-close.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698