Chromium Code Reviews| 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..0066f5d352520629cf5672576d90178964dc2af7 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,42 @@ 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]'); |
| + var id = f.querySelector('[name=theId]'); |
| + password.value = ""; |
| + assert_throws(new TypeError(), _ => { new PasswordCredential(f); }); |
|
philipj_slow
2016/03/29 05:45:54
{} seem to not be needed here.
Mike West
2016/03/31 08:31:41
Removed.
|
| + 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"; |
|
philipj_slow
2016/03/29 05:45:54
assert that it doesn't throw after this to make su
Mike West
2016/03/31 08:31:41
Sure.
|
| + id.value = ""; |
| + assert_throws(new TypeError(), _ => { new PasswordCredential(f); }); |
| + f.removeChild(id); |
| + assert_throws(new TypeError(), _ => { new PasswordCredential(f); }); |
| +}, 'PasswordCredential creation from `HTMLFormElement`'); |
| </script> |