Erik Rothoff
Erik Rothoff

Reputation: 5123

chrome.storage is undefined in chrome extension

I'm developing a Google Chrome extension, and have been working on one for a while. So it's been installed for a while, and I updated the manifest file to include the "storage" permission and reloaded the extension. However, when I try it in the console, chrome.storage is undefined. I restarted Chrome and still nothing.

My manifest file looks like this:

{
    ... snip ...
    "permissions": [
        "tabs",
        "http://*/*",
        "https://*/*",
        "chrome://favicon/",
        "storage"
    ]
}

I could reinstall the application, but I'm hesitant, since: Will it be the same for the existing users of the extension? It says in the documentation that the permission won't show any warnings or temporarily block the extension for adding more permissions.

My question is mainly, how will the existing users of my extension be affected? Will they get a warning and have the extension disabled until they actively enable it? Or is it just a local develpment issue?

Upvotes: 12

Views: 17448

Answers (2)

Pablo LION
Pablo LION

Reputation: 1435

In the case you are adding new permissions to the manifest file manually, I see that to make the new manifest file work, you'd have to remove and add it back again.

Some background if it's helpful: I'm migrating a manifest-v2 to manifest-v3, with a new framework called "plasmo".

  1. The permission from plasmo generated manifest v3 is not working (seems plasmo haven't implemented it yet).
  2. To do it safely, I used Overriding the Manifest to create a storage permission.
  3. Only reloading the extension won't grant the new permissions to the extension. You need to remove the extension and add it again.

Upvotes: 0

marky-b
marky-b

Reputation: 304

Your manifest looks fine. Did you reload your extension after making the change?

I pasted your manifest permissions into a new extension and called:

console.log(chrome.storage);

And recieved the following:

chrome.storage output

Note "local" and "sync", the two types of storage available to the extension.

Upvotes: 11

Related Questions