Q:

Firefox local storage not available in other tab

I'm creating a firefox extension. I want to use localStorage as a global variable for whole browser. But it is working only for the tab where it was saved. I'm not able to read this value in other tab. How  I can make it to be accessible from any tab, or what may be the possible issues ?
I use it like:
localStorage.getItem('variable')
localStorage.setItem('variable','value')

To be more precise, I'm injecting the javascript code into the page when it was loaded. and from injected code i want to save my value to localstorage.
tabs have different url. and my code is trying to use the localstorage when page loaded. but it checking if the localStorage value exists like this:
if(localStorage.getItem('variable')){ ... }

A:

I don't think you can use localStorage as a global variable
localStorage is also the same as globalStorage[location.hostname], with the exception 
of being scoped to an HTML5 origin (scheme + hostname + non-standard port) and 
localStorage being an instance of Storage as opposed to 
globalStorage[location.hostname] being an instance of StorageObsolete which is covered 
below. For example, http://example.com is not able to access the same localStorage 
object as https://example.com but they can access the same globalStorage item. 
localStorage is a standard interface while globalStorage is non-standard so you 
shouldn't rely on these.

Please note that setting a property on globalStorage[location.hostname] does not set 
it on localStorage and extending Storage.prototype does not affect globalStorage 
items, only extending StorageObsolete.prototype does.

Consider using globalStorage and then setting localStorage where need be.
Source: https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Storage#localStorage

