Skip to content

Truly independent web browser

1.1 KB
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
    promiseTest(async () => {
        performance.clearResourceTimings();

        const iframe = document.createElement("iframe");
        iframe.srcdoc = "<!DOCTYPE html><title>Fallback timing</title>";
        const loaded = new Promise(resolve => iframe.addEventListener("load", resolve, { once: true }));
        document.body.appendChild(iframe);
        await loaded;

        const entries = performance.getEntriesByType("resource").filter(entry => {
            return entry.name === "about:srcdoc" && entry.initiatorType === "iframe";
        });
        println(`iframe fallback resource timing entries: ${entries.length}`);
        const entry = entries[0];
        const now = performance.now();
        println(`startTime within [0, now]: ${entry.startTime >= 0 && entry.startTime <= now}`);
        println(`responseEnd within [startTime, now]: ${entry.responseEnd >= entry.startTime && entry.responseEnd <= now}`);
        println(`duration within [0, now]: ${entry.duration >= 0 && entry.duration <= now}`);
        iframe.remove();
    });
</script>