Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <title>Credential Management API: create() basics.</title> | |
| 3 <script src="/resources/testharness.js"></script> | |
| 4 <script src="/resources/testharnessreport.js"></script> | |
| 5 <script> | |
| 6 promise_test(function(t) { | |
| 7 return promise_rejects(t, "NotSupportedError", | |
| 8 navigator.credentials.create()); | |
| 9 }, "navigator.credentials.create() with no argument."); | |
| 10 | |
| 11 promise_test(function(t) { | |
| 12 return promise_rejects(t, "NotSupportedError", | |
| 13 navigator.credentials.create({})); | |
| 14 }, "navigator.credentials.create() with empty argument."); | |
| 15 | |
| 16 promise_test(function(t) { | |
| 17 var credential_data = { | |
| 18 id: 'id', | |
| 19 password: 'pencil', | |
| 20 }; | |
| 21 | |
| 22 return navigator.credentials.create({password: credential_data}) | |
| 23 .then(function(credential) { | |
| 24 assert_equals(credential.id, 'id'); | |
| 25 assert_equals(credential.name, ''); | |
| 26 assert_equals(credential.iconURL, ''); | |
| 27 assert_equals(credential.type, 'password'); | |
|
Mike West
2017/05/17 11:39:40
Can you add something like `// TODO(jdoerrie): Add
| |
| 28 }); | |
| 29 }, "navigator.credentials.create() with valid PasswordCredentialData"); | |
| 30 | |
| 31 promise_test(function(t) { | |
| 32 var f = document.createElement('form'); | |
| 33 f.innerHTML = "<input type='text' name='theId' value='musterman' autocomplet e='username'>" | |
| 34 + "<input type='text' name='thePassword' value='sekrit' autocomplete='cu rrent-password'>" | |
| 35 + "<input type='text' name='theIcon' value='https://example.com/photo' a utocomplete='photo'>" | |
| 36 + "<input type='text' name='theExtraField' value='extra'>" | |
| 37 + "<input type='text' name='theName' value='friendly name' autocomplete= 'name'>"; | |
| 38 | |
| 39 return navigator.credentials.create({password: f}) | |
| 40 .then(function(credential) { | |
| 41 assert_equals(credential.id, 'musterman'); | |
| 42 assert_equals(credential.name, 'friendly name'); | |
| 43 assert_equals(credential.iconURL, 'https://example.com/photo'); | |
| 44 assert_equals(credential.type, 'password'); | |
| 45 }); | |
| 46 }, "navigator.credentials.create() with valid HTMLFormElement"); | |
| 47 | |
| 48 promise_test(function(t) { | |
| 49 return promise_rejects(t, new TypeError(), | |
| 50 navigator.credentials.create({password: "bogus password data"})); | |
| 51 }, "navigator.credentials.create() with bogus password data"); | |
| 52 | |
| 53 promise_test(function(t) { | |
| 54 var federated_data = { | |
| 55 id: 'id', | |
| 56 provider: 'https://example.com/', | |
| 57 }; | |
| 58 | |
| 59 return navigator.credentials.create({federated: federated_data}) | |
| 60 .then(function(credential) { | |
| 61 assert_equals(credential.id, 'id'); | |
| 62 assert_equals(credential.name, ''); | |
| 63 assert_equals(credential.iconURL, ''); | |
| 64 assert_equals(credential.type, 'federated'); | |
| 65 }); | |
| 66 }, "navigator.credentials.create() with valid FederatedCredentialData"); | |
| 67 | |
| 68 promise_test(function(t) { | |
| 69 return promise_rejects(t, new TypeError(), | |
| 70 navigator.credentials.create({federated: "bogus federated data"})); | |
| 71 }, "navigator.credentials.create() with bogus federated data"); | |
| 72 | |
| 73 promise_test(function(t) { | |
| 74 var credential_data = { | |
| 75 id: 'id', | |
| 76 password: 'pencil', | |
| 77 }; | |
| 78 | |
| 79 var federated_data = { | |
| 80 id: 'id', | |
| 81 provider: 'https://example.com/', | |
| 82 }; | |
| 83 | |
| 84 return promise_rejects(t, "NotSupportedError", | |
| 85 navigator.credentials.create({ | |
| 86 password: credential_data, | |
| 87 federated: federated_data, | |
| 88 })); | |
| 89 }, "navigator.credentials.create() with both PasswordCredentialData and Federate dCredentialData"); | |
| 90 | |
| 91 promise_test(function(t) { | |
| 92 return promise_rejects(t, new TypeError(), | |
| 93 navigator.credentials.create({ | |
| 94 password: "bogus password data", | |
| 95 federated: "bogus federated data", | |
| 96 })); | |
| 97 }, "navigator.credentials.create() with bogus password and federated data"); | |
| 98 | |
| 99 promise_test(function(t) { | |
| 100 return promise_rejects(t, "NotSupportedError", | |
| 101 navigator.credentials.create({bogus_key: "bogus data"})); | |
| 102 }, "navigator.credentials.create() with bogus data"); | |
| 103 </script> | |
| OLD | NEW |