From b18609a0236fd8d1650a7a5784568743c1e66dd3 Mon Sep 17 00:00:00 2001 From: Jeevanandam M Date: Tue, 19 Jul 2022 12:44:51 -0700 Subject: [PATCH 1/2] TB version and RWH version update in manifest #118 #119 --- manifest.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 34fa350..24f3391 100644 --- a/manifest.json +++ b/manifest.json @@ -2,16 +2,16 @@ "name": "ReplyWithHeader", "short_name": "RWH", "description": "Outlook style headers and few goodies for Thunderbird", - "version_name": "2.4.0", - "version": "2.4.0", + "version_name": "2.5.0", + "version": "2.5.0", "author": "Jeevanandam M.", "homepage_url": "https://myjeeva.com/replywithheader-mozilla", "applications": { "gecko": { "id": "replywithheader@myjeeva.com", - "strict_min_version": "91.0", - "strict_max_version": "91.*" + "strict_min_version": "102.0", + "strict_max_version": "102.*" } }, From 5bbc8d792249855ae6be135108e1a29c180de080 Mon Sep 17 00:00:00 2001 From: Jeevanandam M Date: Tue, 19 Jul 2022 12:49:48 -0700 Subject: [PATCH 2/2] Update ACM team provided script #118 #119 --- .../api/WindowListener/implementation.js | 86 +++++++++---------- 1 file changed, 41 insertions(+), 45 deletions(-) diff --git a/experiment/api/WindowListener/implementation.js b/experiment/api/WindowListener/implementation.js index 95876b4..71d1614 100644 --- a/experiment/api/WindowListener/implementation.js +++ b/experiment/api/WindowListener/implementation.js @@ -2,7 +2,7 @@ * This file is provided by the addon-developer-support repository at * https://github.com/thundernest/addon-developer-support * - * Version: 1.56 + * Version: 1.57 * * Author: John Bieling (john@thunderbird.net) * @@ -200,7 +200,7 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI { // returns the outer browser, not the nested browser of the add-on manager // events must be attached to the outer browser getAddonManagerFromTab(tab) { - if (tab.browser) { + if (tab.browser && tab.mode.name == "contentTab") { let win = tab.browser.contentWindow; if (win && win.location.href == "about:addons") { return win; @@ -211,9 +211,28 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI { getAddonManagerFromWindow(window) { let tabMail = this.getTabMail(window); for (let tab of tabMail.tabInfo) { - let win = this.getAddonManagerFromTab(tab); - if (win) { - return win; + let managerWindow = this.getAddonManagerFromTab(tab); + if (managerWindow) { + return managerWindow; + } + } + } + + async getAddonManagerFromWindowWaitForLoad(window) { + let { setTimeout } = Services.wm.getMostRecentWindow("mail:3pane"); + + let tabMail = this.getTabMail(window); + for (let tab of tabMail.tabInfo) { + if (tab.browser && tab.mode.name == "contentTab") { + // Instead of registering a load observer, wait until its loaded. Not nice, + // but gets aroud a lot of edge cases. + while(!tab.pageLoaded) { + await new Promise(r => setTimeout(r, 150)); + } + let managerWindow = this.getAddonManagerFromTab(tab); + if (managerWindow) { + return managerWindow; + } } } } @@ -329,41 +348,20 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI { // TabMonitor to detect opening of tabs, to setup the options button in the add-on manager. this.tabMonitor = { - onTabTitleChanged(aTab) { }, - onTabClosing(aTab) { }, - onTabPersist(aTab) { }, - onTabRestored(aTab) { }, - onTabSwitched(aNewTab, aOldTab) { - //self.setupAddonManager(self.getAddonManagerFromTab(aNewTab)); - }, - async onTabOpened(aTab) { - if (aTab.browser) { - if (!aTab.pageLoaded) { - // await a location change if browser is not loaded yet - await new Promise((resolve) => { - let reporterListener = { - QueryInterface: ChromeUtils.generateQI([ - "nsIWebProgressListener", - "nsISupportsWeakReference", - ]), - onStateChange() { }, - onProgressChange() { }, - onLocationChange( - /* in nsIWebProgress*/ aWebProgress, - /* in nsIRequest*/ aRequest, - /* in nsIURI*/ aLocation - ) { - aTab.browser.removeProgressListener(reporterListener); - resolve(); - }, - onStatusChange() { }, - onSecurityChange() { }, - onContentBlockingEvent() { }, - }; - aTab.browser.addProgressListener(reporterListener); - }); + onTabTitleChanged(tab) { }, + onTabClosing(tab) { }, + onTabPersist(tab) { }, + onTabRestored(tab) { }, + onTabSwitched(aNewTab, aOldTab) { }, + async onTabOpened(tab) { + if (tab.browser && tab.mode.name == "contentTab") { + let { setTimeout } = Services.wm.getMostRecentWindow("mail:3pane"); + // Instead of registering a load observer, wait until its loaded. Not nice, + // but gets aroud a lot of edge cases. + while(!tab.pageLoaded) { + await new Promise(r => setTimeout(r, 150)); } - self.setupAddonManager(self.getAddonManagerFromTab(aTab)); + self.setupAddonManager(self.getAddonManagerFromTab(tab)); } }, }; @@ -594,16 +592,14 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI { self ); } else { - // Setup the options button/menu in the add-on manager, if it is already open. - self.setupAddonManager( - self.getAddonManagerFromWindow(window), - true - ); // Add a tabmonitor, to be able to setup the options button/menu in the add-on manager. self .getTabMail(window) .registerTabMonitor(self.tabMonitor); window[self.uniqueRandomID].hasTabMonitor = true; + // Setup the options button/menu in the add-on manager, if it is already open. + let managerWindow = await self.getAddonManagerFromWindowWaitForLoad(window); + self.setupAddonManager(managerWindow, true); } } } @@ -1183,4 +1179,4 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI { this.chromeHandle = null; } } -}; +}; \ No newline at end of file