Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

/* Any copyright is dedicated to the Public Domain.
"use strict";
const { sinon } = ChromeUtils.importESModule(
);
const { OPFS } = ChromeUtils.importESModule(
"chrome://global/content/ml/OPFS.sys.mjs"
);
add_task(async function test_opfs_file() {
const iconUrl =
const icon = await new OPFS.File({
urls: [iconUrl],
localPath: "/icons/icon.webp",
});
let blobUrl = await icon.getAsObjectURL();
Assert.notEqual(blobUrl, null, "we got a blob url");
// second call will get it from the cache
let spy = sinon.spy(OPFS.File.prototype, "getBlobFromOPFS");
blobUrl = await icon.getAsObjectURL();
Assert.notEqual(blobUrl, null);
// check that it cames from OPFS
Assert.notEqual(await spy.lastCall.returnValue, null);
sinon.restore();
await icon.delete();
});