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

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: 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
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 5bc4269e2644db0b0473c9abcf9aa0d27cd83823..22e0032cbf97367bf24c1b31e8e1ec3cd352c91e 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);
@@ -55,4 +55,35 @@ suite('<bookmarks-edit-dialog>', function() {
assertEquals(undefined, lastUpdate.edit.url);
assertEquals('Awesome websites', lastUpdate.edit.title);
});
+
+ 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);
+ });
+
});

Powered by Google App Engine
This is Rietveld 408576698