I’m now accessing IndexedDB from my extension page and I just found out, that if I open my extension page in different container, it won’t have access to the same database!
Can I detect that the tab is opened in a container without contextualIdentities permission? (because if I know it’s container tab, I can ask my background script for data from database)
There is actually a race condition bug… if the code is called right after browser starts (if add-on page is set as homepage), then await browser.runtime.getBackgroundPage() will return null, even though it’s not a container.
And if you are “smart” like me and store the result in constant:
const IS_CONTAINER_OR_PRIVATE_TAB_PROMISE = browser.runtime.getBackgroundPage().then(bc => bc === null);
then it will keep report wrong value until you refresh the tab .
It took me two hours to track this bug down! Crazy!