Newer
Older
minerva / Tests / LibWeb / Text / input / css / FontFace-binary-data.html
@minerva minerva on 13 Jul 1 KB Initial commit
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
    asyncTest(async (done) => {
        const badFace = new FontFace("My Cool Font", new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7]));

        await badFace.loaded.then(() => {
            println("FAILED");
        },
        () => {
            println(`badFace.status: ${badFace.status}`); // "error"
            println(`badFace.family: ${badFace.family}`); // "My Cool Font"
        });

        const zeroBytesFace = new FontFace("Empty Font", new ArrayBuffer(0));
        await zeroBytesFace.loaded.then(() => {
                println("FAILED");
            },
            () => {
                println(`zeroBytesFace.status: ${zeroBytesFace.status}`); // "error"
                println(`zeroBytesFace.family: ${zeroBytesFace.family}`); // "Empty Font"
            });

        const fontData = await fetch("../../../Ref/assets/HashSans.woff").then(
            response => response.arrayBuffer(),
            (reason) => {
                println(`FAILED to fetch font from local file ${reason}`);
                return new ArrayBuffer(0);
            });

        const hashSans = new FontFace("Hash Sans", fontData);
        await hashSans.loaded.then(() => {
            println(`face.status: ${hashSans.status}`); // "loaded"
            println(`face.family: ${hashSans.family}`); // "Hash Sans"
        },
        () => {
            println("FAILED");
        });

        done();
    });
</script>