Update Credential Management API for WebAuthentication
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Jan 2018 20:28:31 +0000 (20:28 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Jan 2018 20:28:31 +0000 (20:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181082
<rdar://problem/36055239>

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* web-platform-tests/credential-management/credentialscontainer-create-basics.https-expected.txt:
* web-platform-tests/credential-management/idl.https-expected.txt:

Source/WebCore:

Part 2/2

This patch implements Core API from Credential Management API: https://www.w3.org/TR/credential-management-1/#core.
which is required by WebAuthN. It also sets the CredentialManagement runtime flag to enable testing. Note that it
introduces a dummy PublicKeyCredential interface for testing functionalities of the Credential interface, which
cannot be instantiated.

Tests: http/wpt/credential-management/credentialscontainer-create-basics.https.html
       http/wpt/credential-management/credentialscontainer-get-basics.https.html
       http/wpt/credential-management/credentialscontainer-preventSilentAccess-basics.https.html
       http/wpt/credential-management/idl.https.html

* CMakeLists.txt:
* DerivedSources.make:
* Modules/credentialmanagement/BasicCredential.cpp:
(WebCore::BasicCredential::BasicCredential):
(WebCore::BasicCredential::type const):
* Modules/credentialmanagement/BasicCredential.h:
(WebCore::BasicCredential::discovery const):
* Modules/credentialmanagement/BasicCredential.idl:
* Modules/credentialmanagement/CredentialCreationOptions.h:
* Modules/credentialmanagement/CredentialCreationOptions.idl:
* Modules/credentialmanagement/CredentialRequestOptions.h:
* Modules/credentialmanagement/CredentialRequestOptions.idl:
* Modules/credentialmanagement/CredentialsContainer.cpp:
(WebCore::CredentialsContainer::CredentialsContainer):
(WebCore::CredentialsContainer::isSameOriginWithItsAncestors):
(WebCore::CredentialsContainer::dispatchTask):
(WebCore::CredentialsContainer::get):
(WebCore::CredentialsContainer::store):
(WebCore::CredentialsContainer::isCreate):
(WebCore::CredentialsContainer::preventSilentAccess):
* Modules/credentialmanagement/CredentialsContainer.h:
(WebCore::CredentialsContainer::create):
(WebCore::CredentialsContainer::CredentialsContainer): Deleted.
* Modules/credentialmanagement/CredentialsContainer.idl:
* Modules/credentialmanagement/NavigatorCredentials.cpp:
(WebCore::NavigatorCredentials::credentials):
* Modules/credentialmanagement/NavigatorCredentials.h:
* Modules/credentialmanagement/NavigatorCredentials.idl:
* Modules/webauthn/PublicKeyCredential.cpp: Copied from Source/WebCore/Modules/credentialmanagement/BasicCredential.cpp.
(WebCore::PublicKeyCredential::PublicKeyCredential):
(WebCore::PublicKeyCredential::collectFromCredentialStore):
(WebCore::PublicKeyCredential::discoverFromExternalSource):
(WebCore::PublicKeyCredential::store):
(WebCore::PublicKeyCredential::create):
* Modules/webauthn/PublicKeyCredential.h: Copied from Source/WebCore/Modules/credentialmanagement/BasicCredential.cpp.
* Modules/webauthn/PublicKeyCredential.idl: Copied from Source/WebCore/Modules/credentialmanagement/BasicCredential.idl.
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/WebCoreBuiltinNames.h:
* page/RuntimeEnabledFeatures.h:

Tools:

Enable Credential Management API for testing.

* DumpRenderTree/TestOptions.h:
* WebKitTestRunner/TestOptions.h:

LayoutTests:

This patch moves original tests for Credential Management API to http/wpt/ to better integrate
with web-platform-tests infrastructure. Hopefully this will help us later on contribute tests
back to W3C.

* credentials/idlharness-expected.txt: Removed.
* credentials/idlharness.html: Removed.
* fast/dom/navigator-detached-no-crash-expected.txt:
* http/wpt/credential-management/credentialscontainer-create-basics.https-expected.txt: Added.
* http/wpt/credential-management/credentialscontainer-create-basics.https.html: Added.
* http/wpt/credential-management/credentialscontainer-get-basics.https-expected.txt: Added.
* http/wpt/credential-management/credentialscontainer-get-basics.https.html: Added.
* http/wpt/credential-management/credentialscontainer-preventSilentAccess-basics.https-expected.txt: Added.
* http/wpt/credential-management/credentialscontainer-preventSilentAccess-basics.https.html: Added.
* http/wpt/credential-management/idl.https-expected.txt: Added.
* http/wpt/credential-management/idl.https.html: Added.
* platform/gtk/TestExpectations:
* platform/gtk/fast/dom/navigator-detached-no-crash-expected.txt:
* platform/mac-elcapitan-wk2/fast/dom/navigator-detached-no-crash-expected.txt:
* platform/mac-wk1/fast/dom/navigator-detached-no-crash-expected.txt:
* platform/win/TestExpectations:
* platform/win/fast/dom/navigator-detached-no-crash-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226332 268f45cc-cd09-0410-ab3c-d52691b4dbfc

46 files changed:
LayoutTests/ChangeLog
LayoutTests/credentials/idlharness-expected.txt [deleted file]
LayoutTests/credentials/idlharness.html [deleted file]
LayoutTests/fast/dom/navigator-detached-no-crash-expected.txt
LayoutTests/http/wpt/credential-management/credentialscontainer-create-basics.https-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/credential-management/credentialscontainer-create-basics.https.html [new file with mode: 0644]
LayoutTests/http/wpt/credential-management/credentialscontainer-get-basics.https-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/credential-management/credentialscontainer-get-basics.https.html [new file with mode: 0644]
LayoutTests/http/wpt/credential-management/credentialscontainer-preventSilentAccess-basics.https-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/credential-management/credentialscontainer-preventSilentAccess-basics.https.html [new file with mode: 0644]
LayoutTests/http/wpt/credential-management/idl.https-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/credential-management/idl.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/credential-management/credentialscontainer-create-basics.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/credential-management/idl.https-expected.txt
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/gtk/fast/dom/navigator-detached-no-crash-expected.txt
LayoutTests/platform/mac-elcapitan-wk2/fast/dom/navigator-detached-no-crash-expected.txt
LayoutTests/platform/mac-wk1/fast/dom/navigator-detached-no-crash-expected.txt
LayoutTests/platform/win/TestExpectations
LayoutTests/platform/win/fast/dom/navigator-detached-no-crash-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/credentialmanagement/BasicCredential.cpp
Source/WebCore/Modules/credentialmanagement/BasicCredential.h
Source/WebCore/Modules/credentialmanagement/BasicCredential.idl
Source/WebCore/Modules/credentialmanagement/CredentialCreationOptions.h
Source/WebCore/Modules/credentialmanagement/CredentialCreationOptions.idl
Source/WebCore/Modules/credentialmanagement/CredentialRequestOptions.h
Source/WebCore/Modules/credentialmanagement/CredentialRequestOptions.idl
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.idl
Source/WebCore/Modules/credentialmanagement/NavigatorCredentials.cpp
Source/WebCore/Modules/credentialmanagement/NavigatorCredentials.h
Source/WebCore/Modules/credentialmanagement/NavigatorCredentials.idl
Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp [new file with mode: 0644]
Source/WebCore/Modules/webauthn/PublicKeyCredential.h [new file with mode: 0644]
Source/WebCore/Modules/webauthn/PublicKeyCredential.idl [new file with mode: 0644]
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Tools/ChangeLog
Tools/DumpRenderTree/TestOptions.h
Tools/WebKitTestRunner/TestOptions.h

index 3a7d6e1..d8065d3 100644 (file)
@@ -1,3 +1,33 @@
+2018-01-02  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Update Credential Management API for WebAuthentication
+        https://bugs.webkit.org/show_bug.cgi?id=181082
+        <rdar://problem/36055239>
+
+        Reviewed by Brent Fulgham.
+
+        This patch moves original tests for Credential Management API to http/wpt/ to better integrate
+        with web-platform-tests infrastructure. Hopefully this will help us later on contribute tests
+        back to W3C.
+
+        * credentials/idlharness-expected.txt: Removed.
+        * credentials/idlharness.html: Removed.
+        * fast/dom/navigator-detached-no-crash-expected.txt:
+        * http/wpt/credential-management/credentialscontainer-create-basics.https-expected.txt: Added.
+        * http/wpt/credential-management/credentialscontainer-create-basics.https.html: Added.
+        * http/wpt/credential-management/credentialscontainer-get-basics.https-expected.txt: Added.
+        * http/wpt/credential-management/credentialscontainer-get-basics.https.html: Added.
+        * http/wpt/credential-management/credentialscontainer-preventSilentAccess-basics.https-expected.txt: Added.
+        * http/wpt/credential-management/credentialscontainer-preventSilentAccess-basics.https.html: Added.
+        * http/wpt/credential-management/idl.https-expected.txt: Added.
+        * http/wpt/credential-management/idl.https.html: Added.
+        * platform/gtk/TestExpectations:
+        * platform/gtk/fast/dom/navigator-detached-no-crash-expected.txt:
+        * platform/mac-elcapitan-wk2/fast/dom/navigator-detached-no-crash-expected.txt:
+        * platform/mac-wk1/fast/dom/navigator-detached-no-crash-expected.txt:
+        * platform/win/TestExpectations:
+        * platform/win/fast/dom/navigator-detached-no-crash-expected.txt:
+
 2018-01-02  Ms2ger  <Ms2ger@igalia.com>
 
         Remove obsolete expectations for updated imported/w3c/web-platform-tests/html/browsers/windows/browsing-context.html.
diff --git a/LayoutTests/credentials/idlharness-expected.txt b/LayoutTests/credentials/idlharness-expected.txt
deleted file mode 100644 (file)
index ea66736..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-idlharness test
-
-This test validates the WebIDL included in the Credential Management API.
-
-
-PASS Credential interface: existence and properties of interface object 
-PASS Credential interface object length 
-PASS Credential interface object name 
-PASS Credential interface: existence and properties of interface prototype object 
-PASS Credential interface: existence and properties of interface prototype object's "constructor" property 
-PASS Credential interface: attribute id 
-PASS Credential interface: attribute type 
-PASS CredentialsContainer interface: existence and properties of interface object 
-PASS CredentialsContainer interface object length 
-PASS CredentialsContainer interface object name 
-PASS CredentialsContainer interface: existence and properties of interface prototype object 
-PASS CredentialsContainer interface: existence and properties of interface prototype object's "constructor" property 
-PASS CredentialsContainer interface: operation get(CredentialRequestOptions) 
-PASS CredentialsContainer interface: operation store(Credential) 
-PASS CredentialsContainer interface: operation create(CredentialCreationOptions) 
-PASS CredentialsContainer interface: operation preventSilentAccess() 
-PASS CredentialsContainer must be primary interface of navigator.credentials 
-PASS Stringification of navigator.credentials 
-PASS CredentialsContainer interface: navigator.credentials must inherit property "get" with the proper type (0) 
-PASS CredentialsContainer interface: calling get(CredentialRequestOptions) on navigator.credentials with too few arguments must throw TypeError 
-PASS CredentialsContainer interface: navigator.credentials must inherit property "store" with the proper type (1) 
-PASS CredentialsContainer interface: calling store(Credential) on navigator.credentials with too few arguments must throw TypeError 
-PASS CredentialsContainer interface: navigator.credentials must inherit property "create" with the proper type (2) 
-PASS CredentialsContainer interface: calling create(CredentialCreationOptions) on navigator.credentials with too few arguments must throw TypeError 
-PASS CredentialsContainer interface: navigator.credentials must inherit property "preventSilentAccess" with the proper type (3) 
-FAIL PasswordCredential interface: existence and properties of interface object assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
-FAIL PasswordCredential interface object length assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
-FAIL PasswordCredential interface object name assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
-FAIL PasswordCredential interface: existence and properties of interface prototype object assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
-FAIL PasswordCredential interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
-FAIL PasswordCredential interface: attribute password assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
-FAIL PasswordCredential interface: attribute name assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
-FAIL PasswordCredential interface: attribute iconURL assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
-FAIL PasswordCredential must be primary interface of new PasswordCredential({ name: "name", iconURL: "https://example.com", password: "12345", id: "12345" }) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: PasswordCredential"
-FAIL Stringification of new PasswordCredential({ name: "name", iconURL: "https://example.com", password: "12345", id: "12345" }) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: PasswordCredential"
-FAIL PasswordCredential interface: new PasswordCredential({ name: "name", iconURL: "https://example.com", password: "12345", id: "12345" }) must inherit property "password" with the proper type (0) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: PasswordCredential"
-FAIL PasswordCredential interface: new PasswordCredential({ name: "name", iconURL: "https://example.com", password: "12345", id: "12345" }) must inherit property "name" with the proper type (1) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: PasswordCredential"
-FAIL PasswordCredential interface: new PasswordCredential({ name: "name", iconURL: "https://example.com", password: "12345", id: "12345" }) must inherit property "iconURL" with the proper type (2) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: PasswordCredential"
-FAIL Credential interface: new PasswordCredential({ name: "name", iconURL: "https://example.com", password: "12345", id: "12345" }) must inherit property "id" with the proper type (0) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: PasswordCredential"
-FAIL Credential interface: new PasswordCredential({ name: "name", iconURL: "https://example.com", password: "12345", id: "12345" }) must inherit property "type" with the proper type (1) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: PasswordCredential"
-FAIL FederatedCredential interface: existence and properties of interface object assert_own_property: self does not have own property "FederatedCredential" expected property "FederatedCredential" missing
-FAIL FederatedCredential interface object length assert_own_property: self does not have own property "FederatedCredential" expected property "FederatedCredential" missing
-FAIL FederatedCredential interface object name assert_own_property: self does not have own property "FederatedCredential" expected property "FederatedCredential" missing
-FAIL FederatedCredential interface: existence and properties of interface prototype object assert_own_property: self does not have own property "FederatedCredential" expected property "FederatedCredential" missing
-FAIL FederatedCredential interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "FederatedCredential" expected property "FederatedCredential" missing
-FAIL FederatedCredential interface: attribute provider assert_own_property: self does not have own property "FederatedCredential" expected property "FederatedCredential" missing
-FAIL FederatedCredential interface: attribute protocol assert_own_property: self does not have own property "FederatedCredential" expected property "FederatedCredential" missing
-FAIL FederatedCredential interface: attribute name assert_own_property: self does not have own property "FederatedCredential" expected property "FederatedCredential" missing
-FAIL FederatedCredential interface: attribute iconURL assert_own_property: self does not have own property "FederatedCredential" expected property "FederatedCredential" missing
-FAIL FederatedCredential must be primary interface of new FederatedCredential({ name: "name", iconURL: "https://example.com", provider: "https://example.com", protocol: "protocol", id: "12345" }) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: FederatedCredential"
-FAIL Stringification of new FederatedCredential({ name: "name", iconURL: "https://example.com", provider: "https://example.com", protocol: "protocol", id: "12345" }) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: FederatedCredential"
-FAIL FederatedCredential interface: new FederatedCredential({ name: "name", iconURL: "https://example.com", provider: "https://example.com", protocol: "protocol", id: "12345" }) must inherit property "provider" with the proper type (0) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: FederatedCredential"
-FAIL FederatedCredential interface: new FederatedCredential({ name: "name", iconURL: "https://example.com", provider: "https://example.com", protocol: "protocol", id: "12345" }) must inherit property "protocol" with the proper type (1) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: FederatedCredential"
-FAIL FederatedCredential interface: new FederatedCredential({ name: "name", iconURL: "https://example.com", provider: "https://example.com", protocol: "protocol", id: "12345" }) must inherit property "name" with the proper type (2) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: FederatedCredential"
-FAIL FederatedCredential interface: new FederatedCredential({ name: "name", iconURL: "https://example.com", provider: "https://example.com", protocol: "protocol", id: "12345" }) must inherit property "iconURL" with the proper type (3) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: FederatedCredential"
-FAIL Credential interface: new FederatedCredential({ name: "name", iconURL: "https://example.com", provider: "https://example.com", protocol: "protocol", id: "12345" }) must inherit property "id" with the proper type (0) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: FederatedCredential"
-FAIL Credential interface: new FederatedCredential({ name: "name", iconURL: "https://example.com", provider: "https://example.com", protocol: "protocol", id: "12345" }) must inherit property "type" with the proper type (1) assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: FederatedCredential"
-
diff --git a/LayoutTests/credentials/idlharness.html b/LayoutTests/credentials/idlharness.html
deleted file mode 100644 (file)
index 91e2d73..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-<!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>
index 0e933ce..333ec96 100644 (file)
@@ -5,6 +5,7 @@ navigator.appCodeName is OK
 navigator.appName is OK
 navigator.appVersion is OK
 navigator.cookieEnabled is OK
+navigator.credentials is OK
 navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
@@ -27,6 +28,7 @@ navigator.appCodeName is OK
 navigator.appName is OK
 navigator.appVersion is OK
 navigator.cookieEnabled is OK
+navigator.credentials is OK
 navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
diff --git a/LayoutTests/http/wpt/credential-management/credentialscontainer-create-basics.https-expected.txt b/LayoutTests/http/wpt/credential-management/credentialscontainer-create-basics.https-expected.txt
new file mode 100644 (file)
index 0000000..3df2cb3
--- /dev/null
@@ -0,0 +1,8 @@
+
+PASS navigator.credentials.create() with no argument. 
+PASS navigator.credentials.create() with empty argument. 
+FAIL navigator.credentials.create() with bogus publicKey data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS navigator.credentials.create() with bogus data 
+PASS navigator.credentials.create() with abort signal set 
+PASS navigator.credentials.create() with faked data 
+
diff --git a/LayoutTests/http/wpt/credential-management/credentialscontainer-create-basics.https.html b/LayoutTests/http/wpt/credential-management/credentialscontainer-create-basics.https.html
new file mode 100644 (file)
index 0000000..6c86ae5
--- /dev/null
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<title>Credential Management API: create() basics.</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+promise_test(function(t) {
+    return promise_rejects(t, "NotSupportedError",
+            navigator.credentials.create());
+}, "navigator.credentials.create() with no argument.");
+
+promise_test(function(t) {
+    return promise_rejects(t, "NotSupportedError",
+            navigator.credentials.create({ }));
+}, "navigator.credentials.create() with empty argument.");
+
+promise_test(function(t) {
+    return promise_rejects(t, new TypeError(),
+            navigator.credentials.create({publicKey: "bogus publicKey data"}));
+}, "navigator.credentials.create() with bogus publicKey data");
+
+promise_test(function(t) {
+    return promise_rejects(t, "NotSupportedError",
+            navigator.credentials.create({bogus_key: "bogus data"}));
+}, "navigator.credentials.create() with bogus data");
+
+promise_test(function(t) {
+    var controller = new AbortController();
+    var options = { signal: controller.signal };
+
+    controller.abort();
+    return promise_rejects(t, "AbortError",
+        navigator.credentials.create(options));
+}, "navigator.credentials.create() with abort signal set");
+
+promise_test(function(t) {
+    return promise_rejects(t, "NotSupportedError",
+        navigator.credentials.create({publicKey: true}));
+}, "navigator.credentials.create() with faked data");
+</script>
diff --git a/LayoutTests/http/wpt/credential-management/credentialscontainer-get-basics.https-expected.txt b/LayoutTests/http/wpt/credential-management/credentialscontainer-get-basics.https-expected.txt
new file mode 100644 (file)
index 0000000..8cc1684
--- /dev/null
@@ -0,0 +1,8 @@
+
+PASS navigator.credentials.get() with no argument. 
+PASS navigator.credentials.get() with empty argument. 
+FAIL navigator.credentials.get() with bogus publicKey data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS navigator.credentials.get() with bogus data 
+PASS navigator.credentials.get() with abort signal set 
+PASS navigator.credentials.get() with faked data 
+
diff --git a/LayoutTests/http/wpt/credential-management/credentialscontainer-get-basics.https.html b/LayoutTests/http/wpt/credential-management/credentialscontainer-get-basics.https.html
new file mode 100644 (file)
index 0000000..ca6d634
--- /dev/null
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<title>Credential Management API: get() basics.</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+promise_test(function(t) {
+    return promise_rejects(t, "NotSupportedError",
+            navigator.credentials.get());
+}, "navigator.credentials.get() with no argument.");
+
+promise_test(function(t) {
+    return promise_rejects(t, "NotSupportedError",
+            navigator.credentials.get({ }));
+}, "navigator.credentials.get() with empty argument.");
+
+promise_test(function(t) {
+    return promise_rejects(t, new TypeError(),
+            navigator.credentials.get({publicKey: "bogus publicKey data"}));
+}, "navigator.credentials.get() with bogus publicKey data");
+
+promise_test(function(t) {
+    return promise_rejects(t, "NotSupportedError",
+            navigator.credentials.get({bogus_key: "bogus data"}));
+}, "navigator.credentials.get() with bogus data");
+
+promise_test(function(t) {
+    var controller = new AbortController();
+    var options = { signal: controller.signal };
+
+    controller.abort();
+    return promise_rejects(t, "AbortError",
+        navigator.credentials.get(options));
+}, "navigator.credentials.get() with abort signal set");
+
+promise_test(function(t) {
+    return promise_rejects(t, "NotSupportedError",
+        navigator.credentials.get({publicKey: true}));
+}, "navigator.credentials.get() with faked data");
+</script>
diff --git a/LayoutTests/http/wpt/credential-management/credentialscontainer-preventSilentAccess-basics.https-expected.txt b/LayoutTests/http/wpt/credential-management/credentialscontainer-preventSilentAccess-basics.https-expected.txt
new file mode 100644 (file)
index 0000000..f0e9a91
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS navigator.credentials.preventSilentAccess(). 
+
diff --git a/LayoutTests/http/wpt/credential-management/credentialscontainer-preventSilentAccess-basics.https.html b/LayoutTests/http/wpt/credential-management/credentialscontainer-preventSilentAccess-basics.https.html
new file mode 100644 (file)
index 0000000..030d9d1
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<title>Credential Management API: preventSilentAccess() basics.</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+promise_test(function(t) {
+    return promise_rejects(t, "NotSupportedError",
+            navigator.credentials.preventSilentAccess());
+}, "navigator.credentials.preventSilentAccess().");
+</script>
diff --git a/LayoutTests/http/wpt/credential-management/idl.https-expected.txt b/LayoutTests/http/wpt/credential-management/idl.https-expected.txt
new file mode 100644 (file)
index 0000000..7c06a52
--- /dev/null
@@ -0,0 +1,20 @@
+
+PASS CredentialsContainer interface: existence and properties of interface object 
+PASS CredentialsContainer interface object length 
+PASS CredentialsContainer interface object name 
+PASS CredentialsContainer interface: existence and properties of interface prototype object 
+PASS CredentialsContainer interface: existence and properties of interface prototype object's "constructor" property 
+PASS CredentialsContainer interface: operation get(CredentialRequestOptions) 
+PASS CredentialsContainer interface: operation store(Credential) 
+PASS CredentialsContainer interface: operation create(CredentialCreationOptions) 
+PASS CredentialsContainer interface: operation preventSilentAccess() 
+PASS CredentialsContainer must be primary interface of navigator.credentials 
+PASS Stringification of navigator.credentials 
+PASS CredentialsContainer interface: navigator.credentials must inherit property "get(CredentialRequestOptions)" with the proper type 
+PASS CredentialsContainer interface: calling get(CredentialRequestOptions) on navigator.credentials with too few arguments must throw TypeError 
+PASS CredentialsContainer interface: navigator.credentials must inherit property "store(Credential)" with the proper type 
+PASS CredentialsContainer interface: calling store(Credential) on navigator.credentials with too few arguments must throw TypeError 
+PASS CredentialsContainer interface: navigator.credentials must inherit property "create(CredentialCreationOptions)" with the proper type 
+PASS CredentialsContainer interface: calling create(CredentialCreationOptions) on navigator.credentials with too few arguments must throw TypeError 
+PASS CredentialsContainer interface: navigator.credentials must inherit property "preventSilentAccess()" with the proper type 
+
diff --git a/LayoutTests/http/wpt/credential-management/idl.https.html b/LayoutTests/http/wpt/credential-management/idl.https.html
new file mode 100644 (file)
index 0000000..093c0f1
--- /dev/null
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=/resources/WebIDLParser.js></script>
+<script src=/resources/idlharness.js></script>
+<script type="text/plain" id="untested">
+    dictionary CredentialData {
+        USVString id;
+    };
+
+    [Exposed=Window, SecureContext]
+    interface Credential {
+        readonly attribute USVString id;
+        readonly attribute DOMString type;
+    };
+
+    dictionary CredentialCreationOptions {
+        AbortSignal signal;
+    };
+
+    enum CredentialMediationRequirement {
+        "silent",
+        "optional",
+        "required"
+    };
+
+    dictionary CredentialRequestOptions {
+        CredentialMediationRequirement mediation = "optional";
+        AbortSignal signal;
+    };
+</script>
+<script type="text/plain" id="tested">
+    [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();
+    };
+</script>
+<script>
+    "use strict";
+    var idl_array = new IdlArray();
+    idl_array.add_untested_idls(document.querySelector('#untested').textContent);
+    idl_array.add_idls(document.querySelector('#tested').textContent);
+    idl_array.add_objects({
+        CredentialsContainer: ['navigator.credentials'],
+    });
+    idl_array.test();
+</script>
index 3ec3588..237e131 100644 (file)
@@ -1,3 +1,14 @@
+2018-01-02  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Update Credential Management API for WebAuthentication
+        https://bugs.webkit.org/show_bug.cgi?id=181082
+        <rdar://problem/36055239>
+
+        Reviewed by Brent Fulgham.
+
+        * web-platform-tests/credential-management/credentialscontainer-create-basics.https-expected.txt:
+        * web-platform-tests/credential-management/idl.https-expected.txt:
+
 2018-01-02  Ms2ger  <Ms2ger@igalia.com>
 
         Update imported/w3c/web-platform-tests/html/browsers/windows/browsing-context.html from upstream wpt.
index ba45fd7..cdc9d62 100644 (file)
@@ -1,17 +1,17 @@
 
-FAIL navigator.credentials.create() with no argument. undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with empty argument. undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with valid PasswordCredentialData undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with valid HTMLFormElement undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with bogus password data undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with valid FederatedCredentialData undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with bogus federated data undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with bogus publicKey data undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() returns PublicKeyCredential undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with both PasswordCredentialData and FederatedCredentialData undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with bogus password and federated data undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with bogus federated and publicKey data undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with bogus password and publicKey data undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with bogus password, federated, and publicKey data undefined is not an object (evaluating 'navigator.credentials.create')
-FAIL navigator.credentials.create() with bogus data undefined is not an object (evaluating 'navigator.credentials.create')
+PASS navigator.credentials.create() with no argument. 
+PASS navigator.credentials.create() with empty argument. 
+FAIL navigator.credentials.create() with valid PasswordCredentialData promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
+FAIL navigator.credentials.create() with valid HTMLFormElement promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
+FAIL navigator.credentials.create() with bogus password data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+FAIL navigator.credentials.create() with valid FederatedCredentialData promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
+FAIL navigator.credentials.create() with bogus federated data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+FAIL navigator.credentials.create() with bogus publicKey data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+FAIL navigator.credentials.create() returns PublicKeyCredential promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
+PASS navigator.credentials.create() with both PasswordCredentialData and FederatedCredentialData 
+FAIL navigator.credentials.create() with bogus password and federated data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+FAIL navigator.credentials.create() with bogus federated and publicKey data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+FAIL navigator.credentials.create() with bogus password and publicKey data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+FAIL navigator.credentials.create() with bogus password, federated, and publicKey data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS navigator.credentials.create() with bogus data 
 
index 903cd8e..2020a90 100644 (file)
@@ -1,22 +1,22 @@
 
-FAIL CredentialsContainer interface: existence and properties of interface object assert_own_property: self does not have own property "CredentialsContainer" expected property "CredentialsContainer" missing
-FAIL CredentialsContainer interface object length assert_own_property: self does not have own property "CredentialsContainer" expected property "CredentialsContainer" missing
-FAIL CredentialsContainer interface object name assert_own_property: self does not have own property "CredentialsContainer" expected property "CredentialsContainer" missing
-FAIL CredentialsContainer interface: existence and properties of interface prototype object assert_own_property: self does not have own property "CredentialsContainer" expected property "CredentialsContainer" missing
-FAIL CredentialsContainer interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "CredentialsContainer" expected property "CredentialsContainer" missing
-FAIL CredentialsContainer interface: operation get(CredentialRequestOptions) assert_own_property: self does not have own property "CredentialsContainer" expected property "CredentialsContainer" missing
-FAIL CredentialsContainer interface: operation store(Credential) assert_own_property: self does not have own property "CredentialsContainer" expected property "CredentialsContainer" missing
-FAIL CredentialsContainer interface: operation create(CredentialCreationOptions) assert_own_property: self does not have own property "CredentialsContainer" expected property "CredentialsContainer" missing
-FAIL CredentialsContainer interface: operation preventSilentAccess() assert_own_property: self does not have own property "CredentialsContainer" expected property "CredentialsContainer" missing
-FAIL CredentialsContainer must be primary interface of navigator.credentials assert_equals: wrong typeof object expected "object" but got "undefined"
-FAIL Stringification of navigator.credentials assert_equals: wrong typeof object expected "object" but got "undefined"
-FAIL CredentialsContainer interface: navigator.credentials must inherit property "get(CredentialRequestOptions)" with the proper type assert_equals: wrong typeof object expected "object" but got "undefined"
-FAIL CredentialsContainer interface: calling get(CredentialRequestOptions) on navigator.credentials with too few arguments must throw TypeError assert_equals: wrong typeof object expected "object" but got "undefined"
-FAIL CredentialsContainer interface: navigator.credentials must inherit property "store(Credential)" with the proper type assert_equals: wrong typeof object expected "object" but got "undefined"
-FAIL CredentialsContainer interface: calling store(Credential) on navigator.credentials with too few arguments must throw TypeError assert_equals: wrong typeof object expected "object" but got "undefined"
-FAIL CredentialsContainer interface: navigator.credentials must inherit property "create(CredentialCreationOptions)" with the proper type assert_equals: wrong typeof object expected "object" but got "undefined"
-FAIL CredentialsContainer interface: calling create(CredentialCreationOptions) on navigator.credentials with too few arguments must throw TypeError assert_equals: wrong typeof object expected "object" but got "undefined"
-FAIL CredentialsContainer interface: navigator.credentials must inherit property "preventSilentAccess()" with the proper type assert_equals: wrong typeof object expected "object" but got "undefined"
+PASS CredentialsContainer interface: existence and properties of interface object 
+PASS CredentialsContainer interface object length 
+PASS CredentialsContainer interface object name 
+PASS CredentialsContainer interface: existence and properties of interface prototype object 
+PASS CredentialsContainer interface: existence and properties of interface prototype object's "constructor" property 
+PASS CredentialsContainer interface: operation get(CredentialRequestOptions) 
+PASS CredentialsContainer interface: operation store(Credential) 
+PASS CredentialsContainer interface: operation create(CredentialCreationOptions) 
+PASS CredentialsContainer interface: operation preventSilentAccess() 
+PASS CredentialsContainer must be primary interface of navigator.credentials 
+PASS Stringification of navigator.credentials 
+PASS CredentialsContainer interface: navigator.credentials must inherit property "get(CredentialRequestOptions)" with the proper type 
+PASS CredentialsContainer interface: calling get(CredentialRequestOptions) on navigator.credentials with too few arguments must throw TypeError 
+PASS CredentialsContainer interface: navigator.credentials must inherit property "store(Credential)" with the proper type 
+PASS CredentialsContainer interface: calling store(Credential) on navigator.credentials with too few arguments must throw TypeError 
+PASS CredentialsContainer interface: navigator.credentials must inherit property "create(CredentialCreationOptions)" with the proper type 
+PASS CredentialsContainer interface: calling create(CredentialCreationOptions) on navigator.credentials with too few arguments must throw TypeError 
+PASS CredentialsContainer interface: navigator.credentials must inherit property "preventSilentAccess()" with the proper type 
 FAIL PasswordCredential interface: existence and properties of interface object assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
 FAIL PasswordCredential interface object length assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
 FAIL PasswordCredential interface object name assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
index c23c040..2e772ff 100644 (file)
@@ -1534,7 +1534,6 @@ Bug(GTK) fast/loader/fragment-after-redirect-gets-back-entry.html [ Failure Pass
 Bug(GTK) fast/writing-mode/japanese-ruby-horizontal-bt.html [ Failure Pass ]
 Bug(GTK) fast/writing-mode/japanese-ruby-vertical-lr.html [ Failure Pass ]
 Bug(GTK) fast/writing-mode/japanese-ruby-vertical-rl.html [ Failure Pass ]
-Bug(GTK) credentials/idlharness.html [ Failure Pass ]
 webkit.org/b/131533 media/track/track-remove-active-cue-crash.html [ Timeout Pass ]
 
 webkit.org/b/131934 fast/dom/Window/mozilla-focus-blur.html [ Failure Timeout Pass ]
index fa3ff16..65625b9 100644 (file)
@@ -5,6 +5,7 @@ navigator.appCodeName is OK
 navigator.appName is OK
 navigator.appVersion is OK
 navigator.cookieEnabled is OK
+navigator.credentials is OK
 navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
@@ -23,6 +24,7 @@ navigator.appCodeName is OK
 navigator.appName is OK
 navigator.appVersion is OK
 navigator.cookieEnabled is OK
+navigator.credentials is OK
 navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
index 56bdc9f..29fe951 100644 (file)
@@ -5,6 +5,7 @@ navigator.appCodeName is OK
 navigator.appName is OK
 navigator.appVersion is OK
 navigator.cookieEnabled is OK
+navigator.credentials is OK
 navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
@@ -26,6 +27,7 @@ navigator.appCodeName is OK
 navigator.appName is OK
 navigator.appVersion is OK
 navigator.cookieEnabled is OK
+navigator.credentials is OK
 navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
index aecf6ac..567339c 100644 (file)
@@ -5,6 +5,7 @@ navigator.appCodeName is OK
 navigator.appName is OK
 navigator.appVersion is OK
 navigator.cookieEnabled is OK
+navigator.credentials is OK
 navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
@@ -25,6 +26,7 @@ navigator.appCodeName is OK
 navigator.appName is OK
 navigator.appVersion is OK
 navigator.cookieEnabled is OK
+navigator.credentials is OK
 navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
index ac6a4aa..096cd45 100644 (file)
@@ -627,7 +627,7 @@ webkit.org/b/149630 css3/font-variant-all.html [ ImageOnlyFailure ]
 webkit.org/b/158836 imported/w3c/web-platform-tests/encrypted-media [ Skip ]
 
 # Credential Management not supported
-credentials/ [ Skip ]
+http/wpt/credential-management/ [ Skip ]
 
 # UIScriptController::zoomToScale is not implemented on Windows.
 webkit.org/b/180424 fast/visual-viewport/rtl-zoomed-rects.html [ Skip ]
index 0974460..9ccceac 100644 (file)
@@ -5,6 +5,7 @@ navigator.appCodeName is OK
 navigator.appName is OK
 navigator.appVersion is OK
 navigator.cookieEnabled is OK
+navigator.credentials is OK
 navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
@@ -24,6 +25,7 @@ navigator.appCodeName is OK
 navigator.appName is OK
 navigator.appVersion is OK
 navigator.cookieEnabled is OK
+navigator.credentials is OK
 navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
index 9f52be8..02fb1c1 100644 (file)
@@ -46,6 +46,7 @@ set(WebCore_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/Modules/speech"
     "${WEBCORE_DIR}/Modules/streams"
     "${WEBCORE_DIR}/Modules/webaudio"
+    "${WEBCORE_DIR}/Modules/webauthn"
     "${WEBCORE_DIR}/Modules/webdatabase"
     "${WEBCORE_DIR}/Modules/webdriver"
     "${WEBCORE_DIR}/Modules/websockets"
@@ -397,6 +398,8 @@ set(WebCore_NON_SVG_IDL_FILES
     Modules/webaudio/ScriptProcessorNode.idl
     Modules/webaudio/WaveShaperNode.idl
 
+    Modules/webauthn/PublicKeyCredential.idl
+
     Modules/webdatabase/DOMWindowWebDatabase.idl
     Modules/webdatabase/Database.idl
     Modules/webdatabase/DatabaseCallback.idl
index 13a6575..8c14b5b 100644 (file)
@@ -1,3 +1,64 @@
+2018-01-02  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Update Credential Management API for WebAuthentication
+        https://bugs.webkit.org/show_bug.cgi?id=181082
+        <rdar://problem/36055239>
+
+        Reviewed by Brent Fulgham.
+
+        Part 2/2
+
+        This patch implements Core API from Credential Management API: https://www.w3.org/TR/credential-management-1/#core.
+        which is required by WebAuthN. It also sets the CredentialManagement runtime flag to enable testing. Note that it
+        introduces a dummy PublicKeyCredential interface for testing functionalities of the Credential interface, which
+        cannot be instantiated.
+
+        Tests: http/wpt/credential-management/credentialscontainer-create-basics.https.html
+               http/wpt/credential-management/credentialscontainer-get-basics.https.html
+               http/wpt/credential-management/credentialscontainer-preventSilentAccess-basics.https.html
+               http/wpt/credential-management/idl.https.html
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Modules/credentialmanagement/BasicCredential.cpp:
+        (WebCore::BasicCredential::BasicCredential):
+        (WebCore::BasicCredential::type const):
+        * Modules/credentialmanagement/BasicCredential.h:
+        (WebCore::BasicCredential::discovery const):
+        * Modules/credentialmanagement/BasicCredential.idl:
+        * Modules/credentialmanagement/CredentialCreationOptions.h:
+        * Modules/credentialmanagement/CredentialCreationOptions.idl:
+        * Modules/credentialmanagement/CredentialRequestOptions.h:
+        * Modules/credentialmanagement/CredentialRequestOptions.idl:
+        * Modules/credentialmanagement/CredentialsContainer.cpp:
+        (WebCore::CredentialsContainer::CredentialsContainer):
+        (WebCore::CredentialsContainer::isSameOriginWithItsAncestors):
+        (WebCore::CredentialsContainer::dispatchTask):
+        (WebCore::CredentialsContainer::get):
+        (WebCore::CredentialsContainer::store):
+        (WebCore::CredentialsContainer::isCreate):
+        (WebCore::CredentialsContainer::preventSilentAccess):
+        * Modules/credentialmanagement/CredentialsContainer.h:
+        (WebCore::CredentialsContainer::create):
+        (WebCore::CredentialsContainer::CredentialsContainer): Deleted.
+        * Modules/credentialmanagement/CredentialsContainer.idl:
+        * Modules/credentialmanagement/NavigatorCredentials.cpp:
+        (WebCore::NavigatorCredentials::credentials):
+        * Modules/credentialmanagement/NavigatorCredentials.h:
+        * Modules/credentialmanagement/NavigatorCredentials.idl:
+        * Modules/webauthn/PublicKeyCredential.cpp: Copied from Source/WebCore/Modules/credentialmanagement/BasicCredential.cpp.
+        (WebCore::PublicKeyCredential::PublicKeyCredential):
+        (WebCore::PublicKeyCredential::collectFromCredentialStore):
+        (WebCore::PublicKeyCredential::discoverFromExternalSource):
+        (WebCore::PublicKeyCredential::store):
+        (WebCore::PublicKeyCredential::create):
+        * Modules/webauthn/PublicKeyCredential.h: Copied from Source/WebCore/Modules/credentialmanagement/BasicCredential.cpp.
+        * Modules/webauthn/PublicKeyCredential.idl: Copied from Source/WebCore/Modules/credentialmanagement/BasicCredential.idl.
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/WebCoreBuiltinNames.h:
+        * page/RuntimeEnabledFeatures.h:
+
 2018-01-02  Oleksandr Skachkov  <gskachkov@gmail.com>
 
         WebAssembly: sending module to iframe fails
index 8bb1c46..94a6db9 100644 (file)
@@ -54,6 +54,7 @@ VPATH = \
     $(WebCore)/Modules/speech \
     $(WebCore)/Modules/streams \
     $(WebCore)/Modules/webaudio \
+    $(WebCore)/Modules/webauthn \
     $(WebCore)/Modules/webdatabase \
     $(WebCore)/Modules/webdriver \
     $(WebCore)/Modules/websockets \
@@ -323,6 +324,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/Modules/webaudio/PeriodicWave.idl \
     $(WebCore)/Modules/webaudio/ScriptProcessorNode.idl \
     $(WebCore)/Modules/webaudio/WaveShaperNode.idl \
+    $(WebCore)/Modules/webauthn/PublicKeyCredential.idl \
     $(WebCore)/Modules/webdatabase/DOMWindowWebDatabase.idl \
     $(WebCore)/Modules/webdatabase/Database.idl \
     $(WebCore)/Modules/webdatabase/DatabaseCallback.idl \
index 22eb0f4..dc8f12a 100644 (file)
 
 namespace WebCore {
 
-BasicCredential::BasicCredential(const String& id, Type type)
+BasicCredential::BasicCredential(const String& id, Type type, Discovery discovery)
     : m_id(id)
     , m_type(type)
+    , m_discovery(discovery)
 {
 }
 
@@ -39,10 +40,8 @@ BasicCredential::~BasicCredential() = default;
 String BasicCredential::type() const
 {
     switch (m_type) {
-    case Type::Password:
-        return ASCIILiteral("password");
-    case Type::Federated:
-        return ASCIILiteral("federated");
+    case Type::PublicKey:
+        return ASCIILiteral("public-key");
     }
 
     ASSERT_NOT_REACHED();
index f81f99c..7760bea 100644 (file)
 
 #pragma once
 
-#include <wtf/RefCounted.h>
+#include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-class BasicCredential : public RefCounted<BasicCredential> {
+class BasicCredential : public ThreadSafeRefCounted<BasicCredential> {
 public:
     enum class Type {
-        Password,
-        Federated,
+        PublicKey,
+    };
+
+    enum class Discovery {
+        CredentialStore,
+        Remote,
     };
 
     virtual ~BasicCredential();
 
     const String& id() const { return m_id; }
     String type() const;
+    Discovery discovery() const { return m_discovery; }
 
 protected:
-    BasicCredential(const String&, Type);
+    BasicCredential(const String&, Type, Discovery);
 
 private:
     String m_id;
     Type m_type;
+    Discovery m_discovery;
 };
 
 } // namespace WebCore
index 8415bee..7a5e4ed 100644 (file)
@@ -27,6 +27,7 @@
     InterfaceName=Credential,
     EnabledAtRuntime=CredentialManagement,
     Exposed=Window,
+    SecureContext
 ] interface BasicCredential {
     readonly attribute USVString id;
     readonly attribute DOMString type;
index b259c40..de989d1 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 Google Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #pragma once
 
+#include <wtf/RefCounted.h>
+
 namespace WebCore {
 
+class AbortSignal;
+
 struct CredentialCreationOptions {
+    RefPtr<AbortSignal> signal;
+    std::optional<bool> publicKey;
 };
 
 } // namespace WebCore
index c081b94..330f4ea 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 Google Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -24,4 +25,6 @@
  */
 
 dictionary CredentialCreationOptions {
+    AbortSignal signal;
+    boolean publicKey; // fake for now
 };
index e5db317..f5cdfa6 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 Google Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #pragma once
 
+#include <wtf/RefCounted.h>
+
 namespace WebCore {
 
+class AbortSignal;
+
 struct CredentialRequestOptions {
     enum class MediationRequirement { Silent, Optional, Required };
 
     MediationRequirement mediation;
+    RefPtr<AbortSignal> signal;
+    std::optional<bool> publicKey;
 };
 
 } // namespace WebCore
index f87d0d5..aeeaf4a 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 Google Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -31,4 +32,6 @@ enum CredentialMediationRequirement {
 
 dictionary CredentialRequestOptions {
     CredentialMediationRequirement mediation = "optional";
+    AbortSignal signal;
+    boolean publicKey; // fake for now
 };
index 484e3d1..9ec3858 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 Google Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "config.h"
 #include "CredentialsContainer.h"
 
+#include "AbortSignal.h"
+#include "CredentialCreationOptions.h"
+#include "CredentialRequestOptions.h"
+#include "Document.h"
+#include "ExceptionOr.h"
+#include "JSBasicCredential.h"
+#include "PublicKeyCredential.h"
+#include "SecurityOrigin.h"
+
 namespace WebCore {
 
-void CredentialsContainer::get(std::optional<CredentialRequestOptions>, DOMPromiseDeferred<IDLInterface<BasicCredential>>&&)
+CredentialsContainer::CredentialsContainer(WeakPtr<Document>&& document)
+    : m_document(WTFMove(document))
+    , m_workQueue(WorkQueue::create("com.apple.WebKit.CredentialQueue"))
+{
+}
+
+bool CredentialsContainer::doesHaveSameOriginAsItsAncestors()
 {
+    if (!m_document)
+        return false;
+
+    auto& origin = m_document->securityOrigin();
+    for (auto* document = m_document->parentDocument(); document; document = document->parentDocument()) {
+        if (!originsMatch(document->securityOrigin(), origin))
+            return false;
+    }
+    return true;
 }
 
-void CredentialsContainer::store(const BasicCredential&, DOMPromiseDeferred<IDLInterface<BasicCredential>>&&)
+template<typename OperationType>
+void CredentialsContainer::dispatchTask(OperationType&& operation, Ref<DeferredPromise>&& promise)
 {
+    auto* promiseIndex = promise.ptr();
+    m_pendingPromises.add(promiseIndex, WTFMove(promise));
+    auto weakThis = m_weakPtrFactory.createWeakPtr(*this);
+    auto task = [promiseIndex, weakThis, isSameOriginWithItsAncestors = doesHaveSameOriginAsItsAncestors(), operation = WTFMove(operation)] () {
+        auto result = operation(isSameOriginWithItsAncestors);
+        callOnMainThread([promiseIndex, weakThis, result = WTFMove(result)] () mutable {
+            if (weakThis) {
+                if (auto promise = weakThis->m_pendingPromises.take(promiseIndex)) {
+                    if (result.hasException())
+                        promise.value()->reject(result.releaseException());
+                    else
+                        promise.value()->resolve<IDLNullable<IDLInterface<BasicCredential>>>(result.releaseReturnValue().get());
+                }
+            }
+        });
+    };
+    m_workQueue->dispatch(WTFMove(task));
 }
 
-void CredentialsContainer::isCreate(std::optional<CredentialCreationOptions>, DOMPromiseDeferred<IDLInterface<BasicCredential>>&&)
+void CredentialsContainer::get(CredentialRequestOptions&& options, Ref<DeferredPromise>&& promise)
 {
+    // FIXME: Optional options are passed with no contents. It should be std::optional.
+    if ((!options.signal && !options.publicKey) || !m_document) {
+        promise->reject(Exception { NotSupportedError });
+        return;
+    }
+    if (options.signal && options.signal->aborted()) {
+        promise->reject(Exception { AbortError });
+        return;
+    }
+    ASSERT(m_document->isSecureContext());
+
+    // The followings is a shortcut to https://www.w3.org/TR/credential-management-1/#algorithm-request,
+    // as we only support PublicKeyCredential which can only be requested from [[discoverFromExternalSource]].
+    if (!options.publicKey) {
+        promise->reject(Exception { NotSupportedError });
+        return;
+    }
+
+    auto operation = [options = WTFMove(options)] (bool isSameOriginWithItsAncestors) {
+        return PublicKeyCredential::discoverFromExternalSource(options, isSameOriginWithItsAncestors);
+    };
+    dispatchTask(WTFMove(operation), WTFMove(promise));
+}
+
+void CredentialsContainer::store(const BasicCredential&, Ref<DeferredPromise>&& promise)
+{
+    promise->reject(Exception { NotSupportedError });
+}
+
+void CredentialsContainer::isCreate(CredentialCreationOptions&& options, Ref<DeferredPromise>&& promise)
+{
+    // FIXME: Optional options are passed with no contents. It should be std::optional.
+    if ((!options.signal && !options.publicKey) || !m_document) {
+        promise->reject(Exception { NotSupportedError });
+        return;
+    }
+    if (options.signal && options.signal->aborted()) {
+        promise->reject(Exception { AbortError });
+        return;
+    }
+    ASSERT(m_document->isSecureContext());
+
+    // This is a shortcut to https://www.w3.org/TR/credential-management-1/#credentialrequestoptions-relevant-credential-interface-objects,
+    // as we only support one kind of credentials.
+    if (!options.publicKey) {
+        promise->reject(Exception { NotSupportedError });
+        return;
+    }
+
+    auto operation = [options = WTFMove(options)] (bool isSameOriginWithItsAncestors) {
+        // Shortcut as well.
+        return PublicKeyCredential::create(options, isSameOriginWithItsAncestors);
+    };
+    dispatchTask(WTFMove(operation), WTFMove(promise));
 }
 
-void CredentialsContainer::preventSilentAccess(DOMPromiseDeferred<IDLInterface<BasicCredential>>&&)
+void CredentialsContainer::preventSilentAccess(Ref<DeferredPromise>&& promise)
 {
+    promise->reject(Exception { NotSupportedError });
 }
 
 } // namespace WebCore
index 90568e4..3931b8d 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 Google Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #pragma once
 
-#include "CredentialCreationOptions.h"
-#include "CredentialRequestOptions.h"
 #include "JSDOMPromiseDeferred.h"
+#include <wtf/Function.h>
 #include <wtf/RefCounted.h>
+#include <wtf/WeakPtr.h>
+#include <wtf/WorkQueue.h>
 
 namespace WebCore {
 
 class BasicCredential;
+class Document;
+
+struct CredentialCreationOptions;
+struct CredentialRequestOptions;
 
 class CredentialsContainer : public RefCounted<CredentialsContainer> {
 public:
-    static Ref<CredentialsContainer> create() { return adoptRef(*new CredentialsContainer); }
+    static Ref<CredentialsContainer> create(WeakPtr<Document>&& document) { return adoptRef(*new CredentialsContainer(WTFMove(document))); }
+
+    void get(CredentialRequestOptions&&, Ref<DeferredPromise>&&);
 
-    void get(std::optional<CredentialRequestOptions>, DOMPromiseDeferred<IDLInterface<BasicCredential>>&&);
+    void store(const BasicCredential&, Ref<DeferredPromise>&&);
 
-    void store(const BasicCredential&, DOMPromiseDeferred<IDLInterface<BasicCredential>>&&);
+    void isCreate(CredentialCreationOptions&&, Ref<DeferredPromise>&&);
 
-    void isCreate(std::optional<CredentialCreationOptions>, DOMPromiseDeferred<IDLInterface<BasicCredential>>&&);
+    void preventSilentAccess(Ref<DeferredPromise>&&);
 
-    void preventSilentAccess(DOMPromiseDeferred<IDLInterface<BasicCredential>>&&);
 private:
-    CredentialsContainer() { }
+    CredentialsContainer(WeakPtr<Document>&&);
+
+    bool doesHaveSameOriginAsItsAncestors();
+    template<typename OperationType>
+    void dispatchTask(OperationType&&, Ref<DeferredPromise>&&);
+
+    WeakPtr<Document> m_document;
+    HashMap<DeferredPromise*, Ref<DeferredPromise>> m_pendingPromises;
+    Ref<WorkQueue> m_workQueue;
+    WeakPtrFactory<CredentialsContainer> m_weakPtrFactory;
 };
 
 } // namespace WebCore
index 7cb344a..8e90432 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 Google Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,6 +28,7 @@
     EnabledAtRuntime=CredentialManagement,
     Exposed=Window,
     ImplementationLacksVTable,
+    SecureContext,
 ] interface CredentialsContainer {
     Promise<BasicCredential?> get(optional CredentialRequestOptions options);
     Promise<BasicCredential> store(BasicCredential credential);
index 74a72c7..7f441bd 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 Google Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "config.h"
 #include "NavigatorCredentials.h"
 
+#include "Document.h"
+#include "Frame.h"
 #include "Navigator.h"
 
-
 namespace WebCore {
 
 NavigatorCredentials::NavigatorCredentials() = default;
@@ -40,17 +42,19 @@ const char* NavigatorCredentials::supplementName()
     return "NavigatorCredentials";
 }
 
-CredentialsContainer* NavigatorCredentials::credentials()
+CredentialsContainer* NavigatorCredentials::credentials(WeakPtr<Document>&& document)
 {
     if (!m_credentialsContainer)
-        m_credentialsContainer = CredentialsContainer::create();
+        m_credentialsContainer = CredentialsContainer::create(WTFMove(document));
 
     return m_credentialsContainer.get();
 }
 
 CredentialsContainer* NavigatorCredentials::credentials(Navigator& navigator)
 {
-    return NavigatorCredentials::from(&navigator)->credentials();
+    if (!navigator.frame() || !navigator.frame()->document())
+        return nullptr;
+    return NavigatorCredentials::from(&navigator)->credentials(navigator.frame()->document()->createWeakPtr());
 }
 
 NavigatorCredentials* NavigatorCredentials::from(Navigator* navigator)
index 76e2727..d3ab52b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 Google Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,6 +28,7 @@
 
 #include "CredentialsContainer.h"
 #include "Supplementable.h"
+#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 
@@ -37,11 +39,12 @@ public:
     NavigatorCredentials();
     virtual ~NavigatorCredentials();
 
-    CredentialsContainer* credentials();
-
-    static NavigatorCredentials* from(Navigator*);
     static CredentialsContainer* credentials(Navigator&);
+
 private:
+    CredentialsContainer* credentials(WeakPtr<Document>&&);
+
+    static NavigatorCredentials* from(Navigator*);
     static const char* supplementName();
 
     RefPtr<CredentialsContainer> m_credentialsContainer;
index 9f187ac..461f3bf 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 Google Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,5 +27,5 @@
 [
     EnabledAtRuntime=CredentialManagement,
 ] partial interface Navigator {
-    readonly attribute CredentialsContainer credentials;
+    [SecureContext, SameObject] readonly attribute CredentialsContainer credentials;
 };
diff --git a/Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp b/Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp
new file mode 100644 (file)
index 0000000..d708137
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PublicKeyCredential.h"
+
+namespace WebCore {
+
+PublicKeyCredential::PublicKeyCredential(const String& id)
+    : BasicCredential(id, Type::PublicKey, Discovery::Remote)
+{
+}
+
+Vector<Ref<BasicCredential>> PublicKeyCredential::collectFromCredentialStore(CredentialRequestOptions&&, bool)
+{
+    return { };
+}
+
+ExceptionOr<RefPtr<BasicCredential>> PublicKeyCredential::discoverFromExternalSource(const CredentialRequestOptions&, bool)
+{
+    return Exception { NotSupportedError };
+}
+
+RefPtr<BasicCredential> PublicKeyCredential::store(RefPtr<BasicCredential>&&, bool)
+{
+    return nullptr;
+}
+
+ExceptionOr<RefPtr<BasicCredential>> PublicKeyCredential::create(const CredentialCreationOptions&, bool)
+{
+    return Exception { NotSupportedError };
+}
+
+}
diff --git a/Source/WebCore/Modules/webauthn/PublicKeyCredential.h b/Source/WebCore/Modules/webauthn/PublicKeyCredential.h
new file mode 100644 (file)
index 0000000..d5e801a
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "BasicCredential.h"
+#include "ExceptionOr.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+struct CredentialCreationOptions;
+struct CredentialRequestOptions;
+
+class PublicKeyCredential final : public BasicCredential {
+public:
+    static Ref<PublicKeyCredential> create(const String& id)
+    {
+        return adoptRef(*new PublicKeyCredential(id));
+    }
+
+    static Vector<Ref<BasicCredential>> collectFromCredentialStore(CredentialRequestOptions&&, bool);
+    static ExceptionOr<RefPtr<BasicCredential>> discoverFromExternalSource(const CredentialRequestOptions&, bool);
+    static RefPtr<BasicCredential> store(RefPtr<BasicCredential>&&, bool);
+    static ExceptionOr<RefPtr<BasicCredential>> create(const CredentialCreationOptions&, bool);
+
+private:
+    PublicKeyCredential(const String&);
+};
+
+} // namespace WebCore
diff --git a/Source/WebCore/Modules/webauthn/PublicKeyCredential.idl b/Source/WebCore/Modules/webauthn/PublicKeyCredential.idl
new file mode 100644 (file)
index 0000000..28bcfe8
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    EnabledAtRuntime=CredentialManagement,
+    Exposed=Window,
+    SecureContext,
+] interface PublicKeyCredential {
+    // Dummy for now.
+};
index 7f6b837..a4baf59 100644 (file)
@@ -244,6 +244,8 @@ Modules/webaudio/WaveShaperDSPKernel.cpp
 Modules/webaudio/WaveShaperNode.cpp
 Modules/webaudio/WaveShaperProcessor.cpp
 
+Modules/webauthn/PublicKeyCredential.cpp
+
 Modules/webdatabase/ChangeVersionWrapper.cpp
 Modules/webdatabase/DOMWindowWebDatabase.cpp
 Modules/webdatabase/Database.cpp
@@ -2732,6 +2734,7 @@ JSPositionOptions.cpp
 JSProcessingInstruction.cpp
 JSProgressEvent.cpp
 JSPromiseRejectionEvent.cpp
+JSPublicKeyCredential.cpp
 JSRTCAnswerOptions.cpp
 JSRTCConfiguration.cpp
 JSRTCDTMFSender.cpp
index 43bb4b5..ec8f0d4 100644 (file)
                57C7A69F1E57917800C67D71 /* JSBasicCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57C7A69D1E57910D00C67D71 /* JSBasicCredential.h */; };
                57D0018D1DD5413200ED19D9 /* JSCryptoKeyUsage.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D0018C1DD5413200ED19D9 /* JSCryptoKeyUsage.h */; };
                57D846281FE8960500CA3682 /* NavigatorCredentials.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D846261FE895F800CA3682 /* NavigatorCredentials.h */; };
+               57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D8462B1FEAF68F00CA3682 /* PublicKeyCredential.h */; };
+               57D846351FEAFCD300CA3682 /* JSPublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */; };
                57E1E5A31E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5A11E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.h */; };
                57E1E5A71E8DBD3E00EE37C9 /* CryptoAlgorithmAesCtrParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5A61E8DBD3E00EE37C9 /* CryptoAlgorithmAesCtrParams.h */; };
                57E1E5AD1E8DD09B00EE37C9 /* JSAesCtrParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5AB1E8DD09B00EE37C9 /* JSAesCtrParams.h */; };
                57D846251FE895F600CA3682 /* NavigatorCredentials.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NavigatorCredentials.idl; sourceTree = "<group>"; };
                57D846261FE895F800CA3682 /* NavigatorCredentials.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigatorCredentials.h; sourceTree = "<group>"; };
                57D846291FE99F6300CA3682 /* CredentialsContainer.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CredentialsContainer.idl; sourceTree = "<group>"; };
+               57D8462B1FEAF68F00CA3682 /* PublicKeyCredential.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PublicKeyCredential.h; sourceTree = "<group>"; };
+               57D8462C1FEAF68F00CA3682 /* PublicKeyCredential.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PublicKeyCredential.cpp; sourceTree = "<group>"; };
+               57D8462D1FEAF68F00CA3682 /* PublicKeyCredential.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PublicKeyCredential.idl; sourceTree = "<group>"; };
+               57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPublicKeyCredential.h; sourceTree = "<group>"; };
+               57D846311FEAFC2F00CA3682 /* JSPublicKeyCredential.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPublicKeyCredential.cpp; sourceTree = "<group>"; };
                57E1E5A01E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmAES_CTR.cpp; sourceTree = "<group>"; };
                57E1E5A11E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAES_CTR.h; sourceTree = "<group>"; };
                57E1E5A61E8DBD3E00EE37C9 /* CryptoAlgorithmAesCtrParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesCtrParams.h; sourceTree = "<group>"; };
                                E1C8BE4B0E8BD0D10064CB7D /* Threads */,
                                BC9854530CD3DA8F00069BC1 /* Traversal */,
                                FDA15E7B12B03E04003A583A /* WebAudio */,
