TB68, autoconfig, ReferenceError: Components is not defined
Categories
(Thunderbird :: Untriaged, defect)
Tracking
(Not tracked)
People
(Reporter: heim, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763
Steps to reproduce:
We have some lines of JS-Code in the autoconfig,cfg file, which calls Components.classes.
Actual results:
This trows an error with TB68: ReferenceError: Components is not defined
Expected results:
Load the classes.
Comment 1•6 years ago
|
||
autoconfig.cfg is for pre-canned account configuration (https://wiki.mozilla.org/Thunderbird:Autoconfiguration)?
What exactly is the JS code you have?
Ben, can you comment here?
No, not this one.
That is a confusing situation about the term "AutoConfig". I was not aware of this until now.
It is used in TB in 2 locations: The one, you described for the mail config.
But it is also used on mozilla products for the configuration/lockdown of the program itself by preferences and extensions.
Here, i refer to the second one.
Which on Windows is located in: "C:\Program Files\Mozilla Thunderbird\defaults\pref" and typically redirected to a mozilla.cfg file in the main application folder.
However, when we use a call to Components.classes from this mozilla.cfg it trows the aforementioned error:
ReferenceError: Components is not defined
So, this should definitely work, it still does on Firefox for example, even tough, it is web extensions only now a days.
Does this clarify the situation?
Comment 3•6 years ago
|
||
Somewhat. But you didn't answer the question: What exactly is the JS code you have?
There have been many changes to JS code between 60 and 68, so changes are that you need to adapt that code.
Oh, sorry
Here we go:
try
{
var io = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var resource = io.getProtocolHandler("resource")
.QueryInterface(Components.interfaces.nsIResProtocolHandler);
var greDir = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("GreD", Components.interfaces.nsIFile);
var gpoModDir = greDir.clone();
gpoModDir.append("gpo");
gpoModDir.append("modules");
var gpoAlias = io.newFileURI(gpoModDir);
resource.setSubstitution("gpo", gpoAlias);
Components.utils.import("resource://gpo/gpo.jsm");
GPO.onLoad();
} catch(e) {
displayError("gpo.cfg", e);
}
try {
var timer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
timer.initWithCallback(
function refreshPolicy_timer() { GPO.onLoad(); },
// Hourly refresh preferences from policy
60 * 60000,
timer.TYPE_REPEATING_SLACK
);
} catch(e) {
displayError("gpo.cfg timer init", e);
}
That basically loads a JS module to set prefs by Windows Group Policies.
This works on TB 60.x and also on an actual FF 69.x.
Comment 5•6 years ago
|
||
Can you attach this as a file since markdown destroyed the indentation. You need to wrap code into three back-quotes.
Which line fails exactly? If it works on FF 69, it should work on TB 68. Hmm. Internally we've changed all Components.classes and Components.interfaces to Cc and Ci and also changed the imports, like Components.utils.import(), but the old syntax should still work.
Magnus, Geoff, can you see anything here?
Solved!
It was the new sandbox feature, which was causing this!
One has to add the following line:
pref("general.config.sandbox_enabled", false);
to the autoconfig.js file here:
C:\Program Files\Mozilla Thunderbird\defaults\pref\autoconfig.js
Just for reference, if somebody else stumbles across this.
We all hope, that the new Policy-Feature is Building up real quick, so we can drop this ancient stuff...
Comment 7•6 years ago
|
||
Great, thanks for the feedback.
Description
•