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('id', 'pencil', 'name', 'https://exa
mple.com/icon.png'); | 8 var credential = new PasswordCredential('id', 'pencil', 'name', 'https://exa
mple.com/icon.png'); |
9 | 9 |
10 verify_interface('PasswordCredential', credential, { | 10 verify_interface('PasswordCredential', credential, { |
11 formData: 'object', | |
12 id: 'string', | 11 id: 'string', |
13 name: 'string', | 12 name: 'string', |
14 iconURL: 'string', | 13 iconURL: 'string', |
15 password: 'string', | |
16 type: 'string' | 14 type: 'string' |
17 }); | 15 }); |
18 | 16 |
19 assert_true(credential.formData instanceof FormData); | |
20 assert_equals(credential.id, 'id'); | 17 assert_equals(credential.id, 'id'); |
21 assert_equals(credential.name, 'name'); | 18 assert_equals(credential.name, 'name'); |
22 assert_equals(credential.iconURL, 'https://example.com/icon.png'); | 19 assert_equals(credential.iconURL, 'https://example.com/icon.png'); |
23 assert_equals(credential.password, 'pencil'); | |
24 assert_equals(credential.type, 'password'); | 20 assert_equals(credential.type, 'password'); |
| 21 |
| 22 assert_true(credential.toFormData() instanceof FormData); |
25 }, 'Interfaces and attributes of PasswordCredential'); | 23 }, 'Interfaces and attributes of PasswordCredential'); |
26 | 24 |
27 test(function() { | 25 test(function() { |
28 assert_throws(new SyntaxError(), function () { | 26 assert_throws(new SyntaxError(), function () { |
29 var credential = new PasswordCredential('id', 'pencil', 'name', '-'); | 27 var credential = new PasswordCredential('id', 'pencil', 'name', '-'); |
30 }); | 28 }); |
31 }, 'Construct a PasswordCredential with an invalid icon URL.'); | 29 }, 'Construct a PasswordCredential with an invalid icon URL.'); |
32 | 30 |
33 test(function() { | 31 test(function() { |
34 var credential = new PasswordCredential('id', 'pencil', 'name'); | 32 var credential = new PasswordCredential('id', 'pencil', 'name'); |
35 | 33 |
36 assert_equals(credential.id, 'id'); | 34 assert_equals(credential.id, 'id'); |
37 assert_equals(credential.name, 'name'); | 35 assert_equals(credential.name, 'name'); |
38 assert_equals(credential.iconURL, ''); | 36 assert_equals(credential.iconURL, ''); |
39 assert_equals(credential.password, 'pencil'); | |
40 assert_equals(credential.type, 'password'); | 37 assert_equals(credential.type, 'password'); |
| 38 assert_true(credential.toFormData() instanceof FormData); |
41 | 39 |
42 }, 'Construct a PasswordCredential with an empty icon URL.'); | 40 }, 'Construct a PasswordCredential with an empty icon URL.'); |
43 | 41 |
44 test(function() { | 42 test(function() { |
45 var credential = new PasswordCredential('id', 'pencil'); | 43 var credential = new PasswordCredential('id', 'pencil'); |
46 | 44 |
47 assert_equals(credential.id, 'id'); | 45 assert_equals(credential.id, 'id'); |
48 assert_equals(credential.name, ''); | 46 assert_equals(credential.name, ''); |
49 assert_equals(credential.iconURL, ''); | 47 assert_equals(credential.iconURL, ''); |
50 assert_equals(credential.password, 'pencil'); | |
51 assert_equals(credential.type, 'password'); | 48 assert_equals(credential.type, 'password'); |
| 49 assert_true(credential.toFormData() instanceof FormData); |
52 | 50 |
53 }, 'Construct a PasswordCredential with an empty name and icon URL.'); | 51 }, 'Construct a PasswordCredential with an empty name and icon URL.'); |
54 </script> | 52 </script> |
OLD | NEW |