| 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); | 
 |  50 }, 'Construct a PasswordCredential with an empty name and icon URL.'); | 
|  52  |  51  | 
|  53 }, 'Construct a PasswordCredential with an empty name and icon URL.'); |  52 test(function() { | 
 |  53     var credential = new PasswordCredential('id', 'pencil'); | 
 |  54  | 
 |  55     var fd = credential.toFormData(); | 
 |  56     fd.append('n1', 'v1'); | 
 |  57     fd.append('n2', 'v2'); | 
 |  58     fd.append('n3', 'v3'); | 
 |  59     fd.append('n1', 'v4'); | 
 |  60     fd.append('n2', 'v5'); | 
 |  61     fd.append('n3', 'v6'); | 
 |  62  | 
 |  63     assert_equals(fd.get('n1'), null); | 
 |  64     assert_equals(fd.get('n2'), null); | 
 |  65     assert_equals(fd.get('n3'), null); | 
 |  66  | 
 |  67     assert_equals(fd.has('n1'), false); | 
 |  68     assert_equals(fd.has('n2'), false); | 
 |  69     assert_equals(fd.has('n3'), false); | 
 |  70  | 
 |  71     assert_array_equals(fd.getAll('n1'), []); | 
 |  72     assert_array_equals(fd.getAll('n2'), []); | 
 |  73     assert_array_equals(fd.getAll('n3'), []); | 
 |  74  | 
 |  75     for(var entry of fd) { | 
 |  76         assert_unreached("There should be nothing to iterate here."); | 
 |  77     } | 
 |  78 }, 'Verify properties of opaque FormData.'); | 
|  54 </script> |  79 </script> | 
| OLD | NEW |