Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Credential Manager: get() basics.</title> | 2 <title>Credential Manager: get() 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="resources/interfaces.js"></script> | 5 <script src="/w3c/resources/WebIDLParser.js"></script> |
| 6 <script src="/w3c/resources/idlharness.js"></script> | |
| 7 <script type="text/plain" id="tested"> | |
| 8 [Exposed=Window, SecureContext] | |
| 9 interface Credential { | |
| 10 readonly attribute USVString id; | |
| 11 readonly attribute DOMString type; | |
| 12 }; | |
| 13 | |
| 14 [NoInterfaceObject, SecureContext] | |
| 15 interface CredentialUserData { | |
| 16 readonly attribute USVString name; | |
| 17 readonly attribute USVString iconURL; | |
| 18 }; | |
| 19 | |
| 20 [Constructor(HTMLFormElement form), | |
| 21 Constructor(PasswordCredentialData data), | |
| 22 Exposed=Window, | |
| 23 SecureContext] | |
| 24 interface PasswordCredential : Credential { | |
| 25 readonly attribute USVString password; | |
| 26 }; | |
| 27 | |
| 28 PasswordCredential implements CredentialUserData; | |
| 29 </script> | |
| 6 <script> | 30 <script> |
| 7 function stubResolverUndefinedChecker(c) { | 31 function stubResolverUndefinedChecker(c) { |
| 8 assert_equals(c, undefined); | 32 assert_equals(c, undefined); |
| 9 this.done(); | 33 this.done(); |
| 10 } | 34 } |
| 11 | 35 |
| 12 function stubRejectionChecker(reason) { | 36 function stubRejectionChecker(reason) { |
| 13 assert_unreached("get(...) should not reject, but did: " + reason.name); | 37 assert_unreached("get(...) should not reject, but did: " + reason.name); |
| 14 } | 38 } |
| 15 | 39 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 }); | 147 }); |
| 124 }()); | 148 }()); |
| 125 | 149 |
| 126 (function () { | 150 (function () { |
| 127 var id = "id"; | 151 var id = "id"; |
| 128 var name = "name"; | 152 var name = "name"; |
| 129 var icon = "http://example.com/"; | 153 var icon = "http://example.com/"; |
| 130 var password = "pencil"; | 154 var password = "pencil"; |
| 131 | 155 |
| 132 function stubResolverChecker(c) { | 156 function stubResolverChecker(c) { |
| 133 verify_interface('PasswordCredential', c, { | 157 var idl_array = new IdlArray(); |
| 134 id: 'string', | 158 idl_array.add_idls(document.querySelector('#tested').textContent); |
| 135 name: 'string', | 159 window.c = c; |
| 136 iconURL: 'string' | 160 idl_array.add_objects({ |
| 161 PasswordCredential: ["c"] | |
| 137 }); | 162 }); |
| 163 idl_array.test(); | |
|
Mike West
2017/05/29 12:10:38
Likewise, the IDL checks here can just be removed
mike3
2017/05/29 17:41:11
Done.
| |
| 138 | 164 |
| 139 assert_equals(c.id, id); | 165 assert_equals(c.id, id); |
| 140 assert_equals(c.name, name); | 166 assert_equals(c.name, name); |
| 141 assert_equals(c.iconURL, icon); | 167 assert_equals(c.iconURL, icon); |
| 142 assert_equals(c.idName, 'username'); | 168 assert_equals(c.idName, 'username'); |
| 143 assert_equals(c.passwordName, 'password'); | 169 assert_equals(c.passwordName, 'password'); |
| 144 assert_equals(c.additionalData, null); | 170 assert_equals(c.additionalData, null); |
| 145 | 171 |
| 146 this.done(); | 172 this.done(); |
| 147 } | 173 } |
| 148 | 174 |
| 149 var t = async_test("Verify that the mock returns the values we give it."); | 175 var t = async_test("Verify that the mock returns the values we give it."); |
| 150 t.step(function() { | 176 t.step(function() { |
| 151 if (window.testRunner) | 177 if (window.testRunner) |
| 152 testRunner.setMockCredentialManagerResponse(id, name, icon, password ); | 178 testRunner.setMockCredentialManagerResponse(id, name, icon, password ); |
| 153 navigator.credentials.get({ | 179 navigator.credentials.get({ |
| 154 password: true | 180 password: true |
| 155 }).then( | 181 }).then( |
| 156 t.step_func(stubResolverChecker.bind(t)), | 182 t.step_func(stubResolverChecker.bind(t)), |
| 157 t.step_func(stubRejectionChecker.bind(t))); | 183 t.step_func(stubRejectionChecker.bind(t))); |
| 158 }); | 184 }); |
| 159 }()); | 185 }()); |
| 160 </script> | 186 </script> |
| OLD | NEW |