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

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

Issue 2852423002: Expose passwords to JavaScript in Credential Manager API (Closed)
Patch Set: Console Message Created 3 years, 7 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="resources/interfaces.js"></script> 5 <script src="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',
11 name: 'name', 11 name: 'name',
12 iconURL: 'https://example.com/icon.png' 12 iconURL: 'https://example.com/icon.png'
13 }); 13 });
14 14
15 verify_interface('PasswordCredential', credential, { 15 verify_interface('PasswordCredential', credential, {
16 id: 'string', 16 id: 'string',
17 name: 'string', 17 name: 'string',
18 iconURL: 'string', 18 iconURL: 'string',
19 type: 'string' 19 type: 'string'
20 }); 20 });
21 21
22 assert_equals(credential.id, 'id'); 22 assert_equals(credential.id, 'id');
23 assert_equals(credential.name, 'name'); 23 assert_equals(credential.name, 'name');
24 assert_equals(credential.iconURL, 'https://example.com/icon.png'); 24 assert_equals(credential.iconURL, 'https://example.com/icon.png');
25 assert_equals(credential.type, 'password'); 25 assert_equals(credential.type, 'password');
26 assert_equals(credential.idName, 'username'); 26 assert_equals(credential.idName, 'username');
27 assert_equals(credential.passwordName, 'password'); 27 assert_equals(credential.passwordName, 'password');
28 assert_equals(credential.additionalData, null); 28 assert_equals(credential.additionalData, null);
29 assert_equals(credential.password, 'pencil');
29 }, 'Interfaces and attributes of PasswordCredential'); 30 }, 'Interfaces and attributes of PasswordCredential');
30 31
31 test(function() { 32 test(function() {
32 assert_throws(new SyntaxError(), function () { 33 assert_throws(new SyntaxError(), function () {
33 var credential = new PasswordCredential({ 34 var credential = new PasswordCredential({
34 id: 'id', 35 id: 'id',
35 password: 'pencil', 36 password: 'pencil',
36 name: 'name', 37 name: 'name',
37 iconURL: '-' 38 iconURL: '-'
38 }); 39 });
39 }); 40 });
40 }, 'Construct a PasswordCredential with an invalid icon URL.'); 41 }, 'Construct a PasswordCredential with an invalid icon URL.');
41 42
42 test(function() { 43 test(function() {
43 var credential = new PasswordCredential({ 44 var credential = new PasswordCredential({
44 id: 'id', 45 id: 'id',
45 password: 'pencil', 46 password: 'pencil',
46 name: 'name', 47 name: 'name',
47 }); 48 });
48 49
49 assert_equals(credential.id, 'id'); 50 assert_equals(credential.id, 'id');
50 assert_equals(credential.name, 'name'); 51 assert_equals(credential.name, 'name');
51 assert_equals(credential.iconURL, ''); 52 assert_equals(credential.iconURL, '');
52 assert_equals(credential.type, 'password'); 53 assert_equals(credential.type, 'password');
53 assert_equals(credential.idName, 'username'); 54 assert_equals(credential.idName, 'username');
54 assert_equals(credential.passwordName, 'password'); 55 assert_equals(credential.passwordName, 'password');
55 assert_equals(credential.additionalData, null); 56 assert_equals(credential.additionalData, null);
57 assert_equals(credential.password, 'pencil');
56 58
57 }, 'Construct a PasswordCredential with an empty icon URL.'); 59 }, 'Construct a PasswordCredential with an empty icon URL.');
58 60
59 test(function() { 61 test(function() {
60 var credential = new PasswordCredential({ 62 var credential = new PasswordCredential({
61 id: 'id', 63 id: 'id',
62 password: 'pencil', 64 password: 'pencil',
63 }); 65 });
64 66
65 assert_equals(credential.id, 'id'); 67 assert_equals(credential.id, 'id');
66 assert_equals(credential.name, ''); 68 assert_equals(credential.name, '');
67 assert_equals(credential.iconURL, ''); 69 assert_equals(credential.iconURL, '');
68 assert_equals(credential.type, 'password'); 70 assert_equals(credential.type, 'password');
69 assert_equals(credential.idName, 'username'); 71 assert_equals(credential.idName, 'username');
70 assert_equals(credential.passwordName, 'password'); 72 assert_equals(credential.passwordName, 'password');
71 assert_equals(credential.additionalData, null); 73 assert_equals(credential.additionalData, null);
74 assert_equals(credential.password, 'pencil');
72 }, 'Construct a PasswordCredential with an empty name and icon URL.'); 75 }, 'Construct a PasswordCredential with an empty name and icon URL.');
73 76
74 test(function() { 77 test(function() {
75 var credential = new PasswordCredential({ 78 var credential = new PasswordCredential({
76 id: 'id', 79 id: 'id',
77 password: 'pencil', 80 password: 'pencil',
78 }); 81 });
79 82
80 credential.idName = 'yay'; 83 credential.idName = 'yay';
81 assert_equals(credential.idName, 'yay'); 84 assert_equals(credential.idName, 'yay');
82 85
83 credential.passwordName = 'boo'; 86 credential.passwordName = 'boo';
84 assert_equals(credential.passwordName, 'boo'); 87 assert_equals(credential.passwordName, 'boo');
85 88
86 var additionalData = new FormData(); 89 var additionalData = new FormData();
87 credential.additionalData = additionalData; 90 credential.additionalData = additionalData;
88 assert_equals(credential.additionalData, additionalData); 91 assert_equals(credential.additionalData, additionalData);
92
93 assert_equals(credential.password, 'pencil');
89 }, 'Verify the basics of "idName", "passwordName", and "additionalData"'); 94 }, 'Verify the basics of "idName", "passwordName", and "additionalData"');
90 95
91 test(function() { 96 test(function() {
92 assert_throws(new TypeError(), 97 assert_throws(new TypeError(),
93 () => { new PasswordCredential(); }); 98 () => { new PasswordCredential(); });
94 assert_throws(new TypeError(), 99 assert_throws(new TypeError(),
95 () => { new PasswordCredential({}); }); 100 () => { new PasswordCredential({}); });
96 assert_throws(new TypeError(), 101 assert_throws(new TypeError(),
97 () => { new PasswordCredential({ 'id': undefined }); }); 102 () => { new PasswordCredential({ 'id': undefined }); });
98 assert_throws(new TypeError(), 103 assert_throws(new TypeError(),
(...skipping 17 matching lines...) Expand all
116 assert_equals(credential.idName, 'theId'); 121 assert_equals(credential.idName, 'theId');
117 assert_equals(credential.passwordName, 'thePassword'); 122 assert_equals(credential.passwordName, 'thePassword');
118 assert_equals(credential.type, 'password'); 123 assert_equals(credential.type, 'password');
119 124
120 assert_equals(credential.additionalData.get('theId'), 'musterman'); 125 assert_equals(credential.additionalData.get('theId'), 'musterman');
121 assert_equals(credential.additionalData.get('thePassword'), 'sekrit'); 126 assert_equals(credential.additionalData.get('thePassword'), 'sekrit');
122 assert_equals(credential.additionalData.get('theIcon'), 'https://example.com /photo'); 127 assert_equals(credential.additionalData.get('theIcon'), 'https://example.com /photo');
123 assert_equals(credential.additionalData.get('theName'), 'friendly name'); 128 assert_equals(credential.additionalData.get('theName'), 'friendly name');
124 assert_equals(credential.additionalData.get('theExtraField'), 'extra'); 129 assert_equals(credential.additionalData.get('theExtraField'), 'extra');
125 130
131 assert_equals(credential.password, 'sekrit');
132
126 var password = f.querySelector('[name=thePassword]'); 133 var password = f.querySelector('[name=thePassword]');
127 password.value = ""; 134 password.value = "";
128 assert_throws(new TypeError(), _ => new PasswordCredential(f)); 135 assert_throws(new TypeError(), _ => new PasswordCredential(f));
129 f.removeChild(password); 136 f.removeChild(password);
130 assert_throws(new TypeError(), _ => new PasswordCredential(f)); 137 assert_throws(new TypeError(), _ => new PasswordCredential(f));
131 138
132 // Reset the password, do the same test for the ID. 139 // Reset the password, do the same test for the ID.
133 f.appendChild(password); 140 f.appendChild(password);
134 password.value = "sekrit"; 141 password.value = "sekrit";
135 credential = new PasswordCredential(f); 142 credential = new PasswordCredential(f);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 + "<input type='text' name='thePassword' value='sekrit' autocomplete='cu rrent-password value1'>" 196 + "<input type='text' name='thePassword' value='sekrit' autocomplete='cu rrent-password value1'>"
190 + "<input type='text' name='theIcon' value='https://example.com/photo' a utocomplete='photo value2'>" 197 + "<input type='text' name='theIcon' value='https://example.com/photo' a utocomplete='photo value2'>"
191 + "<input type='text' name='theExtraField' value='extra'>" 198 + "<input type='text' name='theExtraField' value='extra'>"
192 + "<input type='text' name='theName' value='friendly name' autocomplete= 'name value3'>"; 199 + "<input type='text' name='theName' value='friendly name' autocomplete= 'name value3'>";
193 200
194 var credential = new PasswordCredential(f); 201 var credential = new PasswordCredential(f);
195 assert_true(credential.additionalData instanceof URLSearchParams); 202 assert_true(credential.additionalData instanceof URLSearchParams);
196 verify_form_credential(f, credential); 203 verify_form_credential(f, credential);
197 }, 'PasswordCredential creation from `HTMLFormElement` with multiple autocomplet e attributes'); 204 }, 'PasswordCredential creation from `HTMLFormElement` with multiple autocomplet e attributes');
198 </script> 205 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698