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', |
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 | 26 assert_equals(credential.idName, 'username'); |
27 assert_true(credential.toFormData() instanceof FormData); | 27 assert_equals(credential.passwordName, 'password'); |
| 28 assert_equals(credential.additionalData, null); |
28 }, 'Interfaces and attributes of PasswordCredential'); | 29 }, 'Interfaces and attributes of PasswordCredential'); |
29 | 30 |
30 test(function() { | 31 test(function() { |
31 assert_throws(new SyntaxError(), function () { | 32 assert_throws(new SyntaxError(), function () { |
32 var credential = new PasswordCredential({ | 33 var credential = new PasswordCredential({ |
33 id: 'id', | 34 id: 'id', |
34 password: 'pencil', | 35 password: 'pencil', |
35 name: 'name', | 36 name: 'name', |
36 iconURL: '-' | 37 iconURL: '-' |
37 }); | 38 }); |
38 }); | 39 }); |
39 }, 'Construct a PasswordCredential with an invalid icon URL.'); | 40 }, 'Construct a PasswordCredential with an invalid icon URL.'); |
40 | 41 |
41 test(function() { | 42 test(function() { |
42 var credential = new PasswordCredential({ | 43 var credential = new PasswordCredential({ |
43 id: 'id', | 44 id: 'id', |
44 password: 'pencil', | 45 password: 'pencil', |
45 name: 'name', | 46 name: 'name', |
46 }); | 47 }); |
47 | 48 |
48 assert_equals(credential.id, 'id'); | 49 assert_equals(credential.id, 'id'); |
49 assert_equals(credential.name, 'name'); | 50 assert_equals(credential.name, 'name'); |
50 assert_equals(credential.iconURL, ''); | 51 assert_equals(credential.iconURL, ''); |
51 assert_equals(credential.type, 'password'); | 52 assert_equals(credential.type, 'password'); |
52 assert_true(credential.toFormData() instanceof FormData); | 53 assert_equals(credential.idName, 'username'); |
| 54 assert_equals(credential.passwordName, 'password'); |
| 55 assert_equals(credential.additionalData, null); |
53 | 56 |
54 }, 'Construct a PasswordCredential with an empty icon URL.'); | 57 }, 'Construct a PasswordCredential with an empty icon URL.'); |
55 | 58 |
56 test(function() { | 59 test(function() { |
57 var credential = new PasswordCredential({ | 60 var credential = new PasswordCredential({ |
58 id: 'id', | 61 id: 'id', |
59 password: 'pencil', | 62 password: 'pencil', |
60 }); | 63 }); |
61 | 64 |
62 assert_equals(credential.id, 'id'); | 65 assert_equals(credential.id, 'id'); |
63 assert_equals(credential.name, ''); | 66 assert_equals(credential.name, ''); |
64 assert_equals(credential.iconURL, ''); | 67 assert_equals(credential.iconURL, ''); |
65 assert_equals(credential.type, 'password'); | 68 assert_equals(credential.type, 'password'); |
66 assert_true(credential.toFormData() instanceof FormData); | 69 assert_equals(credential.idName, 'username'); |
| 70 assert_equals(credential.passwordName, 'password'); |
| 71 assert_equals(credential.additionalData, null); |
67 }, 'Construct a PasswordCredential with an empty name and icon URL.'); | 72 }, 'Construct a PasswordCredential with an empty name and icon URL.'); |
| 73 |
| 74 test(function() { |
| 75 var credential = new PasswordCredential({ |
| 76 id: 'id', |
| 77 password: 'pencil', |
| 78 }); |
| 79 |
| 80 credential.idName = 'yay'; |
| 81 assert_equals(credential.idName, 'yay'); |
| 82 |
| 83 credential.passwordName = 'boo'; |
| 84 assert_equals(credential.passwordName, 'boo'); |
| 85 |
| 86 var additionalData = new FormData(); |
| 87 credential.additionalData = additionalData; |
| 88 assert_equals(credential.additionalData, additionalData); |
| 89 }, 'Verify the basics of "idName", "passwordName", and "additionalData"'); |
68 </script> | 90 </script> |
OLD | NEW |