From 5739562d105599ad31a92efbee6e66ca09515959 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 6 Jul 2023 19:58:05 -0400 Subject: [PATCH] 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 --- src/js/cachestorage.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/js/cachestorage.js b/src/js/cachestorage.js index eba68ed05..2c722586f 100644 --- a/src/js/cachestorage.js +++ b/src/js/cachestorage.js @@ -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;