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..37c001905e319fea8c75731296cb7af9ca9f8343 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() { |
+ if (editor_->details_.type != BookmarkEditor::EditDetails::NEW_FOLDER) |
+ return editor_->url_tf_->text(); |
+ |
+ return base::string16(); |
+ } |
+ |
void ApplyEdits() { |
editor_->ApplyEdits(); |
} |
@@ -332,6 +339,33 @@ 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* bb_node = model_->bookmark_bar_node(); |
+ |
+ GURL script_url = GURL("http://javascript:scripttext@example.com/"); |
sky
2016/09/26 23:03:02
It would be nice if the tests were more similar th
elawrence
2016/09/29 21:53:03
Done.
|
+ |
+ CreateEditor(profile_.get(), bb_node, |
+ BookmarkEditor::EditDetails::AddNodeInFolder( |
+ bb_node, 1, script_url, base::string16()), |
+ BookmarkEditorView::SHOW_TREE); |
+ |
+ // We expect only the trailing / to be trimmed when userinfo is present |
+ EXPECT_EQ(ASCIIToUTF16(script_url.spec()), GetURLText() + ASCIIToUTF16("/")); |
+ |
+ SetTitleText(ASCIIToUTF16("EditingKeepsScheme")); |
sky
2016/09/26 23:03:02
Make local variable (constant) so you can compare
elawrence
2016/09/29 21:53:03
Done.
|
+ |
+ ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); |
+ |
+ ASSERT_EQ(4, bb_node->child_count()); |
+ |
+ const BookmarkNode* new_node = bb_node->GetChild(1); |
+ |
+ EXPECT_EQ(ASCIIToUTF16("EditingKeepsScheme"), new_node->GetTitle()); |
+ EXPECT_TRUE(script_url == new_node->url()); |
+} |
+ |
// Creates a new folder. |
TEST_F(BookmarkEditorViewTest, NewFolder) { |
const BookmarkNode* bb_node = model_->bookmark_bar_node(); |