+                               57D8462F1FEAFB0500CA3682 /* WebAuthN */,
                                5DA5E0F9102B950400088CF9 /* WebSockets */,
                                2DDE1CDC1F574A5600D1A365 /* WebVR */,
                                BC9854430CD3D9D000069BC1 /* Window */,
                        name = CredentialManagement;
                        sourceTree = "<group>";
                };
+               57D8462A1FEAF57F00CA3682 /* webauthn */ = {
+                       isa = PBXGroup;
+                       children = (
+                               57D8462C1FEAF68F00CA3682 /* PublicKeyCredential.cpp */,
+                               57D8462B1FEAF68F00CA3682 /* PublicKeyCredential.h */,
+                               57D8462D1FEAF68F00CA3682 /* PublicKeyCredential.idl */,
+                       );
+                       path = webauthn;
+                       sourceTree = "<group>";
+               };
+               57D8462F1FEAFB0500CA3682 /* WebAuthN */ = {
+                       isa = PBXGroup;
+                       children = (
+                               57D846311FEAFC2F00CA3682 /* JSPublicKeyCredential.cpp */,
+                               57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */,
+                       );
+                       name = WebAuthN;
+                       sourceTree = "<group>";
+               };
                59B5977111086556007159E8 /* jsc */ = {
                        isa = PBXGroup;
                        children = (
                                AA2A5AB716A485A400975A25 /* speech */,
                                41A023EA1A39DB7900F722CF /* streams */,
                                FD315FA212B025B100C1A359 /* webaudio */,
+                               57D8462A1FEAF57F00CA3682 /* webauthn */,
                                97BC69D51505F054001B74AC /* webdatabase */,
                                996E59DA1DF00D45006612B9 /* webdriver */,
                                97AABCF714FA09B5007457AE /* websockets */,
                                65DF320009D1CC60000BE325 /* JSProcessingInstruction.h in Headers */,
                                E44613EE0CD681BB00FADA75 /* JSProgressEvent.h in Headers */,
                                A578F43C1DE01423003DFC6A /* JSPromiseRejectionEvent.h in Headers */,
+                               57D846351FEAFCD300CA3682 /* JSPublicKeyCredential.h in Headers */,
                                077664FD183E6B5C00133B92 /* JSQuickTimePluginReplacement.h in Headers */,
                                B658FFA21522EF3A00DD5595 /* JSRadioNodeList.h in Headers */,
                                65DF320209D1CC60000BE325 /* JSRange.h in Headers */,
                                E12719C70EEEC16800F61213 /* NavigatorBase.h in Headers */,
                                8321507E1F27EA1B0095B136 /* NavigatorBeacon.h in Headers */,
                                57D846281FE8960500CA3682 /* NavigatorCredentials.h in Headers */,
+                               57D846281FE8960500CA3682 /* NavigatorCredentials.h in Headers */,
                                9711460414EF009A00674FD9 /* NavigatorGeolocation.h in Headers */,
                                5EA725D61ACABD5700EAD17B /* NavigatorMediaDevices.h in Headers */,
                                996E59DF1DF0128D006612B9 /* NavigatorWebDriver.h in Headers */,
                                51A052561058874000CC9E95 /* ProtectionSpaceHash.h in Headers */,
                                1AF8E11A1256592600230FF7 /* ProxyServer.h in Headers */,
                                FF945ECC161F7F3600971BC8 /* PseudoElement.h in Headers */,
+                               57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */,
                                0081FF0016B0A2D3008AAA7A /* PublicSuffix.h in Headers */,
                                10FB084B14E15C7E00A3DB98 /* PublicURLManager.h in Headers */,
                                550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */,
index fd04721..c7569c2 100644 (file)
@@ -111,6 +111,7 @@ namespace WebCore {
     macro(PerformanceObserver) \
     macro(PerformanceObserverEntryList) \
     macro(PerformanceResourceTiming) \
+    macro(PublicKeyCredential) \
     macro(RTCDTMFSender) \
     macro(RTCDTMFToneChangeEvent) \
     macro(RTCDataChannel) \
index 97976ca..f9907a0 100644 (file)
@@ -1,3 +1,16 @@
+2018-01-02  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Update Credential Management API for WebAuthentication
+        https://bugs.webkit.org/show_bug.cgi?id=181082
+        <rdar://problem/36055239>
+
+        Reviewed by Brent Fulgham.
+
+        Enable Credential Management API for testing.
+
+        * DumpRenderTree/TestOptions.h:
+        * WebKitTestRunner/TestOptions.h:
+
 2018-01-02  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [GTK] Test /webkit2/WebKitWebExtension/form-controls-associated-signal is flaky
index 3f35e47..ab5548d 100644 (file)
@@ -35,7 +35,7 @@ struct TestOptions {
     bool enableMenuItemElement { false };
     bool enableModernMediaControls { true };
     bool enablePointerLock { false };
-    bool enableCredentialManagement { false };
+    bool enableCredentialManagement { true };
     bool enableDragDestinationActionLoad { false };
     bool layerBackedWebView { false };
     bool enableIsSecureContextAttribute { true };
index 011f49d..37cf665 100644 (file)
@@ -49,7 +49,7 @@ struct TestOptions {
     bool enableMenuItemElement { false };
     bool enableModernMediaControls { true };
     bool enablePointerLock { false };
-    bool enableCredentialManagement { false };
+    bool enableCredentialManagement { true };
     bool enableIsSecureContextAttribute { true };
     bool enableInspectorAdditions { false };
     bool shouldShowTouches { false };