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

Unified Diff: chrome/test/data/webui/md_bookmarks/edit_dialog_test.js

Issue 2769863002: MD Bookmarks: Validate URL input when editing a bookmark (Closed)
Patch Set: Rebase Created 3 years, 9 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/webui/md_bookmarks/md_bookmarks_ui.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/md_bookmarks/edit_dialog_test.js
diff --git a/chrome/test/data/webui/md_bookmarks/edit_dialog_test.js b/chrome/test/data/webui/md_bookmarks/edit_dialog_test.js
index 3eb9a2d7dca14b96b60080872a59e8007274b7d8..f433c9cbddaba499ca66e54582f6a4c65dbff829 100644
--- a/chrome/test/data/webui/md_bookmarks/edit_dialog_test.js
+++ b/chrome/test/data/webui/md_bookmarks/edit_dialog_test.js
@@ -35,7 +35,7 @@ suite('<bookmarks-edit-dialog>', function() {
test('editing passes the correct details to the update', function() {
// Editing an item without changing anything.
- var item = createItem('1', {url: 'www.website.com', title: 'website'});
+ var item = createItem('1', {url: 'http://website.com', title: 'website'});
dialog.showEditDialog(item);
MockInteractions.tap(dialog.$.saveButton);
@@ -63,4 +63,34 @@ suite('<bookmarks-edit-dialog>', function() {
MockInteractions.pressEnter(dialog.$.url);
assertFalse(dialog.$.dialog.open);
});
+
+ test('validates urls correctly', function() {
+ dialog.urlValue_ = 'http://www.example.com';
+ assertTrue(dialog.validateUrl_());
+
+ dialog.urlValue_ = 'https://a@example.com:8080';
+ assertTrue(dialog.validateUrl_());
+
+ dialog.urlValue_ = 'example.com';
+ assertTrue(dialog.validateUrl_());
+ assertEquals('http://example.com', dialog.urlValue_);
+
+ dialog.urlValue_ = '';
+ assertFalse(dialog.validateUrl_());
+
+ dialog.urlValue_ = '~~~example.com~~~';
+ assertFalse(dialog.validateUrl_());
+ });
+
+ test('doesn\'t save when URL is invalid', function() {
+ var item = createItem('0');
+ dialog.showEditDialog(item);
+
+ dialog.urlValue_ = '';
+
+ MockInteractions.tap(dialog.$.saveButton);
+
+ assertTrue(dialog.$.url.invalid);
+ assertTrue(dialog.$.dialog.open);
+ });
});
« no previous file with comments | « chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698