Add-On Validation Warning Message

I am updating one of the extensions that I have created and, when I run it through the online validator, it gives me the “Extension Test” warning below:

Reference to critical user profile data
Signing severity: low
Warning:
Critical files in the user profile should not be directly accessed by
add-ons. In many cases, an equivalent API is available and should be used instead.

Can someone, please, clear up what this is saying. My extension does save files to the user’s TEMP directory (as specified by TmpD) but it removes then when finished. The 2 lines of code reported are:

Components.classes["@mozilla.org/storage/service;1"]
.getService(Components.interfaces.mozIStorageService);

and

Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get(“TmpD”,Components.interfaces.nsIFile);

If TmpD isn’t the right place then where should I be saving the files? Any help would be appreciated. Thank you. - Mr T

We generally prefer add-ons to use the profile directory for this, and there’s an API mentioned in the warning that can be used easily for this purpose. However, using the temp directory is acceptable. This is just a warning, so it’s okay to ignore it. If you want to remove it, though, then you just need to follow the directions in it.

Thank you for your response.

I have adjusted my extension so that it saves the temporary data in an extension specific folder under the profile directory. Unfortunately the warning has not gone away so it seems to refer to mozIStorageService. For various reasons my extension is supporting Firefox version 24+, Thunderbird version 24+ and SeaMonkey version 2.20+.

Is there a storage API common to all of them that I could/should be using instead?

Thank you again. - Mr T

I have found where I was going wrong. According to some old documentation the call I was using:

var DBservice = Components.classes["@mozilla.org/storage/service;1"]
.getService(Components.interfaces.mozIStorageService);

was correct. What I should have been doing (at the least) is:

Components.utils.import(“resource://gre/modules/Services.jsm”);
var DBservice = Services.storage;

So, once I made the change, I no longer get the warning message. The “Services.jsm” module exists for all of the older versions that I’m supporting so that’s good too.

Thank you again. - Mr T

1 Like