<!DOCTYPE html>
<title>Credential Manager: Trying to store a large blob that is too large.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/testdriver.js"></script>
<script src="../resources/testdriver-vendor.js"></script>
<script>
if (document.location.host != "subdomain.example.test:8443") {
document.location = "https://subdomain.example.test:8443/credentialmanagement/credentialscontainer-get-large-blob-max-size.https.html";
}
let createCredential = async t => {
let authenticator = await window.test_driver.add_virtual_authenticator({
transport: 'usb',
protocol: "ctap2_1",
hasResidentKey: true,
hasUserVerification: true,
extensions: ["largeBlob"],
isUserVerified: true,
});
t.add_cleanup(() =>
window.test_driver.remove_virtual_authenticator(authenticator));
console.log(window.origin);
return await navigator.credentials.create({publicKey: {
challenge: new Uint8Array(),
rp: {
name: "Company",
},
user: {
id: new Uint8Array(16),
name: "blobby",
displayName: "Blobby Johnson",
},
authenticatorSelection: {
requireResidentKey: true,
},
pubKeyCredParams: [{
type: "public-key",
alg: -7,
},{
type: "public-key",
alg: -257,
}],
extensions: {
largeBlob: {
support: "required",
},
},
}});
};
promise_test(async t => {
const credential = await createCredential(t);
const blob_2k = new Uint8Array(2048);
const assertion = await navigator.credentials.get({publicKey: {
challenge: new Uint8Array(),
allowCredentials: [{
id: credential.rawId,
type: "public-key",
}],
extensions: {
largeBlob: {
write: blob_2k,
},
},
}});
assert_true(assertion.getClientExtensionResults().largeBlob.written);
}, "Store a large blob that is 2kb");
promise_test(async t => {
const credential = await createCredential(t);
const blob_too_large = new Uint8Array(2049);
const assertion = navigator.credentials.get({publicKey: {
challenge: new Uint8Array(),
allowCredentials: [{
id: credential.rawId,
type: "public-key",
}],
extensions: {
largeBlob: {
write: blob_too_large,
},
},
}});
return promise_rejects_dom(t, "NotSupportedError", assertion);
}, "Try to store a large blob that is > 2kb as a buffer view");
promise_test(async t => {
const credential = await createCredential(t);
const blob_too_large = new Uint8Array(2049);
const assertion = navigator.credentials.get({publicKey: {
challenge: new Uint8Array(),
allowCredentials: [{
id: credential.rawId,
type: "public-key",
}],
extensions: {
largeBlob: {
write: blob_too_large.buffer,
},
},
}});
return promise_rejects_dom(t, "NotSupportedError", assertion);
}, "Try to store a large blob that is > 2kb as a raw buffer");
</script>