chromium/third_party/blink/web_tests/http/tests/credentialmanagement/credentialscontainer-detached.html

<!DOCTYPE html>
<title>Credential Manager: invoke methods after the relevant document has been detached.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>

async_test(t => {
  let openedWindow = window.open("./resources/notify-opener-on-load.html");
  let eventWatcher = new EventWatcher(t, window, ["message"]);
  let navigatorCredentials = null;
  eventWatcher.wait_for("message")
    .then(_ => {
      navigatorCredentials = openedWindow.navigator.credentials;
      publicKeyCredential = openedWindow.PublicKeyCredential;
      OpenedWindowDOMException = openedWindow.DOMException;
      window.setTimeout(_ => openedWindow.location.reload());
      return eventWatcher.wait_for("message");
    })
  .then(t.step_func(async () => {
    await promise_rejects_dom(t, 'InvalidStateError', OpenedWindowDOMException,
        navigatorCredentials.get(),
        "navigator.credentials.get() should reject.");
    await promise_rejects_dom(t, 'InvalidStateError', OpenedWindowDOMException,
        navigatorCredentials.create(),
        "navigator.credentials.create() should reject.");
    await promise_rejects_dom(t, 'InvalidStateError', OpenedWindowDOMException,
        navigatorCredentials.store(new PasswordCredential({id: 'a', password: 'b'})),
        "navigator.credentials.store() should reject.");
    await promise_rejects_dom(t, 'InvalidStateError', OpenedWindowDOMException,
        navigatorCredentials.preventSilentAccess(),
        "navigator.credentials.preventSilentAccess() should reject.");
    await promise_rejects_dom(t, 'InvalidStateError', OpenedWindowDOMException,
        publicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable(),
        "window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() should reject.");
    await promise_rejects_dom(t, 'InvalidStateError', OpenedWindowDOMException,
        publicKeyCredential.getClientCapabilities(),
        "window.PublicKeyCredential.getClientCapabilities() should reject.");
    await promise_rejects_dom(t, 'InvalidStateError', OpenedWindowDOMException,
        publicKeyCredential.signalUnknownCredential({
          rpId: "www.example.com",
          credentialId: "AQIDBAUGBwgJCgsMDQ4PEA",
        }),
        "window.PublicKeyCredential.signalUnknownCredential() should reject.");
    await promise_rejects_dom(t, 'InvalidStateError', OpenedWindowDOMException,
        publicKeyCredential.signalAllAcceptedCredentials({
          rpId: "www.example.com",
          userId: "AQIDBA",
          allAcceptedCredentialIds: [],
        }),
        "window.PublicKeyCredential.signalAllAcceptedCredentials() should reject.");
    await promise_rejects_dom(t, 'InvalidStateError', OpenedWindowDOMException,
        publicKeyCredential.signalCurrentUserDetails({
          rpId: "www.example.com",
          userId: "AQIDBA",
          name: "Aang",
          displayName: "Avatar",
        }),
        "window.PublicKeyCredential.signalCurrentUserDetails() should reject.");
    t.done();
   }));
});

</script>