Changeset 250940 in webkit


Ignore:
Timestamp:
Oct 9, 2019 4:03:06 PM (4 years ago)
Author:
jiewen_tan@apple.com
Message:

[WebAuthn] Move the mock testing entrance to Internals
https://bugs.webkit.org/show_bug.cgi?id=202560
<rdar://problem/55973793>

Reviewed by Chris Dumez.

Source/WebCore:

This patch moves TestRunner.setWebAuthenticationMockConfiguration to
Internals.setMockWebAuthenticationConfiguration and removes the old
entrance. The purpose of this patch is to allow API tests to use
the same mock infrastructure that is used by layout tests.

No new tests, covered by updates on existing tests.

  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Modules/webauthn/PublicKeyCredentialCreationOptions.h:
  • WebCore.xcodeproj/project.pbxproj:
  • page/ChromeClient.h:

(WebCore::ChromeClient::setMockWebAuthenticationConfiguration):

  • testing/Internals.cpp:

(WebCore::Internals::setMockWebAuthenticationConfiguration):

  • testing/Internals.h:
  • testing/Internals.idl:
  • testing/MockWebAuthenticationConfiguration.h: Added.

(WebCore::MockWebAuthenticationConfiguration::LocalConfiguration::encode const):
(WebCore::MockWebAuthenticationConfiguration::LocalConfiguration::decode):
(WebCore::MockWebAuthenticationConfiguration::HidConfiguration::encode const):
(WebCore::MockWebAuthenticationConfiguration::HidConfiguration::decode):
(WebCore::MockWebAuthenticationConfiguration::NfcConfiguration::encode const):
(WebCore::MockWebAuthenticationConfiguration::NfcConfiguration::decode):
(WebCore::MockWebAuthenticationConfiguration::encode const):
(WebCore::MockWebAuthenticationConfiguration::decode):

  • testing/MockWebAuthenticationConfiguration.idl: Added.

Source/WebKit:

  • UIProcess/API/C/WKWebsiteDataStoreRef.cpp:

(WKWebsiteDataStoreSetWebAuthenticationMockConfiguration): Deleted.

  • UIProcess/API/C/WKWebsiteDataStoreRef.h:
  • UIProcess/WebAuthentication/AuthenticatorTransportService.cpp:

(WebKit::AuthenticatorTransportService::createMock):

  • UIProcess/WebAuthentication/AuthenticatorTransportService.h:
  • UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp:

(WebKit::MockAuthenticatorManager::MockAuthenticatorManager):

  • UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.h:
  • UIProcess/WebAuthentication/Mock/MockHidConnection.cpp:

(WebKit::MockHidConnection::send):
(WebKit::MockHidConnection::registerDataReceivedCallbackInternal):
(WebKit::MockHidConnection::parseRequest):
(WebKit::MockHidConnection::feedReports):
(WebKit::MockHidConnection::shouldContinueFeedReports):

  • UIProcess/WebAuthentication/Mock/MockHidConnection.h:
  • UIProcess/WebAuthentication/Mock/MockHidService.cpp:

(WebKit::MockHidService::MockHidService):

  • UIProcess/WebAuthentication/Mock/MockHidService.h:
  • UIProcess/WebAuthentication/Mock/MockLocalConnection.h:
  • UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:

(WebKit::MockLocalConnection::MockLocalConnection):

  • UIProcess/WebAuthentication/Mock/MockLocalService.h:
  • UIProcess/WebAuthentication/Mock/MockLocalService.mm:

(WebKit::MockLocalService::MockLocalService):

  • UIProcess/WebAuthentication/Mock/MockNfcService.h:
  • UIProcess/WebAuthentication/Mock/MockNfcService.mm:

(WebKit::MockNfcService::MockNfcService):
(WebKit::MockNfcService::platformStartDiscovery):
(WebKit::MockNfcService::detectTags const):

  • UIProcess/WebAuthentication/Mock/MockWebAuthenticationConfiguration.h: Removed.
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::setMockWebAuthenticationConfiguration):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/WebsiteData/WebsiteDataStore.h:
  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::setMockWebAuthenticationConfiguration):

  • WebProcess/WebCoreSupport/WebChromeClient.h:

Tools:

  • WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setWebAuthenticationMockConfiguration): Deleted.

  • WebKitTestRunner/InjectedBundle/TestRunner.h:
  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::setWebAuthenticationMockConfiguration): Deleted.

  • WebKitTestRunner/TestController.h:
  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

  • http/wpt/webauthn/ctap-hid-failure.https.html:
  • http/wpt/webauthn/ctap-hid-success.https.html:
  • http/wpt/webauthn/ctap-nfc-failure.https.html:
  • http/wpt/webauthn/idl.https.html:
  • http/wpt/webauthn/public-key-credential-create-failure-hid-silent.https.html:
  • http/wpt/webauthn/public-key-credential-create-failure-hid.https.html:
  • http/wpt/webauthn/public-key-credential-create-failure-local-silent.https.html:
  • http/wpt/webauthn/public-key-credential-create-failure-local.https.html:
  • http/wpt/webauthn/public-key-credential-create-failure-nfc.https.html:
  • http/wpt/webauthn/public-key-credential-create-failure-u2f-silent.https.html:
  • http/wpt/webauthn/public-key-credential-create-failure-u2f.https.html:
  • http/wpt/webauthn/public-key-credential-create-failure.https.html:
  • http/wpt/webauthn/public-key-credential-create-success-hid.https.html:
  • http/wpt/webauthn/public-key-credential-create-success-local.https.html:
  • http/wpt/webauthn/public-key-credential-create-success-nfc.https.html:
  • http/wpt/webauthn/public-key-credential-create-success-u2f.https.html:
  • http/wpt/webauthn/public-key-credential-get-failure-hid-silent.https.html:
  • http/wpt/webauthn/public-key-credential-get-failure-hid.https.html:
  • http/wpt/webauthn/public-key-credential-get-failure-local-silent.https.html:
  • http/wpt/webauthn/public-key-credential-get-failure-local.https.html:
  • http/wpt/webauthn/public-key-credential-get-failure-nfc.https.html:
  • http/wpt/webauthn/public-key-credential-get-failure-u2f-silent.https.html:
  • http/wpt/webauthn/public-key-credential-get-failure-u2f.https.html:
  • http/wpt/webauthn/public-key-credential-get-failure.https.html:
  • http/wpt/webauthn/public-key-credential-get-success-hid.https.html:
  • http/wpt/webauthn/public-key-credential-get-success-local.https.html:
  • http/wpt/webauthn/public-key-credential-get-success-nfc.https.html:
  • http/wpt/webauthn/public-key-credential-get-success-u2f.https.html:
  • http/wpt/webauthn/resources/public-key-credential-ip-address.https.html:
