1
0
Fork 0
firefox/toolkit/components/ml/tests/browser/browser_ml_opfs.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

34 lines
940 B
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { OPFS } = ChromeUtils.importESModule(
"chrome://global/content/ml/OPFS.sys.mjs"
);
add_task(async function test_opfs_file() {
const iconUrl = "chrome://global/content/ml/mozilla-logo.webp";
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();
});