| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Credential Manager: PasswordCredential basics.</title> | 2 <title>Credential Manager: PasswordCredential basics.</title> |
| 3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="/serviceworker/resources/interfaces.js"></script> | 5 <script src="/serviceworker/resources/interfaces.js"></script> |
| 6 <script> | 6 <script> |
| 7 test(function() { | 7 test(function() { |
| 8 var credential = new PasswordCredential({ | 8 var credential = new PasswordCredential({ |
| 9 id: 'id', | 9 id: 'id', |
| 10 password: 'pencil', | 10 password: 'pencil', |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 () => { new PasswordCredential({ 'password': undefined }); }); | 101 () => { new PasswordCredential({ 'password': undefined }); }); |
| 102 assert_throws(new TypeError(), | 102 assert_throws(new TypeError(), |
| 103 () => { new PasswordCredential({ 'password': '' }); }); | 103 () => { new PasswordCredential({ 'password': '' }); }); |
| 104 assert_throws(new TypeError(), | 104 assert_throws(new TypeError(), |
| 105 () => { new PasswordCredential({ 'id': undefined, 'password':
undefined }); }); | 105 () => { new PasswordCredential({ 'id': undefined, 'password':
undefined }); }); |
| 106 assert_throws(new TypeError(), | 106 assert_throws(new TypeError(), |
| 107 () => { new PasswordCredential({ 'id': undefined, 'password':
'' }); }); | 107 () => { new PasswordCredential({ 'id': undefined, 'password':
'' }); }); |
| 108 assert_throws(new TypeError(), | 108 assert_throws(new TypeError(), |
| 109 () => { new PasswordCredential({ 'id': undefined, 'password':
undefined }); }); | 109 () => { new PasswordCredential({ 'id': undefined, 'password':
undefined }); }); |
| 110 }, 'PasswordCredential objects require IDs and Passwords'); | 110 }, 'PasswordCredential objects require IDs and Passwords'); |
| 111 |
| 112 test(function () { |
| 113 var f = document.createElement('form'); |
| 114 f.innerHTML = "<input type='text' name='theId' value='musterman' autocomplet
e='username'>" |
| 115 + "<input type='text' name='thePassword' value='sekrit' autocomplete='cu
rrent-password'>" |
| 116 + "<input type='text' name='theIcon' value='https://example.com/photo' a
utocomplete='photo'>" |
| 117 + "<input type='text' name='theExtraField' value='extra'>" |
| 118 + "<input type='text' name='theName' value='friendly name' autocomplete=
'name'>"; |
| 119 |
| 120 var credential = new PasswordCredential(f); |
| 121 assert_equals(credential.id, 'musterman'); |
| 122 assert_equals(credential.name, 'friendly name'); |
| 123 assert_equals(credential.iconURL, 'https://example.com/photo'); |
| 124 assert_equals(credential.idName, 'theId'); |
| 125 assert_equals(credential.passwordName, 'thePassword'); |
| 126 assert_equals(credential.type, 'password'); |
| 127 |
| 128 assert_equals(credential.additionalData.get('theId'), 'musterman'); |
| 129 assert_equals(credential.additionalData.get('thePassword'), 'sekrit'); |
| 130 assert_equals(credential.additionalData.get('theIcon'), 'https://example.com
/photo'); |
| 131 assert_equals(credential.additionalData.get('theName'), 'friendly name'); |
| 132 assert_equals(credential.additionalData.get('theExtraField'), 'extra'); |
| 133 |
| 134 var password = f.querySelector('[name=thePassword]'); |
| 135 password.value = ""; |
| 136 assert_throws(new TypeError(), _ => new PasswordCredential(f)); |
| 137 f.removeChild(password); |
| 138 assert_throws(new TypeError(), _ => new PasswordCredential(f)); |
| 139 |
| 140 // Reset the password, do the same test for the ID. |
| 141 f.appendChild(password); |
| 142 password.value = "sekrit"; |
| 143 credential = new PasswordCredential(f); |
| 144 assert_true(credential instanceof PasswordCredential); |
| 145 |
| 146 var id = f.querySelector('[name=theId]'); |
| 147 id.value = ""; |
| 148 assert_throws(new TypeError(), _ => new PasswordCredential(f)); |
| 149 f.removeChild(id); |
| 150 assert_throws(new TypeError(), _ => new PasswordCredential(f)); |
| 151 }, 'PasswordCredential creation from `HTMLFormElement`'); |
| 111 </script> | 152 </script> |
| OLD | NEW |