2

I have a couple of questions on use of localStorage in Chrome extensions.

  • Is the 5mb storage limit per extension?
  • Does Chrome use the extension ID to monitor whether an extension conforms to this limit?
Chromer
  • 25
  • 1
  • 3

2 Answers2

3

In short: Yes and Yes.

localStorage is tied to an origin w3 spec: The localStorage attribute, usually the protocol and host part of a resource's URL.

The origin of a Chrome extension is chrome-extension://EXTENSIONIDHERE, which implies that the extensionID of a Chrome extension is indeed used to enforce the per-origin storage limits.

You can find a proof of this by visiting your profile directory, and looking in the Default/Local Storage directory, which contains several (SQLite) files of the following format:

chrome-extension_EXTENSIONIDHERE_0.localstorage
chrome-extension_EXTENSIONIDHERE_0.localstorage-journal
Rob W
  • 341,306
  • 83
  • 791
  • 678
1
  • Extension's localStorage is similar to website's localStorage so I guess it'd be 5mb. You can also consider using chrome.storage

  • Extension id is the only unique thing to every extension so chrome must use this to conform to this limit.

Uzair Farooq
  • 2,402
  • 3
  • 24
  • 37