JavaScript OS.File in Firefox SDK Add-on file // firefox open,file firefox download,file firefox bug,file

This is my first attempt at writing a Firefox add-on.

I'm trying to read a text file that is contained in an Firefox Add-on I'm writing.

I'm following the example from MDN

let decoder = new TextDecoder();      // This decoder can be reused for several reads
let array = OS.File.read("file.txt"); // Read the complete file as an array
let text = decoder.decode(array);     // Convert this array to a text

In my main.js I have the following snippet of code :

Components.utils.import("resource://gre/modules/osfile.jsm");

var pathFile = OS.Path.join("_locales", "en", "messages.json");        

let decoder = new TextDecoder('utf-8');

let promise = OS.File.read(pathFile);        
promise = promise.then(
  function onSuccess(array) {
    return decoder.decode(array);
  },
  function onReject(array) {
    console.log("onReject read: ");
  }            
);

When I run the add-on using the cfx run command, I get the following error:

Message: ReferenceError: TextDecoder is not defined

I'm currently using Firefox 30, and the Firefox Add-on SDK 1.16.

Should I not use OS.File in main.js in an add-on?

Should I use FileUtils instead, i.e. Components.utils.import("resource://gre/modules/FileUtils.jsm");?

Answer:1

This problem occurs in the stock browser included with at least Android 4.1.2 (not Mobile Chrome) and the WebView component in a cordova-based android app we're building. I've built a page with a ...

This problem occurs in the stock browser included with at least Android 4.1.2 (not Mobile Chrome) and the WebView component in a cordova-based android app we're building. I've built a page with a ...

  1. click event firing twice
  2. click event firing multiple times
  3. click event firing twice javascript
  4. click event firing on load
  5. click event firing on page load
  6. click event firing
  7. javascript click event firing multiple times
  8. knockout click event firing on load
  9. angular click event firing twice
  10. click event not firing
  11. javascript click event firing on load
  12. vue click event firing twice
  13. click event not firing jquery
  14. click event not firing javascript
  15. react click event firing twice
  16. ajax click event firing multiple times
  17. button click event firing multiple times
  18. vuejs click event firing twice
  19. click event not firing angular
  20. jquery click event firing on page load

I can't quite seem to get the SearchField to work in extJS. I want to implement it in the table toolbar, and perform the filter on my table store object. I have my require setup like this : Ext....

I can't quite seem to get the SearchField to work in extJS. I want to implement it in the table toolbar, and perform the filter on my table store object. I have my require setup like this : Ext....

  1. canvas
  2. canceled
  3. canceled vs cancelled
  4. canada
  5. cancun
  6. canada goose
  7. cane corso
  8. canes
  9. canadian prime minister
  10. canker sore
  11. cancun flights
  12. candy
  13. cancer
  14. canon
  15. canadian marble fox
  16. canvas prints
  17. cancer sign
  18. canlis
  19. candace owens
  20. candytopia

I'm trying to replace the standard javascript confirm with a twitter bootstrap modal window. Everything is almost working (the modal is shown with its confirm text), but I'm stuck trying to catch the ...

I'm trying to replace the standard javascript confirm with a twitter bootstrap modal window. Everything is almost working (the modal is shown with its confirm text), but I'm stuck trying to catch the ...

I'm trying to intercept web requests and redirect them to a url I have saved on local storage but it isn't working. My code is as follows: chrome.webRequest.onBeforeRequest.addListener( function ...

I'm trying to intercept web requests and redirect them to a url I have saved on local storage but it isn't working. My code is as follows: chrome.webRequest.onBeforeRequest.addListener( function ...

  1. chrome webrequest redirecturl
  2. chrome extension redirecturl
  3. chrome.webrequest.onbeforerequest.addlistener redirecturl