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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-basics.html

Issue 1828213002: CREDENTIAL: Implement the 'PasswordCredential(HTMLFormElement)' constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: EXPORT2 Created 4 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 | « no previous file | third_party/WebKit/Source/core/html/FormAssociatedElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-basics.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-basics.html b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-basics.html
index eced29d615a7555f72d5ff6856e0246dd208d853..5e1277c24a6cde75a9a050a4044b821e2f63bc44 100644
--- a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-basics.html
+++ b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-basics.html
@@ -108,4 +108,45 @@ test(function() {
assert_throws(new TypeError(),
() => { new PasswordCredential({ 'id': undefined, 'password': undefined }); });
}, 'PasswordCredential objects require IDs and Passwords');
+
+test(function () {
+ var f = document.createElement('form');
+ f.innerHTML = "<input type='text' name='theId' value='musterman' autocomplete='username'>"
+ + "<input type='text' name='thePassword' value='sekrit' autocomplete='current-password'>"
+ + "<input type='text' name='theIcon' value='https://example.com/photo' autocomplete='photo'>"
+ + "<input type='text' name='theExtraField' value='extra'>"
+ + "<input type='text' name='theName' value='friendly name' autocomplete='name'>";
+
+ var credential = new PasswordCredential(f);
+ assert_equals(credential.id, 'musterman');
+ assert_equals(credential.name, 'friendly name');
+ assert_equals(credential.iconURL, 'https://example.com/photo');
+ assert_equals(credential.idName, 'theId');
+ assert_equals(credential.passwordName, 'thePassword');
+ assert_equals(credential.type, 'password');
+
+ assert_equals(credential.additionalData.get('theId'), 'musterman');
+ assert_equals(credential.additionalData.get('thePassword'), 'sekrit');
+ assert_equals(credential.additionalData.get('theIcon'), 'https://example.com/photo');
+ assert_equals(credential.additionalData.get('theName'), 'friendly name');
+ assert_equals(credential.additionalData.get('theExtraField'), 'extra');
+
+ var password = f.querySelector('[name=thePassword]');
+ password.value = "";
+ assert_throws(new TypeError(), _ => new PasswordCredential(f));
+ f.removeChild(password);
+ assert_throws(new TypeError(), _ => new PasswordCredential(f));
+
+ // Reset the password, do the same test for the ID.
+ f.appendChild(password);
+ password.value = "sekrit";
+ credential = new PasswordCredential(f);
+ assert_true(credential instanceof PasswordCredential);
+
+ var id = f.querySelector('[name=theId]');
+ id.value = "";
+ assert_throws(new TypeError(), _ => new PasswordCredential(f));
+ f.removeChild(id);
+ assert_throws(new TypeError(), _ => new PasswordCredential(f));
+}, 'PasswordCredential creation from `HTMLFormElement`');
</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/FormAssociatedElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698