Skip to content

Commit

Permalink
Fix compatibility with Firefox 117
Browse files Browse the repository at this point in the history
This commit fixes compatibility with Firefox 117 by conditionally importing `Services.jsm` which was removed. Since Firefox 104, the `Services` object is available in the global scope, however, conditional import has been included to preserve compatibility with Firefox ESR 102. This will be removed in the future.
  • Loading branch information
filips123 committed Aug 3, 2023
1 parent 70cbc3a commit 3fd078d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion native/userchrome/profile/chrome/pwa/boot.jsm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const EXPORTED_SYMBOLS = [];

const { XPCOMUtils } = ChromeUtils.import('resource://gre/modules/XPCOMUtils.jsm');
const Services = globalThis.Services || ChromeUtils.import('resource://gre/modules/Services.jsm').Services;
XPCOMUtils.defineLazyGetter(this, 'gSystemPrincipal', () => Services.scriptSecurityManager.getSystemPrincipal());
XPCOMUtils.defineLazyModuleGetters(this, {
AppConstants: 'resource://gre/modules/AppConstants.jsm',
NetUtil: 'resource://gre/modules/NetUtil.jsm',
Services: 'resource://gre/modules/Services.jsm',
applySystemIntegration: 'resource://pwa/utils/systemIntegration.jsm',
});
XPCOMUtils.defineLazyServiceGetter(this, 'PromptService', '@mozilla.org/embedcomp/prompt-service;1', Ci.nsIPromptService);
Expand Down
2 changes: 1 addition & 1 deletion native/userchrome/profile/chrome/pwa/chrome.jsm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const EXPORTED_SYMBOLS = [];

const { XPCOMUtils } = ChromeUtils.import('resource://gre/modules/XPCOMUtils.jsm');
const Services = globalThis.Services || ChromeUtils.import('resource://gre/modules/Services.jsm').Services;
XPCOMUtils.defineLazyModuleGetters(this, {
AppConstants: 'resource://gre/modules/AppConstants.jsm',
Services: 'resource://gre/modules/Services.jsm',
applySystemIntegration: 'resource://pwa/utils/systemIntegration.jsm',
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const EXPORTED_SYMBOLS = ['buildIconList', 'applySystemIntegration', 'applyDynamicThemeColor'];

const { XPCOMUtils } = ChromeUtils.import('resource://gre/modules/XPCOMUtils.jsm');
const Services = globalThis.Services || ChromeUtils.import('resource://gre/modules/Services.jsm').Services;
XPCOMUtils.defineLazyModuleGetters(this, {
AppConstants: 'resource://gre/modules/AppConstants.jsm',
ImageTools: 'resource:///modules/ssb/ImageTools.jsm',
NetUtil: 'resource://gre/modules/NetUtil.jsm',
Services: 'resource://gre/modules/Services.jsm',
xPref: 'resource://pwa/utils/xPref.jsm',
});
XPCOMUtils.defineLazyServiceGetter(this, 'ImgTools', '@mozilla.org/image/tools;1', Ci.imgITools);
Expand Down
2 changes: 1 addition & 1 deletion native/userchrome/profile/chrome/pwa/utils/xPref.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const EXPORTED_SYMBOLS = ['xPref'];
// File is mostly copied from xiaoxiaoflood/firefox-scripts repository on GitHub, licensed under MPL 2.0
// Original source: https://github.com/xiaoxiaoflood/firefox-scripts/blob/69675c7f09e9009b63b1cc239b94c03c5962a9d7/chrome/utils/xPref.jsm

const { Services } = ChromeUtils.import('resource://gre/modules/Services.jsm');
const Services = globalThis.Services || ChromeUtils.import('resource://gre/modules/Services.jsm').Services;

const xPref = {
get: function (prefPath, def = false, valueIfUndefined, setDefault = true) {
Expand Down

0 comments on commit 3fd078d

Please sign in to comment.