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

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller_unittest.mm

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
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller_unittest.mm
index 5a9a0958c52554298774c4ca35ba2172dcb54f25..4098467fc081af1263246bbe49d32fbea47d7ae9 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller_unittest.mm
@@ -259,6 +259,45 @@ TEST_F(BookmarkEditorControllerUtf8NodeTest, DisplayUtf8Name) {
[controller_ cancel:nil];
}
+using BookmarkEditorControllerEditKeepsSchemeTest = CocoaProfileTest;
+TEST_F(BookmarkEditorControllerEditKeepsSchemeTest, EditKeepsScheme) {
+ // Edits the bookmark and ensures resulting URL keeps the same scheme, even
+ // when userinfo is present in the URL
+ ASSERT_TRUE(profile());
+
+ BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile());
+ const BookmarkNode* kParent = model->bookmark_bar_node();
+ const base::string16 kTitle = ASCIIToUTF16("EditingKeepsScheme");
+
+ const GURL kUrl = GURL("http://javascript:scripttext@example.com/");
+ const BookmarkNode* kNode = model->AddURL(kParent, 0, base::string16(), kUrl);
+
+ BookmarkEditorController* controller = [[BookmarkEditorController alloc]
+ initWithParentWindow:test_window()
+ profile:profile()
+ parent:kParent
+ node:kNode
+ url:GURL()
+ title:base::string16()
+ configuration:BookmarkEditor::SHOW_TREE];
+
+ [controller runAsModalSheet];
+
+ // We expect only the trailing / to be trimmed when userinfo is present
+ EXPECT_NSEQ(base::SysUTF8ToNSString(kUrl.spec()),
+ [[controller displayURL] stringByAppendingString:@"/"]);
+
+ [controller setDisplayName:base::SysUTF16ToNSString(kTitle)];
+
+ EXPECT_TRUE([controller okButtonEnabled]);
+ [controller ok:nil];
+
+ ASSERT_EQ(1, kParent->child_count());
+ const BookmarkNode* kChild = kParent->GetChild(0);
+ EXPECT_EQ(kTitle, kChild->GetTitle());
+ EXPECT_EQ(kUrl, kChild->url());
+}
+
class BookmarkEditorControllerTreeTest : public CocoaProfileTest {
public:
« no previous file with comments | « chrome/browser/ui/bookmarks/bookmark_utils.cc ('k') | chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698