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

Unified 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, 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
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 0066f5d352520629cf5672576d90178964dc2af7..353560dfc2b6dc40b9be7ea76bf5723624453142 100644
--- a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-basics.html
+++ b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-basics.html
@@ -109,15 +109,7 @@ test(function() {
() => { 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);
+function verify_form_credential(f, credential) {
assert_equals(credential.id, 'musterman');
assert_equals(credential.name, 'friendly name');
assert_equals(credential.iconURL, 'https://example.com/photo');
@@ -145,5 +137,46 @@ test(function () {
assert_throws(new TypeError(), _ => { new PasswordCredential(f); });
f.removeChild(id);
assert_throws(new TypeError(), _ => { new PasswordCredential(f); });
-}, 'PasswordCredential creation from `HTMLFormElement`');
+}
+
+test(_ => {
+ var f = document.createElement('form');
+ 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. :)
+ 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_true(credential.additionalData instanceof FormData);
+ verify_form_credential(f, credential);
+}, 'PasswordCredential creation from `HTMLFormElement` with a multipart enctype');
+
+test(_ => {
+ var f = document.createElement('form');
+ f.setAttribute('enctype', 'application/x-www-form-urlencoded');
+ 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_true(credential.additionalData instanceof URLSearchParams);
+ verify_form_credential(f, credential);
+}, 'PasswordCredential creation from `HTMLFormElement` with a urlencoded enctype');
+
+test(_ => {
+ 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_true(credential.additionalData instanceof URLSearchParams);
+ verify_form_credential(f, credential);
+}, 'PasswordCredential creation from `HTMLFormElement` with no enctype');
</script>

Powered by Google App Engine
This is Rietveld 408576698