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

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

Issue 1828923003: CREDENTIAL: Teach the 'PasswordCredential(HTMLFormElement)' constructor about URLSearchParams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@HTMLFormElement
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 111
112 test(function () { 112 function verify_form_credential(f, credential) {
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'); 113 assert_equals(credential.id, 'musterman');
122 assert_equals(credential.name, 'friendly name'); 114 assert_equals(credential.name, 'friendly name');
123 assert_equals(credential.iconURL, 'https://example.com/photo'); 115 assert_equals(credential.iconURL, 'https://example.com/photo');
124 assert_equals(credential.idName, 'theId'); 116 assert_equals(credential.idName, 'theId');
125 assert_equals(credential.passwordName, 'thePassword'); 117 assert_equals(credential.passwordName, 'thePassword');
126 assert_equals(credential.type, 'password'); 118 assert_equals(credential.type, 'password');
127 119
128 assert_equals(credential.additionalData.get('theId'), 'musterman'); 120 assert_equals(credential.additionalData.get('theId'), 'musterman');
129 assert_equals(credential.additionalData.get('thePassword'), 'sekrit'); 121 assert_equals(credential.additionalData.get('thePassword'), 'sekrit');
130 assert_equals(credential.additionalData.get('theIcon'), 'https://example.com /photo'); 122 assert_equals(credential.additionalData.get('theIcon'), 'https://example.com /photo');
131 assert_equals(credential.additionalData.get('theName'), 'friendly name'); 123 assert_equals(credential.additionalData.get('theName'), 'friendly name');
132 assert_equals(credential.additionalData.get('theExtraField'), 'extra'); 124 assert_equals(credential.additionalData.get('theExtraField'), 'extra');
133 125
134 var password = f.querySelector('[name=thePassword]'); 126 var password = f.querySelector('[name=thePassword]');
135 var id = f.querySelector('[name=theId]'); 127 var id = f.querySelector('[name=theId]');
136 password.value = ""; 128 password.value = "";
137 assert_throws(new TypeError(), _ => { new PasswordCredential(f); }); 129 assert_throws(new TypeError(), _ => { new PasswordCredential(f); });
138 f.removeChild(password); 130 f.removeChild(password);
139 assert_throws(new TypeError(), _ => { new PasswordCredential(f); }); 131 assert_throws(new TypeError(), _ => { new PasswordCredential(f); });
140 132
141 // Reset the password, do the same test for the ID. 133 // Reset the password, do the same test for the ID.
142 f.appendChild(password); 134 f.appendChild(password);
143 password.value = "sekrit"; 135 password.value = "sekrit";
144 id.value = ""; 136 id.value = "";
145 assert_throws(new TypeError(), _ => { new PasswordCredential(f); }); 137 assert_throws(new TypeError(), _ => { new PasswordCredential(f); });
146 f.removeChild(id); 138 f.removeChild(id);
147 assert_throws(new TypeError(), _ => { new PasswordCredential(f); }); 139 assert_throws(new TypeError(), _ => { new PasswordCredential(f); });
148 }, 'PasswordCredential creation from `HTMLFormElement`'); 140 }
141
142 test(_ => {
143 var f = document.createElement('form');
144 f.setAttribute('enctype', 'multipart/form-data');
philipj_slow 2016/03/24 13:58:09 enctype is a reflected attribute (per spec) if you
philipj_slow 2016/03/29 06:07:34 However you change this, maybe use a non-canonical
Mike West 2016/03/31 08:53:17 Done and done. :)
145 f.innerHTML = "<input type='text' name='theId' value='musterman' autocomplet e='username'>"
146 + "<input type='text' name='thePassword' value='sekrit' autocomplete='cu rrent-password'>"
147 + "<input type='text' name='theIcon' value='https://example.com/photo' a utocomplete='photo'>"
148 + "<input type='text' name='theExtraField' value='extra'>"
149 + "<input type='text' name='theName' value='friendly name' autocomplete= 'name'>";
150
151 var credential = new PasswordCredential(f);
152 assert_true(credential.additionalData instanceof FormData);
153 verify_form_credential(f, credential);
154 }, 'PasswordCredential creation from `HTMLFormElement` with a multipart enctype' );
155
156 test(_ => {
157 var f = document.createElement('form');
158 f.setAttribute('enctype', 'application/x-www-form-urlencoded');
159 f.innerHTML = "<input type='text' name='theId' value='musterman' autocomplet e='username'>"
160 + "<input type='text' name='thePassword' value='sekrit' autocomplete='cu rrent-password'>"
161 + "<input type='text' name='theIcon' value='https://example.com/photo' a utocomplete='photo'>"
162 + "<input type='text' name='theExtraField' value='extra'>"
163 + "<input type='text' name='theName' value='friendly name' autocomplete= 'name'>";
164
165 var credential = new PasswordCredential(f);
166 assert_true(credential.additionalData instanceof URLSearchParams);
167 verify_form_credential(f, credential);
168 }, 'PasswordCredential creation from `HTMLFormElement` with a urlencoded enctype ');
169
170 test(_ => {
171 var f = document.createElement('form');
172 f.innerHTML = "<input type='text' name='theId' value='musterman' autocomplet e='username'>"
173 + "<input type='text' name='thePassword' value='sekrit' autocomplete='cu rrent-password'>"
174 + "<input type='text' name='theIcon' value='https://example.com/photo' a utocomplete='photo'>"
175 + "<input type='text' name='theExtraField' value='extra'>"
176 + "<input type='text' name='theName' value='friendly name' autocomplete= 'name'>";
177
178 var credential = new PasswordCredential(f);
179 assert_true(credential.additionalData instanceof URLSearchParams);
180 verify_form_credential(f, credential);
181 }, 'PasswordCredential creation from `HTMLFormElement` with no enctype');
149 </script> 182 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698