Services.jsm is going to be removed in Firefox 117

62 views
Skip to first unread message

Mike Kaply

unread,
Jul 5, 2023, 10:59:07 AM7/5/23
to Mozilla.org
If you are still using Autoconfig (I hope you're not), this applies to you.

Services.jsm is Firefox's internal module that has been used in the following pattern inside a non-sandboxed AutoConfig script.

Components.utils.import("resource://gre/modules/Services.jsm");
// or
Cu.import("resource://gre/modules/Services.jsm");
// Then use Services global variable

The Services global variable is available in the non-sandboxed AutoConfig global without importing Services.jsm from Firefox 104 (https://bugzilla.mozilla.org/show_bug.cgi?id=1667455), and Services.jsm is going to be removed in Firefox 117 cycle (https://bugzilla.mozilla.org/show_bug.cgi?id=1780695).

If you're using a non-sandboxed AutoConfig script, and it has Services.jsm references, it's affected by the change.

If your AutoConfig script targets Firefox 104 or above, you can simply remove the import for Services.jsm, and directly use the Services global variable.

If your AutoConfig script targets Firefox 101 or above, ChromeUtils is available in the global (https://bugzilla.mozilla.org/show_bug.cgi?id=1766114), and you can write the following:

var Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;

For other cases, you can write the following:

var Services = globalThis.Services || Cu.import("resource://gre/modules/Services.jsm", {}).Services;

Don't hesitate to reach out if you have questions.

Mike Kaply
Reply all
Reply to author
Forward
0 new messages