Extension: playing audio from IndexedDB: "Content Security Policy: The page’s settings blocked the loading of a resource at blob:moz-extension://c2eb02dd-4249-724d-a725-286299b78933/7b5dea1e-5e40-b645-8217-49618e0d333a (“media-src”)."

But the same code works correctly in Chrome.

My code:

const request = window.indexedDB.open('my-database-name');
request.onsuccess = function(event) {
    const db = event.target.result;
    const objectStore = db.transaction(['audio']).objectStore('audio');
    const request = objectStore.get('my-id');
    request.onsuccess = function() {
        const url = URL.createObjectURL(request.result['blob']);
        const audio = new Audio(url);
        audio.play();
    };
};

I tried to add to manifest.json in CSP into media-src: moz-extension://c2eb02dd-4249-724d-a725-286299b78933/ without success.

Is it correct behaviour of Firefox? Is it workaroundable?

1 Like

If anything, you’d need to add media-src: blob: to the CSP (and might still want to include self).

The blob: protocol is always already restricted to the current origin.