[CredentialManagement] Incorporate IDL updates from latest spec
[WebKit-https.git] / LayoutTests / credentials / idlharness.html
index 4acb003..91e2d73 100644 (file)
@@ -12,33 +12,60 @@ interface Window {};
 </script>
 
 <script type="text/plain" class="idl">
-// 3.1.1 Credential
+// 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;
 };
 
-[SecureContext] interface Credential {
-  readonly attribute USVString id;
-  readonly attribute DOMString type;
+dictionary CredentialRequestOptions {
+  CredentialMediationRequirement medation = "optional";
+  boolean password = false;
+  FederatedCredentialRequestOptions? federated;
 };
 
-// No Transferable at this moment
-// Credential implements Transferable;
-
-dictionary SiteBoundCredentialData : CredentialData {
-  USVString name;
-  USVString iconURL;
+enum CredentialMediationRequirement {
+  "silent",
+  "optional",
+  "required"
 };
 
-[SecureContext] interface SiteBoundCredential : Credential {
-  readonly attribute USVString name;
-  readonly attribute USVString iconURL;
+// 2.4 CredentialCreationOptions
+
+dictionary CredentialCreationOptions {
+  PasswordCredentialInit? password;
+  FederatedCredentialInit? federated;
 };
 
-// 3.1.3 PasswordCredential
+// 3.2 PasswordCredential
 
-dictionary PasswordCredentialData : SiteBoundCredentialData {
+dictionary PasswordCredentialData : CredentialData {
+  USVString name;
+  USVString iconURL;
   required USVString password;
 };
 
@@ -48,11 +75,34 @@ typedef (FormData or URLSearchParams) CredentialBodyType;
  Constructor(HTMLFormElement form),
  Exposed=Window,
  SecureContext]
-interface PasswordCredential : SiteBoundCredential {
-  attribute USVString idName;
-  attribute USVString passwordName;
+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;
 
-  attribute CredentialBodyType? additionalData;
+dictionary FederatedCredentialRequestOptions {
+    sequence<USVString> providers;
+    sequence<DOMString> protocols;
 };
 
 </script>
@@ -70,7 +120,9 @@ var idl_array = new IdlArray();
 idl_array.add_untested_idls(untested);
 idl_array.add_idls(idl);
 idl_array.add_objects({
-  PasswordCredential: ['new PasswordCredential({ password: "12345", id: "12345" })'],
+  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>