Skip to content

Commit fed0771

Browse files
committed
Fix loading patches on Firefox 148
There have been some changes (BZ-543435) in how Firefox triggers load events, so we need to adjust the loading code. The new version should be compatible both with the old loading mechanism and the new one.
1 parent a27fbf3 commit fed0771

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

native/userchrome/profile/chrome/pwa/chrome.sys.mjs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,17 @@ class ChromeLoader {
4545
static INITIALIZED_PREFERENCES = false;
4646

4747
constructor () {
48-
Services.obs.addObserver(this, 'chrome-document-global-created', false);
48+
Services.obs.addObserver(this, 'chrome-document-global-created');
4949
}
5050

5151
observe (window) {
52-
window.ChromeLoader = ChromeLoader;
53-
window.addEventListener('DOMContentLoaded', this, { once: true });
52+
window.addEventListener('DOMContentLoaded', () => {
53+
window.parent.ChromeLoader = ChromeLoader;
54+
this.onDomContentLoaded(window);
55+
}, { once: true });
5456
}
5557

56-
handleEvent (event) {
57-
/**
58-
* @type Document
59-
* @property {Window} originalTarget
60-
*/
61-
let document = event.originalTarget;
62-
63-
let window = document.defaultView;
58+
onDomContentLoaded (window) {
6459
let location = window.location;
6560

6661
if (window._gBrowser) window.gBrowser = window._gBrowser;

native/userchrome/profile/chrome/pwa/utils/systemIntegration.sys.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function setWindowColors (window, site) {
144144
const styles = createOrGetStyles(window, INTEGRATION_STATIC_STYLES);
145145

146146
// Set the window background color
147-
if (lazy.xPref.get(window.ChromeLoader.PREF_SITES_SET_BACKGROUND_COLOR) && site.manifest.background_color) {
147+
if (lazy.xPref.get('firefoxpwa.sitesSetBackgroundColor') && site.manifest.background_color) {
148148
const backgroundColor = site.manifest.background_color.substring(0, 7);
149149

150150
// Set background color to the browser window
@@ -163,7 +163,7 @@ function setWindowColors (window, site) {
163163
}
164164

165165
// Set the theme (titlebar) background and text colors
166-
if (lazy.xPref.get(window.ChromeLoader.PREF_SITES_SET_THEME_COLOR) && site.manifest.theme_color) {
166+
if (lazy.xPref.get('firefoxpwa.sitesSetThemeColor') && site.manifest.theme_color) {
167167
// Set the static theme color from the manifest
168168
const colorHex = site.manifest.theme_color.substring(0, 7);
169169
const colorRGB = colorHex.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).slice(1).map(c => parseInt(c, 16));

0 commit comments

Comments
 (0)