Use browser.storage.local API for Firefox + private mode

But only if the indexedDB is being created.

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2725
This commit is contained in:
Raymond Hill 2023-07-06 19:58:05 -04:00
parent 872eafa378
commit 5739562d10
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 10 additions and 1 deletions

View File

@ -19,7 +19,7 @@
Home: https://github.com/gorhill/uBlock
*/
/* global IDBDatabase, indexedDB */
/* global browser, IDBDatabase, indexedDB */
'use strict';
@ -179,6 +179,15 @@ const selectIDB = async function() {
return resolve(null);
}
req.onupgradeneeded = function(ev) {
// https://github.com/uBlockOrigin/uBlock-issues/issues/2725
// If context Firefox + incognito mode, fall back to
// browser.storage.local for cache storage purpose.
if (
vAPI.webextFlavor.soup.has('firefox') &&
browser.extension.inIncognitoContext === true
) {
return req.onerror();
}
if ( ev.oldVersion === 1 ) { return; }
try {
const db = ev.target.result;