I am developong Firefox Add-on that uses localStorage to store user data in website context. It access localStorage via injected content scripts using standard methods:
localStorage.getItem(key);
localStorage.setItem(key, value);
The code that calls localStorege is injected to website via PageMod:
pageMod.PageMod({
contentScriptFile: [
self.data.url("app.js")
]})
When methods getItem/setItem are called, security exception is thrown:
[Exception... "The operation is insecure." code: "18" nsresult: "0x80530012 (SecurityError)" location: ""]
So far I did not find out the reason why this is happening. I have an suspicion that it may have something to do with old FireFox bug, but probability is low: http://meyerweb.com/eric/thoughts/2012/04/25/firefox-failing-localstorage/
Maybe anyone could suggest an idea what could cause a problem?
Additional info:
localStorage object is enough to throw a security error. Luckily, catching this error is quite easy.
Local storage shares many of the same characteristics as a cookie, including the same security risks. One of those is susceptibility to cross-site scripting, which steals cookies to let hackers masquerade as a user with their login session for a site.
The reason you are running into an error is because, test is not available in the scope of code ( and a reference error is thrown, when you try to access a variable that is not defined yet). In your case it lives on localStorage. test because you are attaching it directly to localStorage object.
Local Storage data stored on normal browsing sessions will not be available when you open a browser in private browsing or in Incognito mode. Local Storage data will not get cleared even if you close the browser. Because it's stored on your browser cache in your machine.
We also have an extension and are getting the same error with local storage. This is a bug with 29, as @basarat notes this error should only be thrown for CORS issues. We've tested with Aurora and Nightly with no issues either. We're filing a bug with Mozilla.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With