Well, here I am back again with another problem concerning parts of my addon.
I'm using an observer to modify values called through javascript.
var observerService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
observerService.addObserver(this, "document-element-inserted", false);
I'm doing this by observing 'document-element-inserted', which is
Sent immediately after the root element of a document has been created, but before executing any script on it. (Source)
When called, my addon modifies several document/navigator/screen-values to reduce fingerprinting by overriding the navigator.X values:
Object.defineProperty(XPCNativeWrapper.unwrap(navigator), "plugins", {
value: "",
});
In this case for example the plugin list, making it appear as if I don't have any plugins installed at all.
So far, this has been working fine in my development environment/jpm run. However, now that I've created an actual xpi, nothing happens. The code still gets called, I've used several console outputs in my jSTracking function, and all of them appeared in the browser console. However, the supposedly changed values are still the original ones.
There are only two errors which don't appear when using jpm run:
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIURI.hostPort]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: resource://gre/modules/PopupNotifications.jsm :: PopupNotifications_refreshPanel/< :: line 667" data: no] (unknown)
gets thrown twice during installation.
Use of nsIFile in content process is deprecated. Content.js:25:17
Use of nsIFile in content process is deprecated. NetUtil.jsm:335:12
Is the other one which appears from time to time, though never related to my scripts.
The thing that confuses me the most: Why does Object.defineProperty work with jpm run, but not with the xpi? What do I have to change to make it always work?
The whole project can be found at my Github repository.
The registering of the observer is in pp.js at line 452,
the observe-function is in lines 436-446
and the jsTracking function starts in line 193 and ends in line 433
The quoted plugin-example can be found in lines 399-403
I'd be grateful for any help, thanks!