| <!DOCTYPE html><!-- webkit-test-runner [ enableCredentialManagement=true ] --> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="../resources/WebIDLParser.js"></script> |
| <script src="../resources/idlharness.js"></script> |
| |
| <h1>idlharness test</h1> |
| <p>This test validates the WebIDL included in the Credential Management API.</p> |
| |
| <script type="text/plain" class="untested-idl"> |
| interface Window {}; |
| </script> |
| |
| <script type="text/plain" class="idl"> |
| // 2.2 Credential |
| |
| [SecureContext, |
| Exposed=Window] |
| interface Credential { |
| readonly attribute USVString id; |
| readonly attribute DOMString type; |
| }; |
| |
| [NoInterfaceObject] |
| interface CredentialUserData { |
| readonly attribute USVString name; |
| readonly attribute USVString iconURL; |
| }; |
| |
| // 2.3 navigator.credentials |
| |
| [Exposed=Window, |
| SecureContext] |
| interface CredentialsContainer { |
| Promise<Credential?> get(optional CredentialRequestOptions options); |
| Promise<Credential> store(Credential credential); |
| Promise<Credential?> create(optional CredentialCreationOptions options); |
| Promise<void> preventSilentAccess(); |
| }; |
| |
| dictionary CredentialData { |
| required USVString id; |
| }; |
| |
| dictionary CredentialRequestOptions { |
| CredentialMediationRequirement medation = "optional"; |
| boolean password = false; |
| FederatedCredentialRequestOptions? federated; |
| }; |
| |
| enum CredentialMediationRequirement { |
| "silent", |
| "optional", |
| "required" |
| }; |
| |
| // 2.4 CredentialCreationOptions |
| |
| dictionary CredentialCreationOptions { |
| PasswordCredentialInit? password; |
| FederatedCredentialInit? federated; |
| }; |
| |
| // 3.2 PasswordCredential |
| |
| dictionary PasswordCredentialData : CredentialData { |
| USVString name; |
| USVString iconURL; |
| required USVString password; |
| }; |
| |
| typedef (FormData or URLSearchParams) CredentialBodyType; |
| |
| [Constructor(PasswordCredentialData data), |
| Constructor(HTMLFormElement form), |
| Exposed=Window, |
| SecureContext] |
| interface PasswordCredential : Credential { |
| readonly attribute USVString password; |
| }; |
| PasswordCredential implements CredentialUserData; |
| |
| typedef (PasswordCredentialData or HTMLFormElement) PasswordCredentialInit; |
| |
| // 4.1 FederatedCredential |
| |
| dictionary FederatedCredentialInit : CredentialData { |
| USVString name; |
| USVString iconURL; |
| required USVString provider; |
| DOMString protocol; |
| }; |
| |
| [Constructor(FederatedCredentialInit init), |
| Exposed=Window, |
| SecureContext] |
| interface FederatedCredential : Credential { |
| readonly attribute USVString provider; |
| readonly attribute DOMString? protocol; |
| }; |
| FederatedCredential implements CredentialUserData; |
| |
| dictionary FederatedCredentialRequestOptions { |
| sequence<USVString> providers; |
| sequence<DOMString> protocols; |
| }; |
| |
| </script> |
| |
| <script> |
| function select(selector) { |
| return [].slice.call(document.querySelectorAll(selector)) |
| .map(function(e) { return e.textContent; }) |
| .join('\n\n'); |
| } |
| |
| var idl = select('.idl') |
| var untested = select('.untested-idl'); |
| var idl_array = new IdlArray(); |
| idl_array.add_untested_idls(untested); |
| idl_array.add_idls(idl); |
| idl_array.add_objects({ |
| CredentialsContainer: ['navigator.credentials'], |
| PasswordCredential: ['new PasswordCredential({ name: "name", iconURL: "https://example.com", password: "12345", id: "12345" })'], |
| FederatedCredential: ['new FederatedCredential({ name: "name", iconURL: "https://example.com", provider: "https://example.com", protocol: "protocol", id: "12345" })'], |
| }); |
| idl_array.test(); |
| </script> |