1. Is object URL cached?
Testing in the same context, object URL was still avialable after URL.revokeObjectURL()
.
(async () => {
const str =
`export class Hi {
static log() {
console.log('Hello there!');
}
}`;
const blob = new Blob([str], {type: 'text/javascript'});
const url = URL.createObjectURL(blob);
console.log(blob); // Blob { size: 73, type: "text/javascript" }
console.log(url); // blob:null/92bfa492-...
const {Hi} = await import(url);
console.log(Hi); // class Hi {}
Hi.log(); // Hello there!
URL.revokeObjectURL(url);
// test after delay
for (let i = 1; i < 4; i++) {
const n = 10*i;
setTimeout(async () => {
console.log(`After ${n} seconds`);
const obj = await import(url);
console.log(Hi); // class Hi {}
Hi.log(); // Hello there!
}, n*1000);
}
})();
2. Is URL.revokeObjectURL()
tied to a context?
Can an object URL created in the background (or action popup) script and passed to the content script, be revoked in the content script?
Update
See also: