OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Credential Management API: create() basics.</title> | 2 <title>Credential Management API: create() 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> | 5 <script> |
6 promise_test(function(t) { | 6 promise_test(function(t) { |
7 return promise_rejects(t, "NotSupportedError", | 7 return promise_rejects(t, "NotSupportedError", |
8 navigator.credentials.create()); | 8 navigator.credentials.create()); |
9 }, "navigator.credentials.create() with no argument."); | 9 }, "navigator.credentials.create() with no argument."); |
10 | 10 |
11 promise_test(function(t) { | 11 promise_test(function(t) { |
12 return promise_rejects(t, "NotSupportedError", | 12 return promise_rejects(t, "NotSupportedError", |
13 navigator.credentials.create({})); | 13 navigator.credentials.create({})); |
14 }, "navigator.credentials.create() with empty argument."); | 14 }, "navigator.credentials.create() with empty argument."); |
15 | 15 |
16 promise_test(function(t) { | 16 promise_test(function(t) { |
17 var credential_data = { | 17 var credential_data = { |
18 id: 'id', | 18 id: 'id', |
19 password: 'pencil', | 19 password: 'pencil', |
20 }; | 20 }; |
21 | 21 |
22 return navigator.credentials.create({password: credential_data}) | 22 return navigator.credentials.create({password: credential_data}) |
23 .then(function(credential) { | 23 .then(function(credential) { |
24 assert_equals(credential.id, 'id'); | 24 assert_equals(credential.id, 'id'); |
25 assert_equals(credential.name, ''); | 25 assert_equals(credential.name, ''); |
26 assert_equals(credential.iconURL, ''); | 26 assert_equals(credential.iconURL, ''); |
27 assert_equals(credential.type, 'password'); | 27 assert_equals(credential.type, 'password'); |
28 // TODO(jdoerrie): Add checks for 'credential.password'. | 28 assert_equals(credential.password, 'pencil'); |
29 }); | 29 }); |
30 }, "navigator.credentials.create() with valid PasswordCredentialData"); | 30 }, "navigator.credentials.create() with valid PasswordCredentialData"); |
31 | 31 |
32 promise_test(function(t) { | 32 promise_test(function(t) { |
33 var f = document.createElement('form'); | 33 var f = document.createElement('form'); |
34 f.innerHTML = "<input type='text' name='theId' value='musterman' autocomplet
e='username'>" | 34 f.innerHTML = "<input type='text' name='theId' value='musterman' autocomplet
e='username'>" |
35 + "<input type='text' name='thePassword' value='sekrit' autocomplete='cu
rrent-password'>" | 35 + "<input type='text' name='thePassword' value='sekrit' autocomplete='cu
rrent-password'>" |
36 + "<input type='text' name='theIcon' value='https://example.com/photo' a
utocomplete='photo'>" | 36 + "<input type='text' name='theIcon' value='https://example.com/photo' a
utocomplete='photo'>" |
37 + "<input type='text' name='theExtraField' value='extra'>" | 37 + "<input type='text' name='theExtraField' value='extra'>" |
38 + "<input type='text' name='theName' value='friendly name' autocomplete=
'name'>"; | 38 + "<input type='text' name='theName' value='friendly name' autocomplete=
'name'>"; |
39 | 39 |
40 return navigator.credentials.create({password: f}) | 40 return navigator.credentials.create({password: f}) |
41 .then(function(credential) { | 41 .then(function(credential) { |
42 assert_equals(credential.id, 'musterman'); | 42 assert_equals(credential.id, 'musterman'); |
43 assert_equals(credential.name, 'friendly name'); | 43 assert_equals(credential.name, 'friendly name'); |
44 assert_equals(credential.iconURL, 'https://example.com/photo'); | 44 assert_equals(credential.iconURL, 'https://example.com/photo'); |
45 assert_equals(credential.type, 'password'); | 45 assert_equals(credential.type, 'password'); |
| 46 assert_equals(credential.password, 'sekrit'); |
46 }); | 47 }); |
47 }, "navigator.credentials.create() with valid HTMLFormElement"); | 48 }, "navigator.credentials.create() with valid HTMLFormElement"); |
48 | 49 |
49 promise_test(function(t) { | 50 promise_test(function(t) { |
50 return promise_rejects(t, new TypeError(), | 51 return promise_rejects(t, new TypeError(), |
51 navigator.credentials.create({password: "bogus password data"})); | 52 navigator.credentials.create({password: "bogus password data"})); |
52 }, "navigator.credentials.create() with bogus password data"); | 53 }, "navigator.credentials.create() with bogus password data"); |
53 | 54 |
54 promise_test(function(t) { | 55 promise_test(function(t) { |
55 var federated_data = { | 56 var federated_data = { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 password: "bogus password data", | 96 password: "bogus password data", |
96 federated: "bogus federated data", | 97 federated: "bogus federated data", |
97 })); | 98 })); |
98 }, "navigator.credentials.create() with bogus password and federated data"); | 99 }, "navigator.credentials.create() with bogus password and federated data"); |
99 | 100 |
100 promise_test(function(t) { | 101 promise_test(function(t) { |
101 return promise_rejects(t, "NotSupportedError", | 102 return promise_rejects(t, "NotSupportedError", |
102 navigator.credentials.create({bogus_key: "bogus data"})); | 103 navigator.credentials.create({bogus_key: "bogus data"})); |
103 }, "navigator.credentials.create() with bogus data"); | 104 }, "navigator.credentials.create() with bogus data"); |
104 </script> | 105 </script> |
OLD | NEW |