Addon Compatibility with FF48 and solution to replace old code

Hi, I have an addon perfectly working just up to FF 47. I know that with e10s FF 48, it has some compatibility troubles. Here a brief list of the lines of code I think are affected by the new multiprocess model of the browser:

1.  let { Cc, Ci } = require('chrome');
2.  const { Cu } = require("chrome");
3.  require("sdk/tabs").on("ready",logURL);
4.  Cu.import("resource://gre/modules/FileUtils.jsm");

5.   const {TextDecoder, TextEncoder, OS} = Cu.import("resource://gre/modules/osfile.jsm", {});

6. file = FileUtils.getFile("Home", [".cp.txt"]); //reopen the file just saved

7.  var txt = "";
    var fstream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
    var cstream = Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(Ci.nsIConverterInputStream);
    fstream.init(file, -1, 0, 0);
    cstream.init(fstream, "UTF-8", 0, 0); 
                                
    let str = {};
                                
    let read = 0;
    do { 
          read = cstream.readString(0xffffffff, str); // read as much as we can and put it in str.value
          txt += str.value;
           } while (read != 0);
     cstream.close(); // this closes fstream

    // use 0x02 | 0x10 to open file for appending.
    // save the domain option in file
     foStream.init(file, 0x02 | 0x08 | 0x20, 0666, 0); 
     converter.init(foStream, "UTF-8", 0, 0);
     var sEP = txt + '\n' + 'h' + '\n'; // encrypt new path
     converter.writeString(sEP);
     converter.close(); // this closes foStream
     console.log('saved h');
                              }    

Please, I need to know, first of all, if all these elements are effectively problematic with new FF, and finally if there is a surrogate construct for the 48 version in order to solve the same problem. In particular, it is essential for the add-on the use of the tabs mechanism. Thanks for the help.

Have you made any findings? What were the compatibility problems you mentioned?
I am using similar APIs (XPCOM and low level APIs), and I don’t experience issues with those, except that the browser requires to restart to complete the installation, if there are no other addons currently installed.

Yes, all the preceding mechanisms work. By testing the add-on I noticed it warned me about some problem concerning eval(). I know this is considered unsafe, but on the basis of a more deep check I noticed the problem was not eval(), it was instead a syntax I used for checking a substring in a string. It was ‘contains’ while the correct one is ‘includes’. Now I have another question: I had used a lot of times the JS ‘contains’ and the add-on never risen any exception. It seems however this syntax does not exist. I thought that before 48 FF had some internal mechanism to recognize that ‘contains’ as an ‘includes’ instruction. Can someone confirm this hypothesis?

Yes, I think contains was discontinued and now only includes is supported.

1 Like