0

I'm making a Firefox Add-On that needs to keep track of a list of words. From the main javascript file I can read and modify a stored Array under the name "list", but when I try to access it from the settings page I get an error:

ReferenceError: browser is not defined

Here is the function from which I try to access the local storage (this is in the .js file that is used in my .html settings page).

function EmptyList() {
    if (confirm("Empty list?")){
    browser.storage.local.set({
        list : []
    });
    }
}

I don't understand what am I doing wrong. I'm not doing anything different from what they do in the mozilla tutorial.

Makyen
  • 31,849
  • 12
  • 86
  • 121
carllacan
  • 310
  • 3
  • 10
  • Please [edit] the question to be on-topic: include a **complete** [mcve] that duplicates the problem. Including a *manifest.json*, some of the background *and* content scripts. Questions seeking debugging help ("**why isn't this code working?**") must include: ►the desired behavior, ►a specific problem or error *and* ►the shortest code necessary to reproduce it **in the question itself**. Questions without a clear problem statement are not useful to other readers. See: "**How to create a [mcve]**", [What topics can I ask about here?](http://stackoverflow.com/help/on-topic), and [ask]. – Makyen Nov 30 '16 at 18:59
  • Do I really need to? I already found the solution and it doesn't seem to involve any other file of my Add-on, it's only a matter of cleaning the cache. Or should I add them to see if we can pinpoint what is really causing the issue? – carllacan Nov 30 '16 at 20:01
  • Well, frankly, the most common similar problem posted as a Question here, based just on what you have provided in your Question, is that you are trying to use WebExtension methods in another type of Firefox add-on. There have been multiple questions with this as the issue with both WebExtension methods attempted to be used in Add-on SDK extensions and vice versa. This is even when the user explicitly states they are trying to use the one they are not actually using. Thus, yes, you should provide at least enough actual code to show what you are doing. – Makyen Nov 30 '16 at 20:14
  • If it really was something that was resolved by disabling and re-enabling the add-on, then it is unlikely to be something we are able to duplicate, and thus resolve. On the other hand, having the question, with that being the resolution, is beneficial as it might get someone to try that as a solution. – Makyen Nov 30 '16 at 20:14

1 Answers1

0

Apparently it has something to do with the cache.

Disable and reenable the add-on (or remove it and add it again) and it works. Go figure.

carllacan
  • 310
  • 3
  • 10