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(); |