-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Password Manager] Url validation for the add password dialog
This CLs adds url validation to the add password dialog on the new UI. The behaviour is copied from the old UI. Bug: 1398560 Change-Id: I380259f815afea4948e2f3b892f2db579e639c7c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4272613 Commit-Queue: Viktor Semeniuk <vsemeniuk@google.com> Reviewed-by: Mohamed Amir Yosef <mamir@chromium.org> Cr-Commit-Position: refs/heads/main@{#1108216}
- Loading branch information
Viktor Semeniuk
authored and
Chromium LUCI CQ
committed
Feb 22, 2023
1 parent
a41da22
commit 614d19f
Showing
11 changed files
with
151 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
chrome/app/password_manager_ui_strings_grdp/IDS_PASSWORD_MANAGER_UI_MISSING_TLD.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6f6f7e0b3aee974b7f754d36f66ab1ce4009b3cb |
1 change: 1 addition & 0 deletions
1
...p/password_manager_ui_strings_grdp/IDS_PASSWORD_MANAGER_UI_NOT_VALID_WEB_ADDRESS.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
13d3bbcbd16feec628a953fbc6ff203e20fab07b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
chrome/test/data/webui/password_manager/add_password_dialog_test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'chrome://password-manager/password_manager.js'; | ||
|
||
import {PasswordManagerImpl} from 'chrome://password-manager/password_manager.js'; | ||
import {assertEquals, assertFalse, assertTrue} from 'chrome://webui-test/chai_assert.js'; | ||
import {flushTasks} from 'chrome://webui-test/polymer_test_util.js'; | ||
|
||
import {TestPasswordManagerProxy} from './test_password_manager_proxy.js'; | ||
|
||
suite('AddPasswordDialogTest', function() { | ||
let passwordManager: TestPasswordManagerProxy; | ||
|
||
setup(function() { | ||
document.body.innerHTML = window.trustedTypes!.emptyHTML; | ||
passwordManager = new TestPasswordManagerProxy(); | ||
PasswordManagerImpl.setInstance(passwordManager); | ||
return flushTasks(); | ||
}); | ||
|
||
test('url validation works', async function() { | ||
const dialog = document.createElement('add-password-dialog'); | ||
document.body.appendChild(dialog); | ||
await flushTasks(); | ||
|
||
assertFalse(dialog.$.websiteInput.invalid); | ||
|
||
// Make url invalid | ||
dialog.$.websiteInput.value = 'abc'; | ||
dialog.$.websiteInput.dispatchEvent(new CustomEvent('input')); | ||
assertEquals('abc', await passwordManager.whenCalled('getUrlCollection')); | ||
await flushTasks(); | ||
|
||
assertTrue(dialog.$.websiteInput.invalid); | ||
assertEquals( | ||
dialog.i18n('notValidWebsite'), dialog.$.websiteInput.errorMessage); | ||
|
||
// Now make URL valid again | ||
passwordManager.reset(); | ||
dialog.$.websiteInput.value = 'www'; | ||
dialog.$.websiteInput.dispatchEvent(new CustomEvent('input')); | ||
assertEquals('www', await passwordManager.whenCalled('getUrlCollection')); | ||
await flushTasks(); | ||
assertFalse(dialog.$.websiteInput.invalid); | ||
|
||
// But after losing focus url is no longer valid due to missing '.' | ||
dialog.$.websiteInput.dispatchEvent(new CustomEvent('blur')); | ||
assertTrue(dialog.$.websiteInput.invalid); | ||
assertEquals( | ||
dialog.i18n('missingTLD', 'www.com'), | ||
dialog.$.websiteInput.errorMessage); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters