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

Unified Diff: chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc

Issue 2411473002: [merge to m54] Prevent interpretating userinfo as url scheme when editing bookmarks (Closed)
Patch Set: Created 4 years, 2 months 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/ui/cocoa/bookmarks/bookmark_editor_controller_unittest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc b/chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc
index 20c893c14948ce3a3febd9516c528de8b88dc5d6..2abe3d77823e2f144ab3c2c62b5117ac182d68d0 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc
@@ -73,6 +73,13 @@ class BookmarkEditorViewTest : public testing::Test {
editor_->url_tf_->SetText(text);
}
+ base::string16 GetURLText() const {
+ if (editor_->details_.type != BookmarkEditor::EditDetails::NEW_FOLDER)
+ return editor_->url_tf_->text();
+
+ return base::string16();
+ }
+
void ApplyEdits() {
editor_->ApplyEdits();
}
@@ -332,6 +339,34 @@ TEST_F(BookmarkEditorViewTest, ChangeTitleNoTree) {
EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle());
}
+// Edits the bookmark and ensures resulting URL keeps the same scheme, even
+// when userinfo is present in the URL
+TEST_F(BookmarkEditorViewTest, EditKeepsScheme) {
+ const BookmarkNode* kBBNode = model_->bookmark_bar_node();
+
+ const GURL kUrl = GURL("http://javascript:scripttext@example.com/");
+
+ CreateEditor(profile_.get(), kBBNode,
+ BookmarkEditor::EditDetails::AddNodeInFolder(kBBNode, 1, kUrl,
+ base::string16()),
+ BookmarkEditorView::SHOW_TREE);
+
+ // We expect only the trailing / to be trimmed when userinfo is present
+ EXPECT_EQ(ASCIIToUTF16(kUrl.spec()), GetURLText() + ASCIIToUTF16("/"));
+
+ const base::string16& kTitle = ASCIIToUTF16("EditingKeepsScheme");
+ SetTitleText(kTitle);
+
+ ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0));
+
+ ASSERT_EQ(4, kBBNode->child_count());
+
+ const BookmarkNode* kNewNode = kBBNode->GetChild(1);
+
+ EXPECT_EQ(kTitle, kNewNode->GetTitle());
+ EXPECT_EQ(kUrl, kNewNode->url());
+}
+
// Creates a new folder.
TEST_F(BookmarkEditorViewTest, NewFolder) {
const BookmarkNode* bb_node = model_->bookmark_bar_node();
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698