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

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

Issue 386035: Escape javascript going into text notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 | « chrome/browser/notifications/desktop_notification_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/notifications/desktop_notifications_unittest.cc
===================================================================
--- chrome/browser/notifications/desktop_notifications_unittest.cc (revision 31911)
+++ chrome/browser/notifications/desktop_notifications_unittest.cc (working copy)
@@ -250,3 +250,21 @@
}
service_.reset(NULL);
}
+
+TEST_F(DesktopNotificationsTest, TestUserInputEscaping) {
+ // Create a test script with some HTML; assert that it doesn't get into the
+ // data:// URL that's produced for the balloon.
+ EXPECT_TRUE(service_->ShowDesktopNotificationText(
+ GURL("http://www.google.com"),
+ GURL("/icon.png"), ASCIIToUTF16("<script>window.alert('uh oh');</script>"),
+ ASCIIToUTF16("<i>this text is in italics</i>"),
+ 0, 0, DesktopNotificationService::PageNotification, 1));
+
+ MessageLoopForUI::current()->RunAllPending();
+ EXPECT_EQ(1, balloon_collection_->count());
+ Balloon* balloon = (*balloon_collection_->balloons().begin());
+ GURL data_url = balloon->notification().content_url();
+ EXPECT_EQ(std::string::npos, data_url.spec().find("<script>"));
+ EXPECT_EQ(std::string::npos, data_url.spec().find("<i>"));
+}
+
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698