Is it possible to have fixed URL for extension page without the random internal UUID

I am developing an addon/extension that opens extension page when user clicks icon in toolbar using ,

//background.js
browser.browserAction.onClicked.addListener(()=> {
    browser.tabs.create({
        active: true,
        url: "./my-page.html"
    })

This page is where user will spend time and I am using indexDB to store data and want to persist it between sessions.
During debugging I noticed that even though I have provided ID in browser_specific_settings in the manifest like so ,

{ 
"manifest_version": 2,
...
"browser_specific_settings": {
        "gecko": {
          "id": "<my-extension-id>",
          "strict_min_version": "42.0"
        }
     },
...
}  

when the page is opened it uses the internal UUID randomly generated everytime I load the extension by Firefox.

moz-extension://<internal-UUID>/my-page.html

Because the URL changes , I am not able to persist indexedDB storage, it’s fresh everytime.

Is it possible to somehow make the extension page open with my id instead of internal UUID? Also I am assuming that this will not be a problem when extension is installed because it will keep the internal ID as long as user doesn’t uninstall / remove it, is that correct.

Thanks in advance.

Each time you manually load the extension, it counts as a new installation, that’s why it has new UUID.
Unlike in Chrome where it’s fixed. And unlike in Safari where the UUID changes even after each browser restart!
And yes, after the release, the UUID is fixed (but still unique and random on each device).

Some workarounds I can think of:

  • don’t turn off your PC :slight_smile:, use sleep / hibernation. That way the Firefox stays running and you can continue developing.

  • create export / import feature for the IndexedDB, that way you can restore your data when you are starting developing

  • the web-ext (tool for addon development) has a special flag to keep profile changes. Although, this specific feature had some issues but I can’t remember what…

web-ext run --keep-profile-changes --firefox-profile=your-custom-profile

(but you may need to create a new profile where the addon is installed)

And lastly, note that the IndexedDB has some limitations/issues:

  • when you open your addon page in a new Firefox Container, it won’t have access to the same IndexedDB! So to get the data, you would have to route them through the background script. And same with the Private Window (if your addon is allowed in “incognito” mode).
  • if user runs out of free space, browser may delete the whole IndexedDB (in Chrome, you may ask for “unlimitedStorage” to avoid it).
  • there are implementation bugs in all browsers, so sooner or later someone somewhere will loose data stored in there (it’s not that bad, but still, it happens).

Unless really necessary, it’s best to avoid IndexDB :slight_smile:.

1 Like

thanks for reply, Looks like export/import data from indexedb seems good workaround for now.