Location:
trunk
Files:
2 added
1 deleted
72 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r250938 r250940  
     12019-10-09  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Move the mock testing entrance to Internals
     4        https://bugs.webkit.org/show_bug.cgi?id=202560
     5        <rdar://problem/55973793>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * http/wpt/webauthn/ctap-hid-failure.https.html:
     10        * http/wpt/webauthn/ctap-hid-success.https.html:
     11        * http/wpt/webauthn/ctap-nfc-failure.https.html:
     12        * http/wpt/webauthn/idl.https.html:
     13        * http/wpt/webauthn/public-key-credential-create-failure-hid-silent.https.html:
     14        * http/wpt/webauthn/public-key-credential-create-failure-hid.https.html:
     15        * http/wpt/webauthn/public-key-credential-create-failure-local-silent.https.html:
     16        * http/wpt/webauthn/public-key-credential-create-failure-local.https.html:
     17        * http/wpt/webauthn/public-key-credential-create-failure-nfc.https.html:
     18        * http/wpt/webauthn/public-key-credential-create-failure-u2f-silent.https.html:
     19        * http/wpt/webauthn/public-key-credential-create-failure-u2f.https.html:
     20        * http/wpt/webauthn/public-key-credential-create-failure.https.html:
     21        * http/wpt/webauthn/public-key-credential-create-success-hid.https.html:
     22        * http/wpt/webauthn/public-key-credential-create-success-local.https.html:
     23        * http/wpt/webauthn/public-key-credential-create-success-nfc.https.html:
     24        * http/wpt/webauthn/public-key-credential-create-success-u2f.https.html:
     25        * http/wpt/webauthn/public-key-credential-get-failure-hid-silent.https.html:
     26        * http/wpt/webauthn/public-key-credential-get-failure-hid.https.html:
     27        * http/wpt/webauthn/public-key-credential-get-failure-local-silent.https.html:
     28        * http/wpt/webauthn/public-key-credential-get-failure-local.https.html:
     29        * http/wpt/webauthn/public-key-credential-get-failure-nfc.https.html:
     30        * http/wpt/webauthn/public-key-credential-get-failure-u2f-silent.https.html:
     31        * http/wpt/webauthn/public-key-credential-get-failure-u2f.https.html:
     32        * http/wpt/webauthn/public-key-credential-get-failure.https.html:
     33        * http/wpt/webauthn/public-key-credential-get-success-hid.https.html:
     34        * http/wpt/webauthn/public-key-credential-get-success-local.https.html:
     35        * http/wpt/webauthn/public-key-credential-get-success-nfc.https.html:
     36        * http/wpt/webauthn/public-key-credential-get-success-u2f.https.html:
     37        * http/wpt/webauthn/resources/public-key-credential-ip-address.https.html:
     38
    1392019-10-09  Dean Jackson  <dino@apple.com>
    240
  • trunk/LayoutTests/http/wpt/credential-management/credentialscontainer-store-basics.https.html

    r250249 r250940  
    4343        };
    4444        // A mock attestation object
    45         if (window.testRunner)
    46             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testCreationMessageBase64] } });
     45        if (window.internals)
     46            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testCreationMessageBase64] } });
    4747        const credential = await navigator.credentials.create(options);
    4848
  • trunk/LayoutTests/http/wpt/webauthn/ctap-hid-failure.https.html

    r245262 r250940  
    2222
    2323    promise_test(function(t) {
    24         if (window.testRunner)
    25             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "data-not-sent" } });
     24        if (window.internals)
     25            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "init", error: "data-not-sent" } });
    2626        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
    2727    }, "CTAP HID with init sub stage data not sent error in a mock hid authenticator.");
    2828
    2929    promise_test(function(t) {
    30         if (window.testRunner)
    31             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "empty-report" } });
     30        if (window.internals)
     31            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "init", error: "empty-report" } });
    3232        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
    3333    }, "CTAP HID with init sub stage empty report error in a mock hid authenticator.");
    3434
    3535    promise_test(function(t) {
    36         if (window.testRunner)
    37             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-channel-id" } });
     36        if (window.internals)
     37            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-channel-id" } });
    3838        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
    3939    }, "CTAP HID with init sub stage wrong channel id error in a mock hid authenticator.");
    4040
    4141    promise_test(function(t) {
    42         if (window.testRunner)
    43             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-nonce" } });
     42        if (window.internals)
     43            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-nonce" } });
    4444        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
    4545    }, "CTAP HID with init sub stage wrong nonce error in a mock hid authenticator.");
    4646
    4747    promise_test(function(t) {
    48         if (window.testRunner)
    49             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "msg", error: "data-not-sent" } });
     48        if (window.internals)
     49            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "msg", error: "data-not-sent" } });
    5050        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
    5151    }, "CTAP HID with msg sub stage data not sent error in a mock hid authenticator.");
    5252
    5353    promise_test(function(t) {
    54         if (window.testRunner)
    55             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "msg", error: "empty-report" } });
     54        if (window.internals)
     55            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "msg", error: "empty-report" } });
    5656        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
    5757    }, "CTAP HID with msg sub stage empty report error in a mock hid authenticator.");
    5858
    5959    promise_test(function(t) {
    60         if (window.testRunner)
    61             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "msg", error: "wrong-channel-id" } });
     60        if (window.internals)
     61            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "msg", error: "wrong-channel-id" } });
    6262        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
    6363    }, "CTAP HID with msg sub stage wrong channel id error in a mock hid authenticator.");
    6464
    6565    promise_test(function(t) {
    66         if (window.testRunner)
    67             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "wrong-channel-id", payloadBase64:[testDummyMessagePayloadBase64] } });
     66        if (window.internals)
     67            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "wrong-channel-id", payloadBase64:[testDummyMessagePayloadBase64] } });
    6868        return promiseRejects(t, "UnknownError", navigator.credentials.create(defaultOptions), "Unknown internal error. Error code: 18");
    6969    }, "CTAP HID with request::msg stage wrong channel id error in a mock hid authenticator.");
  • trunk/LayoutTests/http/wpt/webauthn/ctap-hid-success.https.html

    r239752 r250940  
    2121
    2222    promise_test(function(t) {
    23         if (window.testRunner)
    24             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testCreationMessageBase64], keepAlive: true } });
     23        if (window.internals)
     24            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testCreationMessageBase64], keepAlive: true } });
    2525        return navigator.credentials.create(defaultOptions).then(credential => {
    2626            assert_not_equals(credential, undefined);
     
    3030
    3131    promise_test(function(t) {
    32         if (window.testRunner)
    33             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testCreationMessageBase64], fastDataArrival: true } });
     32        if (window.internals)
     33            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testCreationMessageBase64], fastDataArrival: true } });
    3434        return navigator.credentials.create(defaultOptions).then(credential => {
    3535            assert_not_equals(credential, undefined);
     
    3939
    4040    promise_test(function(t) {
    41         if (window.testRunner)
    42             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "empty-report", payloadBase64: [testCreationMessageBase64], continueAfterErrorData: true } });
     41        if (window.internals)
     42            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "init", error: "empty-report", payloadBase64: [testCreationMessageBase64], continueAfterErrorData: true } });
    4343        return navigator.credentials.create(defaultOptions).then(credential => {
    4444            assert_not_equals(credential, undefined);
     
    4848
    4949    promise_test(function(t) {
    50         if (window.testRunner)
    51             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-channel-id", payloadBase64: [testCreationMessageBase64], continueAfterErrorData: true } });
     50        if (window.internals)
     51            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-channel-id", payloadBase64: [testCreationMessageBase64], continueAfterErrorData: true } });
    5252        return navigator.credentials.create(defaultOptions).then(credential => {
    5353            assert_not_equals(credential, undefined);
     
    5757
    5858    promise_test(function(t) {
    59         if (window.testRunner)
    60             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-nonce", payloadBase64: [testCreationMessageBase64], continueAfterErrorData: true } });
     59        if (window.internals)
     60            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-nonce", payloadBase64: [testCreationMessageBase64], continueAfterErrorData: true } });
    6161        return navigator.credentials.create(defaultOptions).then(credential => {
    6262            assert_not_equals(credential, undefined);
  • trunk/LayoutTests/http/wpt/webauthn/ctap-nfc-failure.https.html

    r249059 r250940  
    2222
    2323    promise_test(function(t) {
    24         if (window.testRunner)
    25             testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "malicious-payload", payloadBase64:[testNfcU2fVersionBase64, ""] } });
     24        if (window.internals)
     25            internals.setMockWebAuthenticationConfiguration({ nfc: { error: "malicious-payload", payloadBase64:[testNfcU2fVersionBase64, ""] } });
    2626        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
    2727    }, "CTAP NFC with empty apdu response in a mock nfc authenticator.");
    2828
    2929    promise_test(function(t) {
    30         if (window.testRunner)
    31             testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "malicious-payload", payloadBase64:[testNfcU2fVersionBase64, testU2fApduWrongDataOnlyResponseBase64] } });
     30        if (window.internals)
     31            internals.setMockWebAuthenticationConfiguration({ nfc: { error: "malicious-payload", payloadBase64:[testNfcU2fVersionBase64, testU2fApduWrongDataOnlyResponseBase64] } });
    3232        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
    3333    }, "CTAP NFC with wrong data error in a mock nfc authenticator.");
  • trunk/LayoutTests/http/wpt/webauthn/idl.https.html

    r250249 r250940  
    5353    };
    5454    // A mock attestation object
    55     if (window.testRunner)
    56         testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testCreationMessageBase64] } });
     55    if (window.internals)
     56        internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testCreationMessageBase64] } });
    5757    createdCredential = await navigator.credentials.create(creationOptions);
    5858
     
    6262        }
    6363    };
    64     if (window.testRunner)
    65         testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64] } });
     64    if (window.internals)
     65        internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64] } });
    6666    requestedCredential = await navigator.credentials.get(requestOptions);
    6767
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure-hid-silent.https.html

    r245262 r250940  
    2222        };
    2323
    24         if (window.testRunner)
    25             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testDummyMessagePayloadBase64] } });
     24        if (window.internals)
     25            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testDummyMessagePayloadBase64] } });
    2626        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    2727    }, "PublicKeyCredential's [[create]] with malicious payload in a mock hid authenticator.");
     
    4545        };
    4646
    47         if (window.testRunner)
    48             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
     47        if (window.internals)
     48            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
    4949        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    5050    }, "PublicKeyCredential's [[create]] with unsupported options in a mock hid authenticator.");
     
    6868        };
    6969
    70         if (window.testRunner)
    71             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
     70        if (window.internals)
     71            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
    7272        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    7373    }, "PublicKeyCredential's [[create]] with unsupported options in a mock hid authenticator. 2");
     
    9191        };
    9292
    93         if (window.testRunner)
    94             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
     93        if (window.internals)
     94            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
    9595        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    9696    }, "PublicKeyCredential's [[create]] with mixed options in a mock hid authenticator.");
     
    112112       };
    113113
    114        if (window.testRunner)
    115            testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testCtapErrCredentialExcludedOnlyResponseBase64] } });
     114       if (window.internals)
     115           internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testCtapErrCredentialExcludedOnlyResponseBase64] } });
    116116       return promiseRejects(t, "InvalidStateError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the authenticator.");
    117117   }, "PublicKeyCredential's [[create]] with InvalidStateError in a mock hid authenticator.");
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure-hid.https.html

    r245262 r250940  
    66<script>
    77    // Default mock configuration. Tests need to override it if they need different configuration.
    8     if (window.testRunner)
    9         testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload" } });
     8    if (window.internals)
     9        internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload" } });
    1010
    1111    promise_test(function(t) {
     
    4646        };
    4747
    48         if (window.testRunner)
    49             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testDummyMessagePayloadBase64] } });
     48        if (window.internals)
     49            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testDummyMessagePayloadBase64] } });
    5050        return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error. Error code: 255");
    5151    }, "PublicKeyCredential's [[create]] with malicious payload in a mock hid authenticator.");
     
    6868        };
    6969
    70         if (window.testRunner)
    71             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
     70        if (window.internals)
     71            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
    7272        return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error. Error code: 43");
    7373    }, "PublicKeyCredential's [[create]] with unsupported options in a mock hid authenticator.");
     
    9090        };
    9191
    92         if (window.testRunner)
    93             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
     92        if (window.internals)
     93            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
    9494        return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error. Error code: 43");
    9595    }, "PublicKeyCredential's [[create]] with unsupported options in a mock hid authenticator. 2");
     
    113113        };
    114114
    115         if (window.testRunner)
    116             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
     115        if (window.internals)
     116            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
    117117        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    118118    }, "PublicKeyCredential's [[create]] with mixed options in a mock hid authenticator.");
     
    135135        };
    136136
    137         if (window.testRunner)
    138             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
     137        if (window.internals)
     138            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
    139139        return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error. Error code: 43");
    140140    }, "PublicKeyCredential's [[create]] with mixed options in a mock hid authenticator. 2");
     
    156156        };
    157157
    158         if (window.testRunner)
    159             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testCtapErrCredentialExcludedOnlyResponseBase64] } });
     158        if (window.internals)
     159            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testCtapErrCredentialExcludedOnlyResponseBase64] } });
    160160        return promiseRejects(t, "InvalidStateError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the authenticator.");
    161161    }, "PublicKeyCredential's [[create]] with InvalidStateError in a mock hid authenticator.");
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure-local-silent.https.html

    r250249 r250940  
    1010        const credentialID = await calculateCredentialID(privateKeyBase64);
    1111        // Default mock configuration. Tests need to override if they need different configuration.
    12         if (window.testRunner)
    13             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, local: { acceptAuthentication: false, acceptAttestation: false } });
     12        if (window.internals)
     13            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, local: { acceptAuthentication: false, acceptAttestation: false } });
    1414
    1515        promise_test(t => {
     
    122122                }
    123123            };
    124             if (window.testRunner)
    125                 testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, local: { acceptAuthentication: true, acceptAttestation: false } });
     124            if (window.internals)
     125                internals.setMockWebAuthenticationConfiguration({ silentFailure: true, local: { acceptAuthentication: true, acceptAttestation: false } });
    126126            return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    127127        }, "PublicKeyCredential's [[create]] with silent failure in a mock local authenticator. 5");
     
    143143                }
    144144            };
    145             if (window.testRunner) {
    146                 testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, local: { acceptAuthentication: true, acceptAttestation: false } });
     145            if (window.internals) {
     146                internals.setMockWebAuthenticationConfiguration({ silentFailure: true, local: { acceptAuthentication: true, acceptAttestation: false } });
    147147                testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, userhandleBase64);
    148148            }
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure-local.https.html

    r250249 r250940  
    1010        const credentialID = await calculateCredentialID(privateKeyBase64);
    1111        // Default mock configuration. Tests need to override if they need different configuration.
    12         if (window.testRunner)
    13             testRunner.setWebAuthenticationMockConfiguration({ local: { acceptAuthentication: false, acceptAttestation: false } });
     12        if (window.internals)
     13            internals.setMockWebAuthenticationConfiguration({ local: { acceptAuthentication: false, acceptAttestation: false } });
    1414
    1515        promise_test(t => {
     
    117117                }
    118118            };
    119             if (window.testRunner)
    120                 testRunner.setWebAuthenticationMockConfiguration({ local: { acceptAuthentication: true, acceptAttestation: false } });
     119            if (window.internals)
     120                internals.setMockWebAuthenticationConfiguration({ local: { acceptAuthentication: true, acceptAttestation: false } });
    121121            return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error.");
    122122        }, "PublicKeyCredential's [[create]] without attestation in a mock local authenticator.");
     
    137137                }
    138138            };
    139             if (window.testRunner) {
    140                 testRunner.setWebAuthenticationMockConfiguration({ local: { acceptAuthentication: true, acceptAttestation: false } });
     139            if (window.internals) {
     140                internals.setMockWebAuthenticationConfiguration({ local: { acceptAuthentication: true, acceptAttestation: false } });
    141141                testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, userhandleBase64);
    142142            }
     
    165165            };
    166166
    167             if (window.testRunner)
    168                 testRunner.setWebAuthenticationMockConfiguration({ local: { acceptAuthentication: false, acceptAttestation: false } });
     167            if (window.internals)
     168                internals.setMockWebAuthenticationConfiguration({ local: { acceptAuthentication: false, acceptAttestation: false } });
    169169            return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    170170        }, "PublicKeyCredential's [[create]] with timeout in a mock local authenticator.");
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure-nfc.https.html

    r249059 r250940  
    66<script>
    77    // Default mock configuration. Tests need to override it if they need different configuration.
    8     if (window.testRunner)
    9         testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "no-tags" } });
     8    if (window.internals)
     9        internals.setMockWebAuthenticationConfiguration({ nfc: { error: "no-tags" } });
    1010
    1111    promise_test(function(t) {
     
    6767        };
    6868
    69         if (window.testRunner)
    70             testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "wrong-tag-type" } });
     69        if (window.internals)
     70            internals.setMockWebAuthenticationConfiguration({ nfc: { error: "wrong-tag-type" } });
    7171        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    7272    }, "PublicKeyCredential's [[create]] with wrong tag type in a mock nfc authenticator.");
     
    8989        };
    9090
    91         if (window.testRunner)
    92             testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "no-connections" } });
     91        if (window.internals)
     92            internals.setMockWebAuthenticationConfiguration({ nfc: { error: "no-connections" } });
    9393        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    9494    }, "PublicKeyCredential's [[create]] with no connections in a mock nfc authenticator.");
     
    111111        };
    112112
    113         if (window.testRunner)
    114             testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "malicious-payload", payloadBase64: [ ] } });
     113        if (window.internals)
     114            internals.setMockWebAuthenticationConfiguration({ nfc: { error: "malicious-payload", payloadBase64: [ ] } });
    115115        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    116116    }, "PublicKeyCredential's [[create]] with null version in a mock nfc authenticator.");
     
    133133        };
    134134
    135         if (window.testRunner)
    136             testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "malicious-payload", payloadBase64:[testDummyMessagePayloadBase64] } });
     135        if (window.internals)
     136            internals.setMockWebAuthenticationConfiguration({ nfc: { error: "malicious-payload", payloadBase64:[testDummyMessagePayloadBase64] } });
    137137        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    138138    }, "PublicKeyCredential's [[create]] with wrong version in a mock nfc authenticator.");
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure-u2f-silent.https.html

    r249656 r250940  
    2222        };
    2323
    24         if (window.testRunner)
    25             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: ["AQ=="] } });
     24        if (window.internals)
     25            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: ["AQ=="] } });
    2626        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    2727    }, "PublicKeyCredential's [[create]] with malformed APDU payload in a mock hid authenticator.");
     
    4444        };
    4545
    46         if (window.testRunner)
    47             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64] } });
     46        if (window.internals)
     47            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64] } });
    4848        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    4949    }, "PublicKeyCredential's [[create]] with malformed U2F register response in a mock hid authenticator.");
     
    6666        };
    6767
    68         if (window.testRunner)
    69             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduInsNotSupportedOnlyResponseBase64] } });
     68        if (window.internals)
     69            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduInsNotSupportedOnlyResponseBase64] } });
    7070        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    7171    }, "PublicKeyCredential's [[create]] with register command error in a mock hid authenticator.");
     
    8989        };
    9090
    91         if (window.testRunner)
    92             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64, testU2fApduInsNotSupportedOnlyResponseBase64] } });
     91        if (window.internals)
     92            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64, testU2fApduInsNotSupportedOnlyResponseBase64] } });
    9393        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    9494    }, "PublicKeyCredential's [[create]] with bogus command error in a mock hid authenticator.");
     
    111111        };
    112112
    113         if (window.testRunner)
    114             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
     113        if (window.internals)
     114            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
    115115        return promiseRejects(t, "InvalidStateError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the authenticator.");
    116116    }, "PublicKeyCredential's [[create]] with first exclude credential matched in a mock hid authenticator.");
     
    134134        };
    135135
    136         if (window.testRunner)
    137             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
     136        if (window.internals)
     137            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
    138138        return promiseRejects(t, "InvalidStateError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the authenticator.");
    139139    }, "PublicKeyCredential's [[create]] with second exclude credential matched in a mock hid authenticator.");
     
    157157        };
    158158
    159         if (window.testRunner)
    160             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
     159        if (window.internals)
     160            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
    161161        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
    162162    }, "PublicKeyCredential's [[create]] with first exclude credential matched in a mock hid authenticator. Test of user presence.");
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure-u2f.https.html

    r239752 r250940  
    2121        };
    2222
    23         if (window.testRunner)
    24             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: ["AQ=="] } });
     23        if (window.internals)
     24            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: ["AQ=="] } });
    2525        return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Couldn't parse the APDU response.");
    2626    }, "PublicKeyCredential's [[create]] with malformed APDU payload in a mock hid authenticator.");
     
    4242        };
    4343
    44         if (window.testRunner)
    45             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64] } });
     44        if (window.internals)
     45            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64] } });
    4646        return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Couldn't parse the U2F register response.");
    4747    }, "PublicKeyCredential's [[create]] with malformed U2F register response in a mock hid authenticator.");
     
    6363        };
    6464
    65         if (window.testRunner)
    66             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduInsNotSupportedOnlyResponseBase64] } });
     65        if (window.internals)
     66            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduInsNotSupportedOnlyResponseBase64] } });
    6767        return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error. Error code: 27904");
    6868    }, "PublicKeyCredential's [[create]] with register command error in a mock hid authenticator.");
     
    8585        };
    8686
    87         if (window.testRunner)
    88             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64, testU2fApduInsNotSupportedOnlyResponseBase64] } });
     87        if (window.internals)
     88            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64, testU2fApduInsNotSupportedOnlyResponseBase64] } });
    8989        return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error. Error code: 27904");
    9090    }, "PublicKeyCredential's [[create]] with bogus command error in a mock hid authenticator.");
     
    107107        };
    108108
    109         if (window.testRunner)
    110             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
     109        if (window.internals)
     110            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
    111111        return promiseRejects(t, "InvalidStateError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the authenticator.");
    112112    }, "PublicKeyCredential's [[create]] with first exclude credential matched in a mock hid authenticator.");
     
    130130        };
    131131
    132         if (window.testRunner)
    133             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
     132        if (window.internals)
     133            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
    134134        return promiseRejects(t, "InvalidStateError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the authenticator.");
    135135    }, "PublicKeyCredential's [[create]] with second exclude credential matched in a mock hid authenticator.");
     
    152152        };
    153153
    154         if (window.testRunner)
    155             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
     154        if (window.internals)
     155            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
    156156        return promiseRejects(t, "InvalidStateError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the authenticator.");
    157157    }, "PublicKeyCredential's [[create]] with first exclude credential matched in a mock hid authenticator. Test of user presence.");
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https.html

    r245043 r250940  
    66<script>
    77    // Default mock configuration. Tests need to override if they need different configuration.
    8     if (window.testRunner)
    9         testRunner.setWebAuthenticationMockConfiguration({ });
     8    if (window.internals)
     9        internals.setMockWebAuthenticationConfiguration({ });
    1010
    1111    promise_test(function(t) {
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-hid.https.html

    r250659 r250940  
    77<script>
    88    // Default mock configuration. Tests need to override if they need different configuration.
    9     if (window.testRunner)
    10         testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testCreationMessageBase64] } });
     9    if (window.internals)
     10        internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testCreationMessageBase64] } });
    1111
    1212    promise_test(t => {
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-local.https.html

    r250249 r250940  
    1111        const credentialID = await calculateCredentialID(privateKeyBase64);
    1212        // Default mock configuration. Tests need to override if they need different configuration.
    13         if (window.testRunner)
    14             testRunner.setWebAuthenticationMockConfiguration({
     13        if (window.internals)
     14            internals.setMockWebAuthenticationConfiguration({
    1515                local: {
    1616                    acceptAuthentication: true,
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-nfc.https.html

    r249059 r250940  
    77<script>
    88    // Default mock configuration. Tests need to override if they need different configuration.
    9     if (window.testRunner)
    10         testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "success", payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testCreationMessageApduBase64] } });
     9    if (window.internals)
     10        internals.setMockWebAuthenticationConfiguration({ nfc: { error: "success", payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testCreationMessageApduBase64] } });
    1111
    1212    promise_test(t => {
     
    7272        };
    7373
    74         if (window.testRunner)
    75             testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "success", payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testCreationMessageApduBase64], multipleTags: true } });
     74        if (window.internals)
     75            internals.setMockWebAuthenticationConfiguration({ nfc: { error: "success", payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testCreationMessageApduBase64], multipleTags: true } });
    7676        return navigator.credentials.create(options).then(credential => {
    7777            checkCtapMakeCredentialResult(credential);
     
    9696        };
    9797
    98         if (window.testRunner)
    99             testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "success", payloadBase64: [testNfcU2fVersionBase64, testU2fApduInsNotSupportedOnlyResponseBase64, testU2fRegisterResponse] } });
     98        if (window.internals)
     99            internals.setMockWebAuthenticationConfiguration({ nfc: { error: "success", payloadBase64: [testNfcU2fVersionBase64, testU2fApduInsNotSupportedOnlyResponseBase64, testU2fRegisterResponse] } });
    100100        return navigator.credentials.create(options).then(credential => {
    101101            checkU2fMakeCredentialResult(credential);
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-u2f.https.html

    r249737 r250940  
    2222        };
    2323
    24         if (window.testRunner)
    25             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fRegisterResponse] } });
     24        if (window.internals)
     25            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fRegisterResponse] } });
    2626        return navigator.credentials.create(options).then(credential => {
    2727            checkU2fMakeCredentialResult(credential);
     
    4646        };
    4747
    48         if (window.testRunner)
    49             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fRegisterResponse] } });
     48        if (window.internals)
     49            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fRegisterResponse] } });
    5050        return navigator.credentials.create(options).then(credential => {
    5151            checkU2fMakeCredentialResult(credential);
     
    7070        };
    7171
    72         if (window.testRunner)
    73             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fRegisterResponse] } });
     72        if (window.internals)
     73            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fRegisterResponse] } });
    7474        return navigator.credentials.create(options).then(credential => {
    7575            checkU2fMakeCredentialResult(credential);
     
    9393        };
    9494
    95         if (window.testRunner)
    96             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fRegisterResponse] } });
     95        if (window.internals)
     96            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fRegisterResponse] } });
    9797        return navigator.credentials.create(options).then(credential => {
    9898            checkU2fMakeCredentialResult(credential);
     
    117117        };
    118118
    119         if (window.testRunner)
    120             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fRegisterResponse] } });
     119        if (window.internals)
     120            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fRegisterResponse] } });
    121121        return navigator.credentials.create(options).then(credential => {
    122122            checkU2fMakeCredentialResult(credential);
     
    141141        };
    142142
    143         if (window.testRunner)
    144             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fRegisterResponse] } });
     143        if (window.internals)
     144            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fRegisterResponse] } });
    145145        return navigator.credentials.create(options).then(credential => {
    146146            checkU2fMakeCredentialResult(credential, false);
     
    165165        };
    166166
    167         if (window.testRunner)
    168             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fRegisterResponse] } });
     167        if (window.internals)
     168            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fRegisterResponse] } });
    169169        return navigator.credentials.create(options).then(credential => {
    170170            checkU2fMakeCredentialResult(credential, false);
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure-hid-silent.https.html

    r245500 r250940  
    1313        };
    1414
    15         if (window.testRunner)
    16             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testDummyMessagePayloadBase64] } });
     15        if (window.internals)
     16            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testDummyMessagePayloadBase64] } });
    1717        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
    1818    }, "PublicKeyCredential's [[get]] with malicious payload in a mock hid authenticator.");
     
    2727        };
    2828
    29         if (window.testRunner)
    30             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
     29        if (window.internals)
     30            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
    3131        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
    3232    }, "PublicKeyCredential's [[get]] with unsupported options in a mock hid authenticator.");
     
    4040        };
    4141
    42         if (window.testRunner)
    43             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
     42        if (window.internals)
     43            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
    4444        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
    4545    }, "PublicKeyCredential's [[get]] with invalid credential in a mock hid authenticator.");
     
    5353        };
    5454
    55         if (window.testRunner)
    56             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
     55        if (window.internals)
     56            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
    5757        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
    5858    }, "PublicKeyCredential's [[get]] with authenticator downgrade in a mock hid authenticator.");
     
    6767        };
    6868
    69         if (window.testRunner)
    70             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
     69        if (window.internals)
     70            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
    7171        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
    7272    }, "PublicKeyCredential's [[get]] with authenticator downgrade in a mock hid authenticator. 2");
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure-hid.https.html

    r245500 r250940  
    66<script>
    77    // Default mock configuration. Tests need to override if they need different configuration.
    8     if (window.testRunner)
    9         testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload" } });
     8    if (window.internals)
     9        internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload" } });
    1010
    1111    promise_test(t => {
     
    3232        };
    3333
    34         if (window.testRunner)
    35             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testDummyMessagePayloadBase64] } });
     34        if (window.internals)
     35            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testDummyMessagePayloadBase64] } });
    3636        return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 255");
    3737    }, "PublicKeyCredential's [[get]] with malicious payload in a mock hid authenticator.");
     
    4545        };
    4646
    47         if (window.testRunner)
    48             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
     47        if (window.internals)
     48            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
    4949        return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 43");
    5050    }, "PublicKeyCredential's [[get]] with unsupported options in a mock hid authenticator.");
     
    5757        };
    5858
    59         if (window.testRunner)
    60             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
     59        if (window.internals)
     60            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
    6161        return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 34");
    6262    }, "PublicKeyCredential's [[get]] with authenticator downgrade failed in a mock hid authenticator.");
     
    7070        };
    7171
    72         if (window.testRunner)
    73             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
     72        if (window.internals)
     73            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
    7474        return promiseRejects(t, "NotSupportedError", navigator.credentials.get(options), "Cannot convert the request to U2F command.");
    7575    }, "PublicKeyCredential's [[get]] with authenticator downgrade succeeded and then U2F failed in a mock hid authenticator. 2");
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure-local-silent.https.html

    r250249 r250940  
    1010        const credentialID = await calculateCredentialID(privateKeyBase64);
    1111        // Default mock configuration. Tests need to override if they need different configuration.
    12         if (window.testRunner)
    13             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, local: { acceptAuthentication: false, acceptAttestation: false, preferredUserhandleBase64: userhandleBase64 } });
     12        if (window.internals)
     13            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, local: { acceptAuthentication: false, acceptAttestation: false, preferredUserhandleBase64: userhandleBase64 } });
    1414
    1515        promise_test(t => {
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure-local.https.html

    r250249 r250940  
    1010        const credentialID = await calculateCredentialID(privateKeyBase64);
    1111        // Default mock configuration. Tests need to override if they need different configuration.
    12         if (window.testRunner)
    13             testRunner.setWebAuthenticationMockConfiguration({ local: { acceptAuthentication: false, acceptAttestation: false, preferredUserhandleBase64: userhandleBase64 } });
     12        if (window.internals)
     13            internals.setMockWebAuthenticationConfiguration({ local: { acceptAuthentication: false, acceptAttestation: false, preferredUserhandleBase64: userhandleBase64 } });
    1414
    1515        promise_test(t => {
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure-nfc.https.html

    r249059 r250940  
    66<script>
    77    // Default mock configuration. Tests need to override if they need different configuration.
    8     if (window.testRunner)
    9         testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "malicious-payload" } });
     8    if (window.internals)
     9        internals.setMockWebAuthenticationConfiguration({ nfc: { error: "malicious-payload" } });
    1010
    1111    promise_test(t => {
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure-u2f-silent.https.html

    r239752 r250940  
    1414        };
    1515
    16         if (window.testRunner)
    17             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64] } });
     16        if (window.internals)
     17            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64] } });
    1818        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
    1919    }, "PublicKeyCredential's [[get]] with malformed sign response in a mock hid authenticator.");
     
    2828        };
    2929
    30         if (window.testRunner)
    31             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64] } });
     30        if (window.internals)
     31            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64] } });
    3232        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
    3333    }, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator.");
     
    4242        };
    4343
    44         if (window.testRunner)
    45             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64] } });
     44        if (window.internals)
     45            internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64] } });
    4646        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
    4747    }, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator. 2");
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure-u2f.https.html

    r243193 r250940  
    1313        };
    1414
    15         if (window.testRunner)
    16             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64] } });
     15        if (window.internals)
     16            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64] } });
    1717        return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Couldn't parse the U2F sign response.");
    1818    }, "PublicKeyCredential's [[get]] with malformed sign response in a mock hid authenticator.");
     
    2626        };
    2727
    28         if (window.testRunner)
    29             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64] } });
     28        if (window.internals)
     29            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64] } });
    3030        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No credentials from the allowCredentials list is found in the authenticator.");
    3131    }, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator.");
     
    3939        };
    4040
    41         if (window.testRunner)
    42             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64] } });
     41        if (window.internals)
     42            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64] } });
    4343        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No credentials from the allowCredentials list is found in the authenticator.");
    4444    }, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator. 2");
     
    5454        };
    5555
    56         if (window.testRunner)
    57             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64] } });
     56        if (window.internals)
     57            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64] } });
    5858        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No credentials from the allowCredentials list is found in the authenticator.");
    5959    }, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator. (AppID)");
     
    6868        };
    6969
    70         if (window.testRunner)
    71             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64] } });
     70        if (window.internals)
     71            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64] } });
    7272        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No credentials from the allowCredentials list is found in the authenticator.");
    7373    }, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator. 2 (AppID)");
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure.https.html

    r245043 r250940  
    66<script>
    77    // Default mock configuration. Tests need to override if they need different configuration.
    8     if (window.testRunner)
    9         testRunner.setWebAuthenticationMockConfiguration({ });
     8    if (window.internals)
     9        internals.setMockWebAuthenticationConfiguration({ });
    1010
    1111    promise_test(t => {
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-success-hid.https.html

    r249059 r250940  
    66<script>
    77    // Default mock configuration. Tests need to override if they need different configuration.
    8     if (window.testRunner)
    9         testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64] } });
     8    if (window.internals)
     9        internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64] } });
    1010
    1111    promise_test(t => {
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-success-local.https.html

    r250249 r250940  
    1010        const credentialID = await calculateCredentialID(privateKeyBase64);
    1111        // Default mock configuration. Tests need to override if they need different configuration.
    12         if (window.testRunner)
    13             testRunner.setWebAuthenticationMockConfiguration({ local: { acceptAuthentication: true, acceptAttestation: false, preferredUserhandleBase64: userhandleBase64 } });
     12        if (window.internals)
     13            internals.setMockWebAuthenticationConfiguration({ local: { acceptAuthentication: true, acceptAttestation: false, preferredUserhandleBase64: userhandleBase64 } });
    1414
    1515        function checkResult(credential)
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-success-nfc.https.html

    r249436 r250940  
    66<script>
    77    // Default mock configuration. Tests need to override if they need different configuration.
    8     if (window.testRunner)
    9         testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "success", payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testAssertionMessageApduBase64] } });
     8    if (window.internals)
     9        internals.setMockWebAuthenticationConfiguration({ nfc: { error: "success", payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testAssertionMessageApduBase64] } });
    1010
    1111    promise_test(t => {
     
    3131        };
    3232
    33         if (window.testRunner)
    34             testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "success", payloadBase64: [testNfcU2fVersionBase64, testU2fApduInsNotSupportedOnlyResponseBase64, testU2fSignResponse] } });
     33        if (window.internals)
     34            internals.setMockWebAuthenticationConfiguration({ nfc: { error: "success", payloadBase64: [testNfcU2fVersionBase64, testU2fApduInsNotSupportedOnlyResponseBase64, testU2fSignResponse] } });
    3535        return navigator.credentials.get(options).then(credential => {
    3636            return checkU2fGetAssertionResult(credential);
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-success-u2f.https.html

    r249059 r250940  
    1414        };
    1515
    16         if (window.testRunner)
    17             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fSignResponse] } });
     16        if (window.internals)
     17            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fSignResponse] } });
    1818        return navigator.credentials.get(options).then(credential => {
    1919            return checkU2fGetAssertionResult(credential);
     
    3030        };
    3131
    32         if (window.testRunner)
    33             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
     32        if (window.internals)
     33            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
    3434        return navigator.credentials.get(options).then(credential => {
    3535            return checkU2fGetAssertionResult(credential);
     
    4646        };
    4747
    48         if (window.testRunner)
    49             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fSignResponse] } });
     48        if (window.internals)
     49            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fApduConditionsNotSatisfiedOnlyResponseBase64, testU2fSignResponse] } });
    5050        return navigator.credentials.get(options).then(credential => {
    5151            return checkU2fGetAssertionResult(credential);
     
    6464        };
    6565
    66         if (window.testRunner)
    67             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fSignResponse] } });
     66        if (window.internals)
     67            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fSignResponse] } });
    6868        return navigator.credentials.get(options).then(credential => {
    6969            return checkU2fGetAssertionResult(credential);
     
    8181        };
    8282
    83         if (window.testRunner)
    84             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fSignResponse] } });
     83        if (window.internals)
     84            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fSignResponse] } });
    8585        return navigator.credentials.get(options).then(credential => {
    8686            return checkU2fGetAssertionResult(credential);
     
    9898        };
    9999
    100         if (window.testRunner)
    101             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
     100        if (window.internals)
     101            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
    102102        return navigator.credentials.get(options).then(credential => {
    103103            return checkU2fGetAssertionResult(credential, true);
     
    116116        };
    117117
    118         if (window.testRunner)
    119             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
     118        if (window.internals)
     119            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
    120120        return navigator.credentials.get(options).then(credential => {
    121121            return checkU2fGetAssertionResult(credential, true, "7eabc5cc3251bdc59115ef87b5f7ee74cb03747e39ba8341748565cc129c0719");
     
    133133        };
    134134
    135         if (window.testRunner)
    136             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
     135        if (window.internals)
     136            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
    137137        return navigator.credentials.get(options).then(credential => {
    138138            return checkU2fGetAssertionResult(credential);
     
    150150        };
    151151
    152         if (window.testRunner)
    153             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
     152        if (window.internals)
     153            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
    154154        return navigator.credentials.get(options).then(credential => {
    155155            return checkU2fGetAssertionResult(credential, true);
     
    167167        };
    168168
    169         if (window.testRunner)
    170             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64, testU2fSignResponse] } });
     169        if (window.internals)
     170            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64, testU2fSignResponse] } });
    171171        return navigator.credentials.get(options).then(credential => {
    172172            return checkU2fGetAssertionResult(credential);
     
    184184        };
    185185
    186         if (window.testRunner)
    187             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
     186        if (window.internals)
     187            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
    188188        return navigator.credentials.get(options).then(credential => {
    189189            return checkU2fGetAssertionResult(credential, true, "7eabc5cc3251bdc59115ef87b5f7ee74cb03747e39ba8341748565cc129c0719");
  • trunk/LayoutTests/http/wpt/webauthn/resources/public-key-credential-ip-address.https.html

    r244863 r250940  
    66<script>
    77    // Default mock configuration. Tests need to override if they need different configuration.
    8     if (window.testRunner)
    9         testRunner.setWebAuthenticationMockConfiguration({ });
     8    if (window.internals)
     9        internals.setMockWebAuthenticationConfiguration({ });
    1010
    1111    promise_test(function(t) {
  • trunk/Source/WebCore/ChangeLog

    r250939 r250940  
     12019-10-09  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Move the mock testing entrance to Internals
     4        https://bugs.webkit.org/show_bug.cgi?id=202560
     5        <rdar://problem/55973793>
     6
     7        Reviewed by Chris Dumez.
     8
     9        This patch moves TestRunner.setWebAuthenticationMockConfiguration to
     10        Internals.setMockWebAuthenticationConfiguration and removes the old
     11        entrance. The purpose of this patch is to allow API tests to use
     12        the same mock infrastructure that is used by layout tests.
     13
     14        No new tests, covered by updates on existing tests.
     15
     16        * DerivedSources-input.xcfilelist:
     17        * DerivedSources-output.xcfilelist:
     18        * DerivedSources.make:
     19        * Modules/webauthn/PublicKeyCredentialCreationOptions.h:
     20        * WebCore.xcodeproj/project.pbxproj:
     21        * page/ChromeClient.h:
     22        (WebCore::ChromeClient::setMockWebAuthenticationConfiguration):
     23        * testing/Internals.cpp:
     24        (WebCore::Internals::setMockWebAuthenticationConfiguration):
     25        * testing/Internals.h:
     26        * testing/Internals.idl:
     27        * testing/MockWebAuthenticationConfiguration.h: Added.
     28        (WebCore::MockWebAuthenticationConfiguration::LocalConfiguration::encode const):
     29        (WebCore::MockWebAuthenticationConfiguration::LocalConfiguration::decode):
     30        (WebCore::MockWebAuthenticationConfiguration::HidConfiguration::encode const):
     31        (WebCore::MockWebAuthenticationConfiguration::HidConfiguration::decode):
     32        (WebCore::MockWebAuthenticationConfiguration::NfcConfiguration::encode const):
     33        (WebCore::MockWebAuthenticationConfiguration::NfcConfiguration::decode):
     34        (WebCore::MockWebAuthenticationConfiguration::encode const):
     35        (WebCore::MockWebAuthenticationConfiguration::decode):
     36        * testing/MockWebAuthenticationConfiguration.idl: Added.
     37
    1382019-10-09  Sihui Liu  <sihui_liu@apple.com>
    239
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r250825 r250940  
    10901090$(PROJECT_DIR)/testing/MockPaymentCoordinator.idl
    10911091$(PROJECT_DIR)/testing/MockPaymentError.idl
     1092$(PROJECT_DIR)/testing/MockWebAuthenticationConfiguration.idl
    10921093$(PROJECT_DIR)/testing/ServiceWorkerInternals.idl
    10931094$(PROJECT_DIR)/testing/TypeConversions.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r250825 r250940  
    10601060$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMockPaymentError.cpp
    10611061$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMockPaymentError.h
     1062$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMockWebAuthenticationConfiguration.cpp
     1063$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMockWebAuthenticationConfiguration.h
    10621064$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMouseEvent.cpp
    10631065$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMouseEvent.h
  • trunk/Source/WebCore/DerivedSources.make

    r250824 r250940  
    10771077    $(WebCore)/testing/MockPaymentCoordinator.idl \
    10781078    $(WebCore)/testing/MockPaymentError.idl \
     1079    $(WebCore)/testing/MockWebAuthenticationConfiguration.idl \
    10791080    $(WebCore)/testing/ServiceWorkerInternals.idl \
    10801081    $(WebCore)/testing/TypeConversions.idl \
  • trunk/Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h

    r250659 r250940  
    3434#include "PublicKeyCredentialType.h"
    3535#include "UserVerificationRequirement.h"
    36 #include <wtf/CrossThreadCopier.h>
    3736#include <wtf/Forward.h>
    3837
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r250824 r250940  
    17391739                57152B7C21DD8BA1000C37CA /* U2fResponseConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 57152B7A21DD8BA1000C37CA /* U2fResponseConverter.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17401740                57152B8021DDA581000C37CA /* WebAuthenticationUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 57152B7E21DDA581000C37CA /* WebAuthenticationUtils.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1741                5715610B234C1B49008FC7AB /* MockWebAuthenticationConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 57156108234C1B31008FC7AB /* MockWebAuthenticationConfiguration.h */; };
     1742                5715610C234C1CA1008FC7AB /* MockWebAuthenticationConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 57156108234C1B31008FC7AB /* MockWebAuthenticationConfiguration.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1743                57156114234C7FD6008FC7AB /* JSMockWebAuthenticationConfiguration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57156111234C7FBC008FC7AB /* JSMockWebAuthenticationConfiguration.cpp */; };
     1744                57156115234C7FDC008FC7AB /* JSMockWebAuthenticationConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 57156110234C7FBC008FC7AB /* JSMockWebAuthenticationConfiguration.h */; };
    17411745                571F21891DA57C54005C9EFD /* JSSubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 571F21881DA57C54005C9EFD /* JSSubtleCrypto.h */; };
    17421746                572093D31DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcCfbParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 572093D21DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcCfbParams.h */; };
     
    86068610                57152B7E21DDA581000C37CA /* WebAuthenticationUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebAuthenticationUtils.h; sourceTree = "<group>"; };
    86078611                57152B7F21DDA581000C37CA /* WebAuthenticationUtils.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebAuthenticationUtils.cpp; sourceTree = "<group>"; };
     8612                57156108234C1B31008FC7AB /* MockWebAuthenticationConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockWebAuthenticationConfiguration.h; sourceTree = "<group>"; };
     8613                5715610D234C7481008FC7AB /* MockWebAuthenticationConfiguration.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MockWebAuthenticationConfiguration.idl; sourceTree = "<group>"; };
     8614                57156110234C7FBC008FC7AB /* JSMockWebAuthenticationConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMockWebAuthenticationConfiguration.h; sourceTree = "<group>"; };
     8615                57156111234C7FBC008FC7AB /* JSMockWebAuthenticationConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMockWebAuthenticationConfiguration.cpp; sourceTree = "<group>"; };
    86088616                571F21881DA57C54005C9EFD /* JSSubtleCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSubtleCrypto.h; sourceTree = "<group>"; };
    86098617                571F218A1DA57C7A005C9EFD /* JSSubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSubtleCrypto.cpp; sourceTree = "<group>"; };
     
    1789317901                                A14061891E2ECA0A0032B34E /* MockPreviewLoaderClient.cpp */,
    1789417902                                A140618A1E2ECA0A0032B34E /* MockPreviewLoaderClient.h */,
     17903                                57156108234C1B31008FC7AB /* MockWebAuthenticationConfiguration.h */,
     17904                                5715610D234C7481008FC7AB /* MockWebAuthenticationConfiguration.idl */,
    1789517905                                417F0D801FFEE14F008EF303 /* ServiceWorkerInternals.cpp */,
    1789617906                                417F0D7E1FFEE14E008EF303 /* ServiceWorkerInternals.h */,
     
    1793317943                                A1BB85B42159B3890067E07D /* JSMockPaymentError.cpp */,
    1793417944                                A1BB85B52159B38A0067E07D /* JSMockPaymentError.h */,
     17945                                57156111234C7FBC008FC7AB /* JSMockWebAuthenticationConfiguration.cpp */,
     17946                                57156110234C7FBC008FC7AB /* JSMockWebAuthenticationConfiguration.h */,
    1793517947                                427DA71B13735DFA007C57FB /* JSServiceWorkerInternals.cpp */,
    1793617948                                427DA71C13735DFA007C57FB /* JSServiceWorkerInternals.h */,
     
    2842628438                                A146D31B1F99BCFB00D29196 /* JSMockPaymentCoordinator.h in Headers */,
    2842728439                                A1BB85B92159B3AE0067E07D /* JSMockPaymentError.h in Headers */,
     28440                                57156115234C7FDC008FC7AB /* JSMockWebAuthenticationConfiguration.h in Headers */,
    2842828441                                427DA71E13735DFA007C57FB /* JSServiceWorkerInternals.h in Headers */,
    2842928442                                EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */,
     
    2844328456                                A1CBEF641F9F11290028DE7C /* MockPaymentMethod.h in Headers */,
    2844428457                                A140618C1E2ECA0A0032B34E /* MockPreviewLoaderClient.h in Headers */,
     28458                                5715610B234C1B49008FC7AB /* MockWebAuthenticationConfiguration.h in Headers */,
    2844528459                                AA5F3B8D16CC33D100455EB0 /* PlatformSpeechSynthesizerMock.h in Headers */,
    2844628460                                A1763F3F1E205234001D58DE /* WebArchiveDumpSupport.h in Headers */,
     
    3102231036                                CDF2B0171820540700F2B424 /* MockSourceBufferPrivate.h in Headers */,
    3102331037                                CDF2B0191820540700F2B424 /* MockTracks.h in Headers */,
     31038                                5715610C234C1CA1008FC7AB /* MockWebAuthenticationConfiguration.h in Headers */,
    3102431039                                C6D74AD509AA282E000B0A52 /* ModifySelectionListLevel.h in Headers */,
    3102531040                                709A01FE1E3D0BDD006B0D4C /* ModuleFetchFailureKind.h in Headers */,
     
    3298533000                                A146D31A1F99BCF800D29196 /* JSMockPaymentCoordinator.cpp in Sources */,
    3298633001                                A1BB85B82159B3A40067E07D /* JSMockPaymentError.cpp in Sources */,
     33002                                57156114234C7FD6008FC7AB /* JSMockWebAuthenticationConfiguration.cpp in Sources */,
    3298733003                                427DA71D13735DFA007C57FB /* JSServiceWorkerInternals.cpp in Sources */,
    3298833004                                EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */,
  • trunk/Source/WebCore/page/ChromeClient.h

    r249359 r250940  
    111111struct DateTimeChooserParameters;
    112112struct GraphicsDeviceAdapter;
     113struct MockWebAuthenticationConfiguration;
    113114struct ShareDataWithParsedURL;
    114115struct ViewportArguments;
     
    511512    virtual void setUserIsInteracting(bool) { }
    512513
     514#if ENABLE(WEB_AUTHN)
     515    virtual void setMockWebAuthenticationConfiguration(const MockWebAuthenticationConfiguration&) { }
     516#endif
     517
    513518protected:
    514519    virtual ~ChromeClient() = default;
  • trunk/Source/WebCore/testing/Internals.cpp

    r250738 r250940  
    52355235}
    52365236
     5237#if ENABLE(WEB_AUTHN)
     5238void Internals::setMockWebAuthenticationConfiguration(const MockWebAuthenticationConfiguration& configuration)
     5239{
     5240    auto* document = contextDocument();
     5241    if (!document)
     5242        return;
     5243    auto* page = document->page();
     5244    if (!page)
     5245        return;
     5246    page->chrome().client().setMockWebAuthenticationConfiguration(configuration);
     5247}
     5248#endif
     5249
    52375250} // namespace WebCore
  • trunk/Source/WebCore/testing/Internals.h

    r250735 r250940  
    113113template<typename IDLType> class DOMPromiseDeferred;
    114114
     115struct MockWebAuthenticationConfiguration;
     116
    115117class Internals final : public RefCounted<Internals>, private ContextDestructionObserver
    116118#if ENABLE(MEDIA_STREAM)
     
    885887    void addPrefetchLoadEventListener(HTMLLinkElement&, RefPtr<EventListener>&&);
    886888
     889#if ENABLE(WEB_AUTHN)
     890    void setMockWebAuthenticationConfiguration(const MockWebAuthenticationConfiguration&);
     891#endif
     892
    887893private:
    888894    explicit Internals(Document&);
  • trunk/Source/WebCore/testing/Internals.idl

    r250663 r250940  
    795795
    796796    void addPrefetchLoadEventListener(HTMLLinkElement link, EventListener? callback);
    797 };
     797
     798    [Conditional=WEB_AUTHN] void setMockWebAuthenticationConfiguration(MockWebAuthenticationConfiguration configuration);
     799};
  • trunk/Source/WebKit/ChangeLog

    r250934 r250940  
     12019-10-09  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Move the mock testing entrance to Internals
     4        https://bugs.webkit.org/show_bug.cgi?id=202560
     5        <rdar://problem/55973793>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
     10        (WKWebsiteDataStoreSetWebAuthenticationMockConfiguration): Deleted.
     11        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
     12        * UIProcess/WebAuthentication/AuthenticatorTransportService.cpp:
     13        (WebKit::AuthenticatorTransportService::createMock):
     14        * UIProcess/WebAuthentication/AuthenticatorTransportService.h:
     15        * UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp:
     16        (WebKit::MockAuthenticatorManager::MockAuthenticatorManager):
     17        * UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.h:
     18        * UIProcess/WebAuthentication/Mock/MockHidConnection.cpp:
     19        (WebKit::MockHidConnection::send):
     20        (WebKit::MockHidConnection::registerDataReceivedCallbackInternal):
     21        (WebKit::MockHidConnection::parseRequest):
     22        (WebKit::MockHidConnection::feedReports):
     23        (WebKit::MockHidConnection::shouldContinueFeedReports):
     24        * UIProcess/WebAuthentication/Mock/MockHidConnection.h:
     25        * UIProcess/WebAuthentication/Mock/MockHidService.cpp:
     26        (WebKit::MockHidService::MockHidService):
     27        * UIProcess/WebAuthentication/Mock/MockHidService.h:
     28        * UIProcess/WebAuthentication/Mock/MockLocalConnection.h:
     29        * UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:
     30        (WebKit::MockLocalConnection::MockLocalConnection):
     31        * UIProcess/WebAuthentication/Mock/MockLocalService.h:
     32        * UIProcess/WebAuthentication/Mock/MockLocalService.mm:
     33        (WebKit::MockLocalService::MockLocalService):
     34        * UIProcess/WebAuthentication/Mock/MockNfcService.h:
     35        * UIProcess/WebAuthentication/Mock/MockNfcService.mm:
     36        (WebKit::MockNfcService::MockNfcService):
     37        (WebKit::MockNfcService::platformStartDiscovery):
     38        (WebKit::MockNfcService::detectTags const):
     39        * UIProcess/WebAuthentication/Mock/MockWebAuthenticationConfiguration.h: Removed.
     40        * UIProcess/WebPageProxy.cpp:
     41        (WebKit::WebPageProxy::setMockWebAuthenticationConfiguration):
     42        * UIProcess/WebPageProxy.h:
     43        * UIProcess/WebPageProxy.messages.in:
     44        * UIProcess/WebsiteData/WebsiteDataStore.h:
     45        * WebKit.xcodeproj/project.pbxproj:
     46        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     47        (WebKit::WebChromeClient::setMockWebAuthenticationConfiguration):
     48        * WebProcess/WebCoreSupport/WebChromeClient.h:
     49
    1502019-10-09  Andy Estes  <aestes@apple.com>
    251
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp

    r250804 r250940  
    2929#include "APIArray.h"
    3030#include "APIHTTPCookieStore.h"
    31 #include "MockWebAuthenticationConfiguration.h"
    3231#include "ShouldGrandfatherStatistics.h"
    3332#include "WKAPICast.h"
     
    659658}
    660659
    661 void WKWebsiteDataStoreSetWebAuthenticationMockConfiguration(WKWebsiteDataStoreRef dataStoreRef, WKDictionaryRef configurationRef)
    662 {
    663 #if ENABLE(WEB_AUTHN)
    664     WebKit::MockWebAuthenticationConfiguration configuration;
    665 
    666     if (auto silentFailureRef = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(configurationRef, adoptWK(WKStringCreateWithUTF8CString("SilentFailure")).get())))
    667         configuration.silentFailure = WKBooleanGetValue(silentFailureRef);
    668 
    669     if (auto localRef = static_cast<WKDictionaryRef>(WKDictionaryGetItemForKey(configurationRef, adoptWK(WKStringCreateWithUTF8CString("Local")).get()))) {
    670         WebKit::MockWebAuthenticationConfiguration::Local local;
    671         local.acceptAuthentication = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(localRef, adoptWK(WKStringCreateWithUTF8CString("AcceptAuthentication")).get())));
    672         local.acceptAttestation = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(localRef, adoptWK(WKStringCreateWithUTF8CString("AcceptAttestation")).get())));
    673         if (local.acceptAttestation) {
    674             local.privateKeyBase64 = WebKit::toImpl(static_cast<WKStringRef>(WKDictionaryGetItemForKey(localRef, adoptWK(WKStringCreateWithUTF8CString("PrivateKeyBase64")).get())))->string();
    675             local.userCertificateBase64 = WebKit::toImpl(static_cast<WKStringRef>(WKDictionaryGetItemForKey(localRef, adoptWK(WKStringCreateWithUTF8CString("UserCertificateBase64")).get())))->string();
    676             local.intermediateCACertificateBase64 = WebKit::toImpl(static_cast<WKStringRef>(WKDictionaryGetItemForKey(localRef, adoptWK(WKStringCreateWithUTF8CString("IntermediateCACertificateBase64")).get())))->string();
    677         }
    678         if (auto preferredUserhandleBase64Ref = static_cast<WKStringRef>(WKDictionaryGetItemForKey(localRef, adoptWK(WKStringCreateWithUTF8CString("PreferredUserhandleBase64")).get())))
    679             local.preferredUserhandleBase64 = WebKit::toImpl(preferredUserhandleBase64Ref)->string();
    680         configuration.local = WTFMove(local);
    681     }
    682 
    683     if (auto hidRef = static_cast<WKDictionaryRef>(WKDictionaryGetItemForKey(configurationRef, adoptWK(WKStringCreateWithUTF8CString("Hid")).get()))) {
    684         WebKit::MockWebAuthenticationConfiguration::Hid hid;
    685 
    686         auto stage = WebKit::toImpl(static_cast<WKStringRef>(WKDictionaryGetItemForKey(hidRef, adoptWK(WKStringCreateWithUTF8CString("Stage")).get())))->string();
    687         if (stage == "info")
    688             hid.stage = WebKit::MockWebAuthenticationConfiguration::Hid::Stage::Info;
    689         else if (stage == "request")
    690             hid.stage = WebKit::MockWebAuthenticationConfiguration::Hid::Stage::Request;
    691 
    692         auto subStage = WebKit::toImpl(static_cast<WKStringRef>(WKDictionaryGetItemForKey(hidRef, adoptWK(WKStringCreateWithUTF8CString("SubStage")).get())))->string();
    693         if (subStage == "init")
    694             hid.subStage = WebKit::MockWebAuthenticationConfiguration::Hid::SubStage::Init;
    695         else if (subStage == "msg")
    696             hid.subStage = WebKit::MockWebAuthenticationConfiguration::Hid::SubStage::Msg;
    697 
    698         auto error = WebKit::toImpl(static_cast<WKStringRef>(WKDictionaryGetItemForKey(hidRef, adoptWK(WKStringCreateWithUTF8CString("Error")).get())))->string();
    699         if (error == "success")
    700             hid.error = WebKit::MockWebAuthenticationConfiguration::Hid::Error::Success;
    701         else if (error == "data-not-sent")
    702             hid.error = WebKit::MockWebAuthenticationConfiguration::Hid::Error::DataNotSent;
    703         else if (error == "empty-report")
    704             hid.error = WebKit::MockWebAuthenticationConfiguration::Hid::Error::EmptyReport;
    705         else if (error == "wrong-channel-id")
    706             hid.error = WebKit::MockWebAuthenticationConfiguration::Hid::Error::WrongChannelId;
    707         else if (error == "malicious-payload")
    708             hid.error = WebKit::MockWebAuthenticationConfiguration::Hid::Error::MaliciousPayload;
    709         else if (error == "unsupported-options")
    710             hid.error = WebKit::MockWebAuthenticationConfiguration::Hid::Error::UnsupportedOptions;
    711         else if (error == "wrong-nonce")
    712             hid.error = WebKit::MockWebAuthenticationConfiguration::Hid::Error::WrongNonce;
    713 
    714         if (auto payloadBase64 = static_cast<WKArrayRef>(WKDictionaryGetItemForKey(hidRef, adoptWK(WKStringCreateWithUTF8CString("PayloadBase64")).get())))
    715             hid.payloadBase64 = WebKit::toImpl(payloadBase64)->toStringVector();
    716 
    717         if (auto isU2f = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(hidRef, adoptWK(WKStringCreateWithUTF8CString("IsU2f")).get())))
    718             hid.isU2f = WKBooleanGetValue(isU2f);
    719 
    720         if (auto keepAlive = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(hidRef, adoptWK(WKStringCreateWithUTF8CString("KeepAlive")).get())))
    721             hid.keepAlive = WKBooleanGetValue(keepAlive);
    722 
    723         if (auto fastDataArrival = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(hidRef, adoptWK(WKStringCreateWithUTF8CString("FastDataArrival")).get())))
    724             hid.fastDataArrival = WKBooleanGetValue(fastDataArrival);
    725 
    726         if (auto continueAfterErrorData = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(hidRef, adoptWK(WKStringCreateWithUTF8CString("ContinueAfterErrorData")).get())))
    727             hid.continueAfterErrorData = WKBooleanGetValue(continueAfterErrorData);
    728 
    729         if (auto canDowngrade = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(hidRef, adoptWK(WKStringCreateWithUTF8CString("CanDowngrade")).get())))
    730             hid.canDowngrade = WKBooleanGetValue(canDowngrade);
    731 
    732         configuration.hid = WTFMove(hid);
    733     }
    734 
    735     if (auto nfcRef = static_cast<WKDictionaryRef>(WKDictionaryGetItemForKey(configurationRef, adoptWK(WKStringCreateWithUTF8CString("Nfc")).get()))) {
    736         WebKit::MockWebAuthenticationConfiguration::Nfc nfc;
    737 
    738         auto error = WebKit::toImpl(static_cast<WKStringRef>(WKDictionaryGetItemForKey(nfcRef, adoptWK(WKStringCreateWithUTF8CString("Error")).get())))->string();
    739         if (error == "success")
    740             nfc.error = WebKit::MockWebAuthenticationConfiguration::Nfc::Error::Success;
    741         else if (error == "no-tags")
    742             nfc.error = WebKit::MockWebAuthenticationConfiguration::Nfc::Error::NoTags;
    743         else if (error == "wrong-tag-type")
    744             nfc.error = WebKit::MockWebAuthenticationConfiguration::Nfc::Error::WrongTagType;
    745         else if (error == "no-connections")
    746             nfc.error = WebKit::MockWebAuthenticationConfiguration::Nfc::Error::NoConnections;
    747         else if (error == "malicious-payload")
    748             nfc.error = WebKit::MockWebAuthenticationConfiguration::Nfc::Error::MaliciousPayload;
    749 
    750         if (auto payloadBase64 = static_cast<WKArrayRef>(WKDictionaryGetItemForKey(nfcRef, adoptWK(WKStringCreateWithUTF8CString("PayloadBase64")).get())))
    751             nfc.payloadBase64 = WebKit::toImpl(payloadBase64)->toStringVector();
    752 
    753         if (auto multipleTags = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(nfcRef, adoptWK(WKStringCreateWithUTF8CString("MultipleTags")).get())))
    754             nfc.multipleTags = WKBooleanGetValue(multipleTags);
    755 
    756         configuration.nfc = WTFMove(nfc);
    757     }
    758 
    759     WebKit::toImpl(dataStoreRef)->setMockWebAuthenticationConfiguration(WTFMove(configuration));
    760 #endif
    761 }
    762 
    763660void WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemoval(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemovalFunction callback)
    764661{
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h

    r250804 r250940  
    144144WK_EXPORT void WKWebsiteDataStoreSetPerOriginStorageQuota(WKWebsiteDataStoreRef dataStoreRef, uint64_t quota) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKWebsiteDataStoreConfigurationSetPerOriginStorageQuota);
    145145
    146 WK_EXPORT void WKWebsiteDataStoreSetWebAuthenticationMockConfiguration(WKWebsiteDataStoreRef dataStoreRef, WKDictionaryRef configuration);
    147 
    148146WK_EXPORT void WKWebsiteDataStoreClearAllDeviceOrientationPermissions(WKWebsiteDataStoreRef dataStoreRef);
    149147
  • trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorTransportService.cpp

    r249108 r250940  
    5454}
    5555
    56 UniqueRef<AuthenticatorTransportService> AuthenticatorTransportService::createMock(WebCore::AuthenticatorTransport transport, Observer& observer, const MockWebAuthenticationConfiguration& configuration)
     56UniqueRef<AuthenticatorTransportService> AuthenticatorTransportService::createMock(WebCore::AuthenticatorTransport transport, Observer& observer, const WebCore::MockWebAuthenticationConfiguration& configuration)
    5757{
    5858    switch (transport) {
  • trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorTransportService.h

    r238166 r250940  
    3232#include <wtf/WeakPtr.h>
    3333
     34namespace WebCore {
     35struct MockWebAuthenticationConfiguration;
     36}
     37
    3438namespace WebKit {
    3539
    3640class Authenticator;
    37 
    38 struct MockWebAuthenticationConfiguration;
    3941
    4042class AuthenticatorTransportService : public CanMakeWeakPtr<AuthenticatorTransportService> {
     
    5052
    5153    static UniqueRef<AuthenticatorTransportService> create(WebCore::AuthenticatorTransport, Observer&);
    52     static UniqueRef<AuthenticatorTransportService> createMock(WebCore::AuthenticatorTransport, Observer&, const MockWebAuthenticationConfiguration&);
     54    static UniqueRef<AuthenticatorTransportService> createMock(WebCore::AuthenticatorTransport, Observer&, const WebCore::MockWebAuthenticationConfiguration&);
    5355
    5456    virtual ~AuthenticatorTransportService() = default;
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp

    r250729 r250940  
    3131namespace WebKit {
    3232
    33 MockAuthenticatorManager::MockAuthenticatorManager(MockWebAuthenticationConfiguration&& configuration)
     33MockAuthenticatorManager::MockAuthenticatorManager(WebCore::MockWebAuthenticationConfiguration&& configuration)
    3434    : m_testConfiguration(WTFMove(configuration))
    3535{
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.h

    r236481 r250940  
    2929
    3030#include "AuthenticatorManager.h"
    31 #include "MockWebAuthenticationConfiguration.h"
     31#include <WebCore/MockWebAuthenticationConfiguration.h>
    3232
    3333namespace WebKit {
     
    3535class MockAuthenticatorManager final : public AuthenticatorManager {
    3636public:
    37     explicit MockAuthenticatorManager(MockWebAuthenticationConfiguration&&);
     37    explicit MockAuthenticatorManager(WebCore::MockWebAuthenticationConfiguration&&);
    3838
    3939    bool isMock() const final { return true; }
    40     void setTestConfiguration(MockWebAuthenticationConfiguration&& configuration) { m_testConfiguration = WTFMove(configuration); }
     40    void setTestConfiguration(WebCore::MockWebAuthenticationConfiguration&& configuration) { m_testConfiguration = WTFMove(configuration); }
    4141
    4242private:
     
    4444    void respondReceivedInternal(Respond&&) final;
    4545
    46     MockWebAuthenticationConfiguration m_testConfiguration;
     46    WebCore::MockWebAuthenticationConfiguration m_testConfiguration;
    4747};
    4848
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockHidConnection.cpp

    r249108 r250940  
    3939
    4040namespace WebKit {
    41 using MockHid = MockWebAuthenticationConfiguration::Hid;
     41using Mock = WebCore::MockWebAuthenticationConfiguration;
    4242using namespace WebCore;
    4343using namespace cbor;
     
    8383
    8484            auto sent = DataSent::Yes;
    85             if (weakThis->stagesMatch() && weakThis->m_configuration.hid->error == MockHid::Error::DataNotSent)
     85            if (weakThis->stagesMatch() && weakThis->m_configuration.hid->error == Mock::HidError::DataNotSent)
    8686                sent = DataSent::No;
    8787            callback(sent);
     
    9393void MockHidConnection::registerDataReceivedCallbackInternal()
    9494{
    95     if (stagesMatch() && m_configuration.hid->error == MockHid::Error::EmptyReport) {
     95    if (stagesMatch() && m_configuration.hid->error == Mock::HidError::EmptyReport) {
    9696        receiveReport({ });
    9797        shouldContinueFeedReports();
     
    124124    if (m_requestMessage->cmd() == FidoHidDeviceCommand::kInit) {
    125125        auto previousSubStage = m_subStage;
    126         m_subStage = MockHid::SubStage::Init;
    127         if (previousSubStage == MockHid::SubStage::Msg)
    128             m_stage = MockHid::Stage::Request;
     126        m_subStage = Mock::HidSubStage::Init;
     127        if (previousSubStage == Mock::HidSubStage::Msg)
     128            m_stage = Mock::HidStage::Request;
    129129    }
    130130    if (m_requestMessage->cmd() == FidoHidDeviceCommand::kCbor || m_requestMessage->cmd() == FidoHidDeviceCommand::kMsg)
    131         m_subStage = MockHid::SubStage::Msg;
    132 
    133     if (m_stage == MockHid::Stage::Request && m_subStage == MockHid::SubStage::Msg) {
     131        m_subStage = Mock::HidSubStage::Msg;
     132
     133    if (m_stage == Mock::HidStage::Request && m_subStage == Mock::HidSubStage::Msg) {
    134134        // Make sure we issue different msg cmd for CTAP and U2F.
    135135        if (m_configuration.hid->canDowngrade && !m_configuration.hid->isU2f)
     
    177177
    178178    // Store nonce.
    179     if (m_subStage == MockHid::SubStage::Init) {
     179    if (m_subStage == Mock::HidSubStage::Init) {
    180180        m_nonce = m_requestMessage->getMessagePayload();
    181181        ASSERT(m_nonce.size() == kHidInitNonceLength);
     
    192192    using namespace MockHidConnectionInternal;
    193193
    194     if (m_subStage == MockHid::SubStage::Init) {
     194    if (m_subStage == Mock::HidSubStage::Init) {
    195195        Vector<uint8_t> payload;
    196196        payload.reserveInitialCapacity(kHidInitResponseSize);
    197197        payload.appendVector(m_nonce);
    198198        size_t writePosition = payload.size();
    199         if (stagesMatch() && m_configuration.hid->error == MockHid::Error::WrongNonce)
     199        if (stagesMatch() && m_configuration.hid->error == Mock::HidError::WrongNonce)
    200200            payload[0]--;
    201201        payload.grow(kHidInitResponseSize);
    202202        cryptographicallyRandomValues(payload.data() + writePosition, CtapChannelIdSize);
    203203        auto channel = kHidBroadcastChannel;
    204         if (stagesMatch() && m_configuration.hid->error == MockHid::Error::WrongChannelId)
     204        if (stagesMatch() && m_configuration.hid->error == Mock::HidError::WrongChannelId)
    205205            channel--;
    206206        FidoHidInitPacket initPacket(channel, FidoHidDeviceCommand::kInit, WTFMove(payload), payload.size());
     
    211211
    212212    Optional<FidoHidMessage> message;
    213     if (m_stage == MockHid::Stage::Info && m_subStage == MockHid::SubStage::Msg) {
     213    if (m_stage == Mock::HidStage::Info && m_subStage == Mock::HidSubStage::Msg) {
    214214        Vector<uint8_t> infoData;
    215215        if (m_configuration.hid->canDowngrade)
     
    218218            infoData = encodeAsCBOR(AuthenticatorGetInfoResponse({ ProtocolVersion::kCtap }, Vector<uint8_t>(aaguidLength, 0u)));
    219219        infoData.insert(0, static_cast<uint8_t>(CtapDeviceResponseCode::kSuccess)); // Prepend status code.
    220         if (stagesMatch() && m_configuration.hid->error == MockHid::Error::WrongChannelId)
     220        if (stagesMatch() && m_configuration.hid->error == Mock::HidError::WrongChannelId)
    221221            message = FidoHidMessage::create(m_currentChannel - 1, FidoHidDeviceCommand::kCbor, infoData);
    222222        else {
     
    228228    }
    229229
    230     if (m_stage == MockHid::Stage::Request && m_subStage == MockHid::SubStage::Msg) {
     230    if (m_stage == Mock::HidStage::Request && m_subStage == Mock::HidSubStage::Msg) {
    231231        if (m_configuration.hid->keepAlive) {
    232232            m_configuration.hid->keepAlive = false;
     
    236236            return;
    237237        }
    238         if (stagesMatch() && m_configuration.hid->error == MockHid::Error::UnsupportedOptions && (m_requireResidentKey || m_requireUserVerification))
     238        if (stagesMatch() && m_configuration.hid->error == Mock::HidError::UnsupportedOptions && (m_requireResidentKey || m_requireUserVerification))
    239239            message = FidoHidMessage::create(m_currentChannel, FidoHidDeviceCommand::kCbor, { static_cast<uint8_t>(CtapDeviceResponseCode::kCtap2ErrUnsupportedOption) });
    240240        else {
     
    255255    while (message->numPackets()) {
    256256        auto report = message->popNextPacket();
    257         if (!isFirst && stagesMatch() && m_configuration.hid->error == MockHid::Error::WrongChannelId)
     257        if (!isFirst && stagesMatch() && m_configuration.hid->error == Mock::HidError::WrongChannelId)
    258258            report = FidoHidContinuationPacket(m_currentChannel - 1, 0, { }).getSerializedData();
    259259        // Packets are feed asynchronously to mimic actual data transmission.
     
    277277        return;
    278278    m_configuration.hid->continueAfterErrorData = false;
    279     m_configuration.hid->error = MockHid::Error::Success;
     279    m_configuration.hid->error = Mock::HidError::Success;
    280280    continueFeedReports();
    281281}
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockHidConnection.h

    r249108 r250940  
    2929
    3030#include "HidConnection.h"
    31 #include "MockWebAuthenticationConfiguration.h"
    3231#include <WebCore/FidoHidMessage.h>
     32#include <WebCore/MockWebAuthenticationConfiguration.h>
    3333#include <wtf/WeakPtr.h>
    3434
     
    4646class MockHidConnection final : public CanMakeWeakPtr<MockHidConnection>, public HidConnection {
    4747public:
    48     MockHidConnection(IOHIDDeviceRef, const MockWebAuthenticationConfiguration&);
     48    MockHidConnection(IOHIDDeviceRef, const WebCore::MockWebAuthenticationConfiguration&);
    4949
    5050private:
     
    6161    void continueFeedReports();
    6262
    63     MockWebAuthenticationConfiguration m_configuration;
     63    WebCore::MockWebAuthenticationConfiguration m_configuration;
    6464    Optional<fido::FidoHidMessage> m_requestMessage;
    65     MockWebAuthenticationConfiguration::Hid::Stage m_stage { MockWebAuthenticationConfiguration::Hid::Stage::Info };
    66     MockWebAuthenticationConfiguration::Hid::SubStage m_subStage { MockWebAuthenticationConfiguration::Hid::SubStage::Init };
     65    WebCore::MockWebAuthenticationConfiguration::HidStage m_stage { MockWebAuthenticationConfiguration::HidStage::Info };
     66    WebCore::MockWebAuthenticationConfiguration::HidSubStage m_subStage { MockWebAuthenticationConfiguration::HidSubStage::Init };
    6767    uint32_t m_currentChannel { fido::kHidBroadcastChannel };
    6868    bool m_requireResidentKey { false };
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockHidService.cpp

    r249108 r250940  
    3434namespace WebKit {
    3535
    36 MockHidService::MockHidService(Observer& observer, const MockWebAuthenticationConfiguration& configuration)
     36MockHidService::MockHidService(Observer& observer, const WebCore::MockWebAuthenticationConfiguration& configuration)
    3737    : HidService(observer)
    3838    , m_configuration(configuration)
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockHidService.h

    r249108 r250940  
    2929
    3030#include "HidService.h"
    31 #include "MockWebAuthenticationConfiguration.h"
     31#include <WebCore/MockWebAuthenticationConfiguration.h>
    3232
    3333namespace WebKit {
    34 
    35 struct MockWebAuthenticationConfiguration;
    3634
    3735class MockHidService final : public HidService {
     
    4341    UniqueRef<HidConnection> createHidConnection(IOHIDDeviceRef) const final;
    4442
    45     MockWebAuthenticationConfiguration m_configuration;
     43    WebCore::MockWebAuthenticationConfiguration m_configuration;
    4644};
    4745
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h

    r250249 r250940  
    2929
    3030#include "LocalConnection.h"
    31 #include "MockWebAuthenticationConfiguration.h"
     31#include <WebCore/MockWebAuthenticationConfiguration.h>
    3232
    3333namespace WebKit {
     
    3535class MockLocalConnection final : public LocalConnection {
    3636public:
    37     explicit MockLocalConnection(const MockWebAuthenticationConfiguration&);
     37    explicit MockLocalConnection(const WebCore::MockWebAuthenticationConfiguration&);
    3838
    3939private:
     
    4343    NSDictionary *selectCredential(const NSArray *) const final;
    4444
    45     MockWebAuthenticationConfiguration m_configuration;
     45    WebCore::MockWebAuthenticationConfiguration m_configuration;
    4646};
    4747
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.mm

    r250249 r250940  
    3737namespace WebKit {
    3838
    39 MockLocalConnection::MockLocalConnection(const MockWebAuthenticationConfiguration& configuration)
     39MockLocalConnection::MockLocalConnection(const WebCore::MockWebAuthenticationConfiguration& configuration)
    4040    : m_configuration(configuration)
    4141{
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalService.h

    r236481 r250940  
    2929
    3030#include "LocalService.h"
    31 #include "MockWebAuthenticationConfiguration.h"
     31#include <WebCore/MockWebAuthenticationConfiguration.h>
    3232
    3333namespace WebKit {
    3434
    35 struct MockWebAuthenticationConfiguration;
    36 
    3735class MockLocalService final : public LocalService {
    3836public:
    39     MockLocalService(Observer&, const MockWebAuthenticationConfiguration&);
     37    MockLocalService(Observer&, const WebCore::MockWebAuthenticationConfiguration&);
    4038
    4139private:
     
    4341    UniqueRef<LocalConnection> createLocalConnection() const final;
    4442
    45     MockWebAuthenticationConfiguration m_configuration;
     43    WebCore::MockWebAuthenticationConfiguration m_configuration;
    4644};
    4745
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalService.mm

    r238166 r250940  
    3434namespace WebKit {
    3535
    36 MockLocalService::MockLocalService(Observer& observer, const MockWebAuthenticationConfiguration& configuration)
     36MockLocalService::MockLocalService(Observer& observer, const WebCore::MockWebAuthenticationConfiguration& configuration)
    3737    : LocalService(observer)
    3838    , m_configuration(configuration)
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockNfcService.h

    r249059 r250940  
    2828#if ENABLE(WEB_AUTHN)
    2929
    30 #include "MockWebAuthenticationConfiguration.h"
    3130#include "NfcService.h"
     31#include <WebCore/MockWebAuthenticationConfiguration.h>
    3232
    3333OBJC_CLASS NSData;
     
    3535namespace WebKit {
    3636
    37 struct MockWebAuthenticationConfiguration;
    38 
    3937class MockNfcService final : public NfcService {
    4038public:
    41     MockNfcService(Observer&, const MockWebAuthenticationConfiguration&);
     39    MockNfcService(Observer&, const WebCore::MockWebAuthenticationConfiguration&);
    4240
    4341    NSData* transceive();
     
    4846    void detectTags() const;
    4947
    50     MockWebAuthenticationConfiguration m_configuration;
     48    WebCore::MockWebAuthenticationConfiguration m_configuration;
    5149};
    5250
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockNfcService.mm

    r249934 r250940  
    109109namespace WebKit {
    110110using namespace fido;
    111 using MockNfc = MockWebAuthenticationConfiguration::Nfc;
     111using Mock = WebCore::MockWebAuthenticationConfiguration;
    112112
    113113#if HAVE(NEAR_FIELD)
     
    144144#endif // HAVE(NEAR_FIELD)
    145145
    146 MockNfcService::MockNfcService(Observer& observer, const MockWebAuthenticationConfiguration& configuration)
     146MockNfcService::MockNfcService(Observer& observer, const WebCore::MockWebAuthenticationConfiguration& configuration)
    147147    : NfcService(observer)
    148148    , m_configuration(configuration)
     
    170170
    171171        Method methodToSwizzle2 = class_getInstanceMethod(getNFReaderSessionClass(), @selector(connectTag:));
    172         if (m_configuration.nfc->error == MockNfc::Error::NoConnections)
     172        if (m_configuration.nfc->error == Mock::NfcError::NoConnections)
    173173            method_setImplementation(methodToSwizzle2, (IMP)NFReaderSessionConnectTagFail);
    174174        else
     
    195195{
    196196#if HAVE(NEAR_FIELD)
    197     if (m_configuration.nfc->error == MockNfc::Error::NoTags)
     197    if (m_configuration.nfc->error == Mock::NfcError::NoTags)
    198198        return;
    199199
    200200    auto callback = makeBlockPtr([configuration = m_configuration] {
    201201        auto tags = adoptNS([[NSMutableArray alloc] init]);
    202         if (configuration.nfc->error == MockNfc::Error::WrongTagType || configuration.nfc->multipleTags)
     202        if (configuration.nfc->error == Mock::NfcError::WrongTagType || configuration.nfc->multipleTags)
    203203            [tags addObject:adoptNS([[WKMockNFTag alloc] initWithType:NFTagTypeUnknown]).get()];
    204204        else
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r250876 r250940  
    93939393#endif
    93949394
     9395#if ENABLE(WEB_AUTHN)
     9396void WebPageProxy::setMockWebAuthenticationConfiguration(MockWebAuthenticationConfiguration&& configuration)
     9397{
     9398    m_websiteDataStore->setMockWebAuthenticationConfiguration(WTFMove(configuration));
     9399}
     9400#endif
     9401
    93959402} // namespace WebKit
    93969403
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r250876 r250940  
    214214struct GlobalWindowIdentifier;
    215215struct MediaStreamRequest;
     216struct MockWebAuthenticationConfiguration;
    216217struct PrewarmInformation;
    217218struct SecurityOriginData;
     
    15881589    void maybeInitializeSandboxExtensionHandle(WebProcessProxy&, const URL&, const URL& resourceDirectoryURL, SandboxExtension::Handle&);
    15891590
     1591#if ENABLE(WEB_AUTHN)
     1592    void setMockWebAuthenticationConfiguration(WebCore::MockWebAuthenticationConfiguration&&);
     1593#endif
     1594
    15901595private:
    15911596    WebPageProxy(PageClient&, WebProcessProxy&, Ref<API::PageConfiguration>&&);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r250780 r250940  
    575575    DidCreateContextForVisibilityPropagation(WebKit::LayerHostingContextID contextID);
    576576#endif
     577
     578#if ENABLE(WEB_AUTHN)
     579    SetMockWebAuthenticationConfiguration(struct WebCore::MockWebAuthenticationConfiguration configuration);
     580#endif
    577581}
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r250804 r250940  
    6565class RegistrableDomain;
    6666class SecurityOrigin;
     67
     68struct MockWebAuthenticationConfiguration;
    6769}
    6870
     
    7981enum class WebsiteDataFetchOption;
    8082enum class WebsiteDataType;
    81 struct MockWebAuthenticationConfiguration;
    8283struct WebsiteDataRecord;
    8384struct WebsiteDataStoreParameters;
     
    253254#if ENABLE(WEB_AUTHN)
    254255    AuthenticatorManager& authenticatorManager() { return m_authenticatorManager.get(); }
    255     void setMockWebAuthenticationConfiguration(MockWebAuthenticationConfiguration&&);
     256    void setMockWebAuthenticationConfiguration(WebCore::MockWebAuthenticationConfiguration&&);
    256257#endif
    257258
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r250876 r250940  
    10741074                57DCEDB2214C604C0016B847 /* WebAuthenticationRequestData.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCEDA62149F9DA0016B847 /* WebAuthenticationRequestData.h */; };
    10751075                57DCEDB3214C60530016B847 /* WebAuthenticatorCoordinatorProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 57608295202BD8BA00116678 /* WebAuthenticatorCoordinatorProxy.h */; };
    1076                 57DCEDBF214F0DCF0016B847 /* MockWebAuthenticationConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCEDBE214CA01B0016B847 /* MockWebAuthenticationConfiguration.h */; };
    10771076                57DCEDC3214F114C0016B847 /* MockLocalService.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCEDC1214F114C0016B847 /* MockLocalService.h */; };
    10781077                57DCEDC7214F18300016B847 /* MockLocalConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCEDC5214F18300016B847 /* MockLocalConnection.h */; };
     
    35653564                57DCEDA8214A568B0016B847 /* LocalConnection.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalConnection.mm; sourceTree = "<group>"; };
    35663565                57DCEDAA214B9B430016B847 /* DeviceIdentitySPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeviceIdentitySPI.h; sourceTree = "<group>"; };
    3567                 57DCEDBE214CA01B0016B847 /* MockWebAuthenticationConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockWebAuthenticationConfiguration.h; sourceTree = "<group>"; };
    35683566                57DCEDC1214F114C0016B847 /* MockLocalService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockLocalService.h; sourceTree = "<group>"; };
    35693567                57DCEDC2214F114C0016B847 /* MockLocalService.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MockLocalService.mm; sourceTree = "<group>"; };
     
    71447142                                57B8264A230603C100B72EB0 /* MockNfcService.h */,
    71457143                                57B8264B230603C100B72EB0 /* MockNfcService.mm */,
    7146                                 57DCEDBE214CA01B0016B847 /* MockWebAuthenticationConfiguration.h */,
    71477144                        );
    71487145                        path = Mock;
     
    95849581                                57DCEDC3214F114C0016B847 /* MockLocalService.h in Headers */,
    95859582                                57B8264C230603C100B72EB0 /* MockNfcService.h in Headers */,
    9586                                 57DCEDBF214F0DCF0016B847 /* MockWebAuthenticationConfiguration.h in Headers */,
    95879583                                C0E3AA7C1209E83C00A49D01 /* Module.h in Headers */,
    95889584                                2D50366B1BCDE17900E20BB3 /* NativeWebGestureEvent.h in Headers */,
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r250717 r250940  
    9999#endif
    100100
     101#if ENABLE(WEB_AUTHN)
     102#include <WebCore/MockWebAuthenticationConfiguration.h>
     103#endif
     104
    101105namespace WebKit {
    102106using namespace WebCore;
     
    13581362}
    13591363
     1364#if ENABLE(WEB_AUTHN)
     1365void WebChromeClient::setMockWebAuthenticationConfiguration(const MockWebAuthenticationConfiguration& configuration)
     1366{
     1367    m_page.send(Messages::WebPageProxy::SetMockWebAuthenticationConfiguration(configuration));
     1368}
     1369#endif
     1370
    13601371} // namespace WebKit
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h

    r250650 r250940  
    382382    void setUserIsInteracting(bool) final;
    383383
     384#if ENABLE(WEB_AUTHN)
     385    void setMockWebAuthenticationConfiguration(const WebCore::MockWebAuthenticationConfiguration&) final;
     386#endif
     387
    384388    String m_cachedToolTip;
    385389    mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
  • trunk/Tools/ChangeLog

    r250930 r250940  
     12019-10-09  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Move the mock testing entrance to Internals
     4        https://bugs.webkit.org/show_bug.cgi?id=202560
     5        <rdar://problem/55973793>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     10        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     11        (WTR::TestRunner::setWebAuthenticationMockConfiguration): Deleted.
     12        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     13        * WebKitTestRunner/TestController.cpp:
     14        (WTR::TestController::setWebAuthenticationMockConfiguration): Deleted.
     15        * WebKitTestRunner/TestController.h:
     16        * WebKitTestRunner/TestInvocation.cpp:
     17        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     18
    1192019-10-09  Daniel Bates  <dabates@apple.com>
    220
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r250904 r250940  
    392392    void setServiceWorkerFetchTimeout(double seconds);
    393393
    394     // WebAuthN
    395     void setWebAuthenticationMockConfiguration(object configuration);
     394    // WebAuthn
    396395    void addTestKeyToKeychain(DOMString privateKeyBase64, DOMString attrLabel, DOMString applicationTagBase64);
    397396    void cleanUpKeychain(DOMString attrLabel, optional DOMString applicationTagBase64);
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r250904 r250940  
    26292629}
    26302630
    2631 // WebAuthN
    2632 void TestRunner::setWebAuthenticationMockConfiguration(JSValueRef configurationValue)
    2633 {
    2634     auto& injectedBundle = InjectedBundle::singleton();
    2635     WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(injectedBundle.page()->page());
    2636     JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
    2637     if (!JSValueIsObject(context, configurationValue))
    2638         return;
    2639     JSObjectRef configuration = JSValueToObject(context, configurationValue, 0);
    2640 
    2641     Vector<WKRetainPtr<WKStringRef>> configurationKeys;
    2642     Vector<WKRetainPtr<WKTypeRef>> configurationValues;
    2643 
    2644     JSRetainPtr<JSStringRef> silentFailurePropertyName(Adopt, JSStringCreateWithUTF8CString("silentFailure"));
    2645     JSValueRef silentFailureValue = JSObjectGetProperty(context, configuration, silentFailurePropertyName.get(), 0);
    2646     if (!JSValueIsUndefined(context, silentFailureValue)) {
    2647         if (!JSValueIsBoolean(context, silentFailureValue))
    2648             return;
    2649         bool silentFailure = JSValueToBoolean(context, silentFailureValue);
    2650         configurationKeys.append(adoptWK(WKStringCreateWithUTF8CString("SilentFailure")));
    2651         configurationValues.append(adoptWK(WKBooleanCreate(silentFailure)).get());
    2652     }
    2653 
    2654     JSRetainPtr<JSStringRef> localPropertyName(Adopt, JSStringCreateWithUTF8CString("local"));
    2655     JSValueRef localValue = JSObjectGetProperty(context, configuration, localPropertyName.get(), 0);
    2656     if (!JSValueIsUndefined(context, localValue) && !JSValueIsNull(context, localValue)) {
    2657         if (!JSValueIsObject(context, localValue))
    2658             return;
    2659         JSObjectRef local = JSValueToObject(context, localValue, 0);
    2660 
    2661         JSRetainPtr<JSStringRef> acceptAuthenticationPropertyName(Adopt, JSStringCreateWithUTF8CString("acceptAuthentication"));
    2662         JSValueRef acceptAuthenticationValue = JSObjectGetProperty(context, local, acceptAuthenticationPropertyName.get(), 0);
    2663         if (!JSValueIsBoolean(context, acceptAuthenticationValue))
    2664             return;
    2665         bool acceptAuthentication = JSValueToBoolean(context, acceptAuthenticationValue);
    2666 
    2667         JSRetainPtr<JSStringRef> acceptAttestationPropertyName(Adopt, JSStringCreateWithUTF8CString("acceptAttestation"));
    2668         JSValueRef acceptAttestationValue = JSObjectGetProperty(context, local, acceptAttestationPropertyName.get(), 0);
    2669         if (!JSValueIsBoolean(context, acceptAttestationValue))
    2670             return;
    2671         bool acceptAttestation = JSValueToBoolean(context, acceptAttestationValue);
    2672 
    2673         Vector<WKRetainPtr<WKStringRef>> localKeys;
    2674         Vector<WKRetainPtr<WKTypeRef>> localValues;
    2675         localKeys.append(adoptWK(WKStringCreateWithUTF8CString("AcceptAuthentication")));
    2676         localValues.append(adoptWK(WKBooleanCreate(acceptAuthentication)).get());
    2677         localKeys.append(adoptWK(WKStringCreateWithUTF8CString("AcceptAttestation")));
    2678         localValues.append(adoptWK(WKBooleanCreate(acceptAttestation)).get());
    2679 
    2680         if (acceptAttestation) {
    2681             JSRetainPtr<JSStringRef> privateKeyBase64PropertyName(Adopt, JSStringCreateWithUTF8CString("privateKeyBase64"));
    2682             JSValueRef privateKeyBase64Value = JSObjectGetProperty(context, local, privateKeyBase64PropertyName.get(), 0);
    2683             if (!JSValueIsString(context, privateKeyBase64Value))
    2684                 return;
    2685 
    2686             JSRetainPtr<JSStringRef> userCertificateBase64PropertyName(Adopt, JSStringCreateWithUTF8CString("userCertificateBase64"));
    2687             JSValueRef userCertificateBase64Value = JSObjectGetProperty(context, local, userCertificateBase64PropertyName.get(), 0);
    2688             if (!JSValueIsString(context, userCertificateBase64Value))
    2689                 return;
    2690 
    2691             JSRetainPtr<JSStringRef> intermediateCACertificateBase64PropertyName(Adopt, JSStringCreateWithUTF8CString("intermediateCACertificateBase64"));
    2692             JSValueRef intermediateCACertificateBase64Value = JSObjectGetProperty(context, local, intermediateCACertificateBase64PropertyName.get(), 0);
    2693             if (!JSValueIsString(context, intermediateCACertificateBase64Value))
    2694                 return;
    2695 
    2696             localKeys.append(adoptWK(WKStringCreateWithUTF8CString("PrivateKeyBase64")));
    2697             localValues.append(toWK(adopt(JSValueToStringCopy(context, privateKeyBase64Value, 0)).get()));
    2698             localKeys.append(adoptWK(WKStringCreateWithUTF8CString("UserCertificateBase64")));
    2699             localValues.append(toWK(adopt(JSValueToStringCopy(context, userCertificateBase64Value, 0)).get()));
    2700             localKeys.append(adoptWK(WKStringCreateWithUTF8CString("IntermediateCACertificateBase64")));
    2701             localValues.append(toWK(adopt(JSValueToStringCopy(context, intermediateCACertificateBase64Value, 0)).get()));
    2702         }
    2703 
    2704         JSRetainPtr<JSStringRef> preferredUserhandleBase64PropertyName(Adopt, JSStringCreateWithUTF8CString("preferredUserhandleBase64"));
    2705         JSValueRef preferredUserhandleBase64Value = JSObjectGetProperty(context, local, preferredUserhandleBase64PropertyName.get(), 0);
    2706         if (!JSValueIsUndefined(context, preferredUserhandleBase64Value) && !JSValueIsNull(context, preferredUserhandleBase64Value)) {
    2707             if (!JSValueIsString(context, preferredUserhandleBase64Value))
    2708                 return;
    2709 
    2710             localKeys.append(adoptWK(WKStringCreateWithUTF8CString("PreferredUserhandleBase64")));
    2711             localValues.append(toWK(adopt(JSValueToStringCopy(context, preferredUserhandleBase64Value, 0)).get()));
    2712         }
    2713 
    2714         Vector<WKStringRef> rawLocalKeys;
    2715         Vector<WKTypeRef> rawLocalValues;
    2716         rawLocalKeys.resize(localKeys.size());
    2717         rawLocalValues.resize(localValues.size());
    2718         for (size_t i = 0; i < localKeys.size(); ++i) {
    2719             rawLocalKeys[i] = localKeys[i].get();
    2720             rawLocalValues[i] = localValues[i].get();
    2721         }
    2722 
    2723         configurationKeys.append(adoptWK(WKStringCreateWithUTF8CString("Local")));
    2724         configurationValues.append(adoptWK(WKDictionaryCreate(rawLocalKeys.data(), rawLocalValues.data(), rawLocalKeys.size())));
    2725     }
    2726 
    2727     JSRetainPtr<JSStringRef> hidPropertyName(Adopt, JSStringCreateWithUTF8CString("hid"));
    2728     JSValueRef hidValue = JSObjectGetProperty(context, configuration, hidPropertyName.get(), 0);
    2729     if (!JSValueIsUndefined(context, hidValue) && !JSValueIsNull(context, hidValue)) {
    2730         if (!JSValueIsObject(context, hidValue))
    2731             return;
    2732         JSObjectRef hid = JSValueToObject(context, hidValue, 0);
    2733 
    2734         JSRetainPtr<JSStringRef> stagePropertyName(Adopt, JSStringCreateWithUTF8CString("stage"));
    2735         JSValueRef stageValue = JSObjectGetProperty(context, hid, stagePropertyName.get(), 0);
    2736         if (!JSValueIsString(context, stageValue))
    2737             return;
    2738 
    2739         JSRetainPtr<JSStringRef> subStagePropertyName(Adopt, JSStringCreateWithUTF8CString("subStage"));
    2740         JSValueRef subStageValue = JSObjectGetProperty(context, hid, subStagePropertyName.get(), 0);
    2741         if (!JSValueIsString(context, subStageValue))
    2742             return;
    2743 
    2744         JSRetainPtr<JSStringRef> errorPropertyName(Adopt, JSStringCreateWithUTF8CString("error"));
    2745         JSValueRef errorValue = JSObjectGetProperty(context, hid, errorPropertyName.get(), 0);
    2746         if (!JSValueIsString(context, errorValue))
    2747             return;
    2748 
    2749         Vector<WKRetainPtr<WKStringRef>> hidKeys;
    2750         Vector<WKRetainPtr<WKTypeRef>> hidValues;
    2751         hidKeys.append(adoptWK(WKStringCreateWithUTF8CString("Stage")));
    2752         hidValues.append(toWK(adopt(JSValueToStringCopy(context, stageValue, 0)).get()));
    2753         hidKeys.append(adoptWK(WKStringCreateWithUTF8CString("SubStage")));
    2754         hidValues.append(toWK(adopt(JSValueToStringCopy(context, subStageValue, 0)).get()));
    2755         hidKeys.append(adoptWK(WKStringCreateWithUTF8CString("Error")));
    2756         hidValues.append(toWK(adopt(JSValueToStringCopy(context, errorValue, 0)).get()));
    2757 
    2758         JSRetainPtr<JSStringRef> payloadBase64PropertyName(Adopt, JSStringCreateWithUTF8CString("payloadBase64"));
    2759         JSValueRef payloadBase64Value = JSObjectGetProperty(context, hid, payloadBase64PropertyName.get(), 0);
    2760         if (!JSValueIsUndefined(context, payloadBase64Value) && !JSValueIsNull(context, payloadBase64Value)) {
    2761             if (!JSValueIsArray(context, payloadBase64Value))
    2762                 return;
    2763 
    2764             JSObjectRef payloadBase64 = JSValueToObject(context, payloadBase64Value, nullptr);
    2765             static auto lengthProperty = adopt(JSStringCreateWithUTF8CString("length"));
    2766             JSValueRef payloadBase64LengthValue = JSObjectGetProperty(context, payloadBase64, lengthProperty.get(), nullptr);
    2767             if (!JSValueIsNumber(context, payloadBase64LengthValue))
    2768                 return;
    2769 
    2770             auto payloadBase64s = adoptWK(WKMutableArrayCreate());
    2771             auto payloadBase64Length = static_cast<size_t>(JSValueToNumber(context, payloadBase64LengthValue, nullptr));
    2772             for (size_t i = 0; i < payloadBase64Length; ++i) {
    2773                 JSValueRef payloadBase64Value = JSObjectGetPropertyAtIndex(context, payloadBase64, i, nullptr);
    2774                 if (!JSValueIsString(context, payloadBase64Value))
    2775                     continue;
    2776                 WKArrayAppendItem(payloadBase64s.get(), toWK(adopt(JSValueToStringCopy(context, payloadBase64Value, 0)).get()).get());
    2777             }
    2778 
    2779             hidKeys.append(adoptWK(WKStringCreateWithUTF8CString("PayloadBase64")));
    2780             hidValues.append(payloadBase64s);
    2781         }
    2782 
    2783         JSRetainPtr<JSStringRef> isU2fPropertyName(Adopt, JSStringCreateWithUTF8CString("isU2f"));
    2784         JSValueRef isU2fValue = JSObjectGetProperty(context, hid, isU2fPropertyName.get(), 0);
    2785         if (!JSValueIsUndefined(context, isU2fValue) && !JSValueIsNull(context, isU2fValue)) {
    2786             if (!JSValueIsBoolean(context, isU2fValue))
    2787                 return;
    2788             bool isU2f = JSValueToBoolean(context, isU2fValue);
    2789             hidKeys.append(adoptWK(WKStringCreateWithUTF8CString("IsU2f")));
    2790             hidValues.append(adoptWK(WKBooleanCreate(isU2f)).get());
    2791         }
    2792 
    2793         JSRetainPtr<JSStringRef> keepAlivePropertyName(Adopt, JSStringCreateWithUTF8CString("keepAlive"));
    2794         JSValueRef keepAliveValue = JSObjectGetProperty(context, hid, keepAlivePropertyName.get(), 0);
    2795         if (!JSValueIsUndefined(context, keepAliveValue) && !JSValueIsNull(context, keepAliveValue)) {
    2796             if (!JSValueIsBoolean(context, keepAliveValue))
    2797                 return;
    2798             bool keepAlive = JSValueToBoolean(context, keepAliveValue);
    2799             hidKeys.append(adoptWK(WKStringCreateWithUTF8CString("KeepAlive")));
    2800             hidValues.append(adoptWK(WKBooleanCreate(keepAlive)).get());
    2801         }
    2802 
    2803         JSRetainPtr<JSStringRef> fastDataArrivalPropertyName(Adopt, JSStringCreateWithUTF8CString("fastDataArrival"));
    2804         JSValueRef fastDataArrivalValue = JSObjectGetProperty(context, hid, fastDataArrivalPropertyName.get(), 0);
    2805         if (!JSValueIsUndefined(context, fastDataArrivalValue) && !JSValueIsNull(context, fastDataArrivalValue)) {
    2806             if (!JSValueIsBoolean(context, fastDataArrivalValue))
    2807                 return;
    2808             bool fastDataArrival = JSValueToBoolean(context, fastDataArrivalValue);
    2809             hidKeys.append(adoptWK(WKStringCreateWithUTF8CString("FastDataArrival")));
    2810             hidValues.append(adoptWK(WKBooleanCreate(fastDataArrival)).get());
    2811         }
    2812 
    2813         JSRetainPtr<JSStringRef> continueAfterErrorDataPropertyName(Adopt, JSStringCreateWithUTF8CString("continueAfterErrorData"));
    2814         JSValueRef continueAfterErrorDataValue = JSObjectGetProperty(context, hid, continueAfterErrorDataPropertyName.get(), 0);
    2815         if (!JSValueIsUndefined(context, continueAfterErrorDataValue) && !JSValueIsNull(context, continueAfterErrorDataValue)) {
    2816             if (!JSValueIsBoolean(context, continueAfterErrorDataValue))
    2817                 return;
    2818             bool continueAfterErrorData = JSValueToBoolean(context, continueAfterErrorDataValue);
    2819             hidKeys.append(adoptWK(WKStringCreateWithUTF8CString("ContinueAfterErrorData")));
    2820             hidValues.append(adoptWK(WKBooleanCreate(continueAfterErrorData)).get());
    2821         }
    2822 
    2823         JSRetainPtr<JSStringRef> canDowngradePropertyName(Adopt, JSStringCreateWithUTF8CString("canDowngrade"));
    2824         JSValueRef canDowngradeValue = JSObjectGetProperty(context, hid, canDowngradePropertyName.get(), 0);
    2825         if (!JSValueIsUndefined(context, canDowngradeValue) && !JSValueIsNull(context, canDowngradeValue)) {
    2826             if (!JSValueIsBoolean(context, canDowngradeValue))
    2827                 return;
    2828             bool canDowngrade = JSValueToBoolean(context, canDowngradeValue);
    2829             hidKeys.append(adoptWK(WKStringCreateWithUTF8CString("CanDowngrade")));
    2830             hidValues.append(adoptWK(WKBooleanCreate(canDowngrade)).get());
    2831         }
    2832 
    2833         Vector<WKStringRef> rawHidKeys;
    2834         Vector<WKTypeRef> rawHidValues;
    2835         rawHidKeys.resize(hidKeys.size());
    2836         rawHidValues.resize(hidValues.size());
    2837         for (size_t i = 0; i < hidKeys.size(); ++i) {
    2838             rawHidKeys[i] = hidKeys[i].get();
    2839             rawHidValues[i] = hidValues[i].get();
    2840         }
    2841 
    2842         configurationKeys.append(adoptWK(WKStringCreateWithUTF8CString("Hid")));
    2843         configurationValues.append(adoptWK(WKDictionaryCreate(rawHidKeys.data(), rawHidValues.data(), rawHidKeys.size())));
    2844     }
    2845 
    2846     JSRetainPtr<JSStringRef> nfcPropertyName(Adopt, JSStringCreateWithUTF8CString("nfc"));
    2847     JSValueRef nfcValue = JSObjectGetProperty(context, configuration, nfcPropertyName.get(), 0);
    2848     if (!JSValueIsUndefined(context, nfcValue) && !JSValueIsNull(context, nfcValue)) {
    2849         if (!JSValueIsObject(context, nfcValue))
    2850             return;
    2851         JSObjectRef nfc = JSValueToObject(context, nfcValue, 0);
    2852 
    2853         JSRetainPtr<JSStringRef> errorPropertyName(Adopt, JSStringCreateWithUTF8CString("error"));
    2854         JSValueRef errorValue = JSObjectGetProperty(context, nfc, errorPropertyName.get(), 0);
    2855         if (!JSValueIsString(context, errorValue))
    2856             return;
    2857 
    2858         Vector<WKRetainPtr<WKStringRef>> nfcKeys;
    2859         Vector<WKRetainPtr<WKTypeRef>> nfcValues;
    2860         nfcKeys.append(adoptWK(WKStringCreateWithUTF8CString("Error")));
    2861         nfcValues.append(toWK(adopt(JSValueToStringCopy(context, errorValue, 0)).get()));
    2862 
    2863         JSRetainPtr<JSStringRef> payloadBase64PropertyName(Adopt, JSStringCreateWithUTF8CString("payloadBase64"));
    2864         JSValueRef payloadBase64Value = JSObjectGetProperty(context, nfc, payloadBase64PropertyName.get(), 0);
    2865         if (!JSValueIsUndefined(context, payloadBase64Value) && !JSValueIsNull(context, payloadBase64Value)) {
    2866             if (!JSValueIsArray(context, payloadBase64Value))
    2867                 return;
    2868 
    2869             JSObjectRef payloadBase64 = JSValueToObject(context, payloadBase64Value, nullptr);
    2870             static auto lengthProperty = adopt(JSStringCreateWithUTF8CString("length"));
    2871             JSValueRef payloadBase64LengthValue = JSObjectGetProperty(context, payloadBase64, lengthProperty.get(), nullptr);
    2872             if (!JSValueIsNumber(context, payloadBase64LengthValue))
    2873                 return;
    2874 
    2875             auto payloadBase64s = adoptWK(WKMutableArrayCreate());
    2876             auto payloadBase64Length = static_cast<size_t>(JSValueToNumber(context, payloadBase64LengthValue, nullptr));
    2877             for (size_t i = 0; i < payloadBase64Length; ++i) {
    2878                 JSValueRef payloadBase64Value = JSObjectGetPropertyAtIndex(context, payloadBase64, i, nullptr);
    2879                 if (!JSValueIsString(context, payloadBase64Value))
    2880                     continue;
    2881                 WKArrayAppendItem(payloadBase64s.get(), toWK(adopt(JSValueToStringCopy(context, payloadBase64Value, 0)).get()).get());
    2882             }
    2883 
    2884             nfcKeys.append(adoptWK(WKStringCreateWithUTF8CString("PayloadBase64")));
    2885             nfcValues.append(payloadBase64s);
    2886         }
    2887 
    2888         JSRetainPtr<JSStringRef> multipleTagsPropertyName(Adopt, JSStringCreateWithUTF8CString("multipleTags"));
    2889         JSValueRef multipleTagsValue = JSObjectGetProperty(context, nfc, multipleTagsPropertyName.get(), 0);
    2890         if (!JSValueIsUndefined(context, multipleTagsValue) && !JSValueIsNull(context, multipleTagsValue)) {
    2891             if (!JSValueIsBoolean(context, multipleTagsValue))
    2892                 return;
    2893             bool multipleTags = JSValueToBoolean(context, multipleTagsValue);
    2894             nfcKeys.append(adoptWK(WKStringCreateWithUTF8CString("MultipleTags")));
    2895             nfcValues.append(adoptWK(WKBooleanCreate(multipleTags)).get());
    2896         }
    2897 
    2898         Vector<WKStringRef> rawNfcKeys;
    2899         Vector<WKTypeRef> rawNfcValues;
    2900         rawNfcKeys.resize(nfcKeys.size());
    2901         rawNfcValues.resize(nfcValues.size());
    2902         for (size_t i = 0; i < nfcKeys.size(); ++i) {
    2903             rawNfcKeys[i] = nfcKeys[i].get();
    2904             rawNfcValues[i] = nfcValues[i].get();
    2905         }
    2906 
    2907         configurationKeys.append(adoptWK(WKStringCreateWithUTF8CString("Nfc")));
    2908         configurationValues.append(adoptWK(WKDictionaryCreate(rawNfcKeys.data(), rawNfcValues.data(), rawNfcKeys.size())));
    2909     }
    2910 
    2911     Vector<WKStringRef> rawConfigurationKeys;
    2912     Vector<WKTypeRef> rawConfigurationValues;
    2913     rawConfigurationKeys.resize(configurationKeys.size());
    2914     rawConfigurationValues.resize(configurationValues.size());
    2915     for (size_t i = 0; i < configurationKeys.size(); ++i) {
    2916         rawConfigurationKeys[i] = configurationKeys[i].get();
    2917         rawConfigurationValues[i] = configurationValues[i].get();
    2918     }
    2919 
    2920     WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetWebAuthenticationMockConfiguration"));
    2921     WKRetainPtr<WKDictionaryRef> messageBody = adoptWK(WKDictionaryCreate(rawConfigurationKeys.data(), rawConfigurationValues.data(), rawConfigurationKeys.size()));
    2922    
    2923     WKBundlePostSynchronousMessage(injectedBundle.bundle(), messageName.get(), messageBody.get(), nullptr);
    2924 }
    2925 
     2631// WebAuthn
    29262632void TestRunner::addTestKeyToKeychain(JSStringRef privateKeyBase64, JSStringRef attrLabel, JSStringRef applicationTagBase64)
    29272633{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r250904 r250940  
    491491
    492492    void setServiceWorkerFetchTimeout(double seconds);
    493    
    494     // WebAuthN
    495     void setWebAuthenticationMockConfiguration(JSValueRef);
     493
    496494    // FIXME(189876)
    497495    void addTestKeyToKeychain(JSStringRef privateKeyBase64, JSStringRef attrLabel, JSStringRef applicationTagBase64);
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r250852 r250940  
    36223622}
    36233623
    3624 void TestController::setWebAuthenticationMockConfiguration(WKDictionaryRef configuration)
    3625 {
    3626     WKWebsiteDataStoreSetWebAuthenticationMockConfiguration(TestController::websiteDataStore(), configuration);
    3627 }
    3628 
    36293624struct AdClickAttributionStringResultCallbackContext {
    36303625    explicit AdClickAttributionStringResultCallbackContext(TestController& controller)
  • trunk/Tools/WebKitTestRunner/TestController.h

    r250852 r250940  
    297297    void setServiceWorkerFetchTimeoutForTesting(double seconds);
    298298
    299     void setWebAuthenticationMockConfiguration(WKDictionaryRef);
    300299    void addTestKeyToKeychain(const String& privateKeyBase64, const String& attrLabel, const String& applicationTagBase64);
    301300    void cleanUpKeychain(const String& attrLabel, const String& applicationTagBase64);
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r250852 r250940  
    16311631    }
    16321632
    1633     if (WKStringIsEqualToUTF8CString(messageName, "SetWebAuthenticationMockConfiguration")) {
    1634         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
    1635         TestController::singleton().setWebAuthenticationMockConfiguration(static_cast<WKDictionaryRef>(messageBody));
    1636         return nullptr;
    1637     }
    1638 
    16391633    if (WKStringIsEqualToUTF8CString(messageName, "AddTestKeyToKeychain")) {
    16401634        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
Note: See TracChangeset for help on using the changeset viewer.