// Load images one at atime, clearing each after decode and aframe,
// so that the cache eviction order matches the load order.
for (let i = 0; i < COUNT; i++) {
const img = await loadImage(BASE_URL + i);
await img.decode();
await new Promise(resolve => requestAnimationFrame(resolve)); img.src = "";
}
for (let i = 0; i < 10; i++) {
await new Promise(resolve => requestAnimationFrame(resolve));
}
// Load one more image to ensure all pending cache tasks have been flushed.
await loadImage(BASE_URL + COUNT);
// Check directly via the image cache API (does not modify cache state).
// Check in reverse load order since recently loaded images are most
// likely to still be cached.
const imgCache = tools.getImgCacheForDocument(document);
let directHitCount = 0;
for (let i = COUNT - 1; i >= 0; i--) {
const uri = SpecialPowers.Services.io.newURI(
new URL(BASE_URL + i, location.href).href
);
if (imgCache.findEntryProperties(uri, document)) {
directHitCount++;
}
}
ok(directHitCount <= maxCached,
`${directHitCount} images in cache (direct check), limit is ${maxCached}`);
// Count how many of the loaded images are still in the cache. Setting
// src on an element makes img.complete true synchronously only for
// cache hits. Check in reverse load order since recently loaded images
// are most likely to still be cached.
let cacheHitCount = 0;
for (let i = COUNT - 1; i >= 0; i--) {
const checkImg = document.createElement("img");
checkImg.width = 10;
checkImg.height = 10;
document.body.appendChild(checkImg);
checkImg.src = BASE_URL + i;
if (checkImg.complete) {
cacheHitCount++;
}
checkImg.src = "";
}
ok(cacheHitCount <= maxCached,
`${cacheHitCount} images remain in cache after eviction, limit is ${maxCached}`);
SimpleTest.finish();
}
runTest();
</script>
</body>
</html>
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.32 Sekunden
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.