Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <title>Credential Manager: create() basics.</title> | |
| 3 <script src="../resources/testharness.js"></script> | |
| 4 <script src="../resources/testharnessreport.js"></script> | |
| 5 <script src="/serviceworker/resources/interfaces.js"></script> | |
| 6 <script> | |
| 7 (function() { | |
|
Mike West
2017/05/17 06:57:57
You don't need this wrapper, here or elsewhere.
jdoerrie
2017/05/17 11:29:09
Done.
| |
| 8 promise_test(function(t) { | |
| 9 return promise_rejects(t, "NotSupportedError", | |
| 10 navigator.credentials.create()); | |
| 11 }, "navigator.credentials.create() with no argument."); | |
| 12 }()); | |
| 13 | |
| 14 (function() { | |
| 15 promise_test(function(t) { | |
| 16 return promise_rejects(t, "NotSupportedError", | |
| 17 navigator.credentials.create({})); | |
|
Mike West
2017/05/17 06:57:57
Please add a test for `{password: { /* invalid pas
jdoerrie
2017/05/17 11:29:09
Done.
| |
| 18 }, "navigator.credentials.create() with empty argument."); | |
| 19 }()); | |
| 20 | |
| 21 (function() { | |
| 22 promise_test(function(t) { | |
| 23 var credential_data = { | |
| 24 id: 'id', | |
| 25 password: 'pencil', | |
| 26 }; | |
| 27 | |
| 28 return navigator.credentials.create({password: credential_data}) | |
| 29 .then(function(credential) { | |
| 30 assert_equals(credential.id, 'id'); | |
| 31 assert_equals(credential.name, ''); | |
| 32 assert_equals(credential.iconURL, ''); | |
| 33 assert_equals(credential.type, 'password'); | |
| 34 assert_equals(credential.idName, 'username'); | |
| 35 assert_equals(credential.passwordName, 'password'); | |
|
Mike West
2017/05/17 06:57:57
Since this test doesn't rely on the internal mocks
jdoerrie
2017/05/17 08:53:22
Sound good :) Just to make sure I understand you c
| |
| 36 assert_equals(credential.additionalData, null); | |
| 37 }); | |
| 38 }, "navigator.credentials.create() with valid PasswordCredentialData"); | |
| 39 }()); | |
| 40 | |
| 41 (function() { | |
| 42 promise_test(function(t) { | |
| 43 var f = document.createElement('form'); | |
| 44 f.innerHTML = "<input type='text' name='theId' value='musterman' autocom plete='username'>" | |
| 45 + "<input type='text' name='thePassword' value='sekrit' autocomplete ='current-password'>" | |
| 46 + "<input type='text' name='theIcon' value='https://example.com/phot o' autocomplete='photo'>" | |
| 47 + "<input type='text' name='theExtraField' value='extra'>" | |
| 48 + "<input type='text' name='theName' value='friendly name' autocompl ete='name'>"; | |
| 49 | |
| 50 return navigator.credentials.create({password: f}) | |
| 51 .then(function(credential) { | |
| 52 assert_equals(credential.id, 'musterman'); | |
| 53 assert_equals(credential.name, 'friendly name'); | |
| 54 assert_equals(credential.iconURL, 'https://example.com/photo'); | |
| 55 assert_equals(credential.idName, 'theId'); | |
| 56 assert_equals(credential.passwordName, 'thePassword'); | |
| 57 assert_equals(credential.type, 'password'); | |
| 58 | |
| 59 assert_equals(credential.additionalData.get('theId'), 'musterman '); | |
| 60 assert_equals(credential.additionalData.get('thePassword'), 'sek rit'); | |
| 61 assert_equals(credential.additionalData.get('theIcon'), | |
| 62 'https://example.com/photo'); | |
| 63 assert_equals(credential.additionalData.get('theName'), 'friendl y name'); | |
| 64 assert_equals(credential.additionalData.get('theExtraField'), 'e xtra'); | |
| 65 }); | |
| 66 }, "navigator.credentials.create() with valid HTMLFormElement"); | |
| 67 }()); | |
| 68 | |
| 69 (function() { | |
| 70 promise_test(function(t) { | |
| 71 return promise_rejects(t, new TypeError(), | |
| 72 navigator.credentials.create({password: "bogus password data"})) ; | |
| 73 }, "navigator.credentials.create() with bogus password data"); | |
| 74 }()); | |
| 75 | |
| 76 (function() { | |
| 77 promise_test(function(t) { | |
| 78 var federated_data = { | |
| 79 id: 'id', | |
| 80 provider: 'https://example.com/', | |
| 81 }; | |
| 82 | |
| 83 return navigator.credentials.create({federated: federated_data}) | |
| 84 .then(function(credential) { | |
| 85 assert_equals(credential.id, 'id'); | |
| 86 assert_equals(credential.name, ''); | |
| 87 assert_equals(credential.iconURL, ''); | |
| 88 assert_equals(credential.type, 'federated'); | |
| 89 }); | |
| 90 }, "navigator.credentials.create() with valid FederatedCredentialData"); | |
| 91 }()); | |
| 92 | |
| 93 (function() { | |
| 94 promise_test(function(t) { | |
| 95 return promise_rejects(t, new TypeError(), | |
| 96 navigator.credentials.create({federated: "bogus federated data"} )); | |
| 97 }, "navigator.credentials.create() with bogus federated data"); | |
| 98 }()); | |
| 99 | |
| 100 (function() { | |
| 101 promise_test(function(t) { | |
| 102 var credential_data = { | |
| 103 id: 'id', | |
| 104 password: 'pencil', | |
| 105 }; | |
| 106 | |
| 107 var federated_data = { | |
| 108 id: 'id', | |
| 109 provider: 'https://example.com/', | |
| 110 }; | |
| 111 | |
| 112 return promise_rejects(t, "NotSupportedError", | |
| 113 navigator.credentials.create({password: credential_data, | |
| 114 federated: federated_data})); | |
| 115 }, "navigator.credentials.create() with both PasswordCredentialData and Fede ratedCredentialData"); | |
| 116 }()); | |
| 117 </script> | |
| OLD | NEW |