Bug 1506706 - Add tab properties so Marionette can run on Thunderbird. r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 16 Nov 2018 21:19:17 +1300
changeset 33769 7f0dd2a068dc9f63603cbe940cbb6f33a3f74159
parent 33768 adf300295c5afff4674ccd5695e158edc43f38d5
child 33770 d61233a819393705eb09d5ba4e14191be39ea1f1
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersmkmelin
bugs1506706
Bug 1506706 - Add tab properties so Marionette can run on Thunderbird. r=mkmelin
mail/base/content/tabmail.xml
mail/installer/Makefile.in
mail/installer/package-manifest.in
--- a/mail/base/content/tabmail.xml
+++ b/mail/base/content/tabmail.xml
@@ -446,18 +446,42 @@
       <method name="openFirstTab">
         <body><![CDATA[
           // From the moment of creation, our XBL binding already has a visible
           //  tab.  We need to create a tab information structure for this tab.
           //  In the process we also generate a synthetic tab title changed
           //  event to ensure we have an accurate title.  We assume the tab
           //  contents will set themselves up correctly.
           if (this.tabInfo.length == 0) {
-            let firstTab = {mode: this.defaultTabMode, busy: false,
-                            canClose: false, thinking: false, _ext: {}};
+            let firstTab = {
+              mode: this.defaultTabMode,
+              busy: false,
+              canClose: false,
+              thinking: false,
+              _ext: {},
+              get linkedBrowser() {
+                // This is a hack to make Marionette work. It needs a linkedBrowser
+                // from the first tab before it will start. Because linkedBrowser is
+                // implemented as a getter, it's ignored by anything that
+                // JSON-serializes this tab.
+                let browserFunc = this.mode.getBrowser || this.mode.tabType.getBrowser;
+                let browser = browserFunc ? browserFunc.call(this.mode.tabType, this) : null;
+
+                if (browser && !("permanentKey" in browser)) {
+                  // The permanentKey property is a unique Object, thus allowing this
+                  // browser to be stored in a WeakMap.
+                  // Use the JSM global to create the permanentKey, so that if the
+                  // permanentKey is held by something after this window closes, it
+                  // doesn't keep the window alive.
+                  browser.permanentKey = new (Cu.getGlobalForObject(Services).Object);
+                }
+
+                return browser;
+              },
+            };
             firstTab.mode.tabs.push(firstTab);
 
             this.tabInfo[0] = this.currentTabInfo = firstTab;
 
             let tabOpenFirstFunc = firstTab.mode.openFirstTab ||
                                    firstTab.mode.tabType.openFirstTab;
             tabOpenFirstFunc.call(firstTab.mode.tabType, firstTab);
             this.setTabTitle(null);
--- a/mail/installer/Makefile.in
+++ b/mail/installer/Makefile.in
@@ -193,8 +193,12 @@ package-compare:: $(MOZ_PKG_MANIFEST)
 	-diff -u $(DIST)/pack-list.txt $(DIST)/bin-list.txt
 	rm -f $(DIST)/pack-list.txt $(DIST)/bin-list.txt
 
 # The comm-* source stamp is already there.
 PLATFORM_SOURCE_STAMP = $(firstword $(shell hg -R "$(moztopsrcdir)" parent --template="{node}\n" 2>/dev/null))
 PLATFORM_SOURCE_REPO = $(shell hg -R "$(moztopsrcdir)" showconfig paths.default 2>/dev/null | sed -e "s/^ssh:/https:/")
 make-sourcestamp-file::
 	@echo "$(PLATFORM_SOURCE_REPO)/rev/$(PLATFORM_SOURCE_STAMP)" >> $(MOZ_SOURCESTAMP_FILE)
+
+ifdef ENABLE_MARIONETTE
+DEFINES += -DENABLE_MARIONETTE=1
+endif
--- a/mail/installer/package-manifest.in
+++ b/mail/installer/package-manifest.in
@@ -495,16 +495,25 @@
 @RESPATH@/components/ClearDataService.manifest
 @RESPATH@/components/ClearDataService.js
 
 #ifdef MOZ_WEBRTC
 @RESPATH@/components/PeerConnection.js
 @RESPATH@/components/PeerConnection.manifest
 #endif
 
+; Remote control protocol
+#ifdef ENABLE_MARIONETTE
+@RESPATH@/chrome/marionette@JAREXT@
+@RESPATH@/chrome/marionette.manifest
+@RESPATH@/components/marionette.manifest
+@RESPATH@/components/marionette.js
+@RESPATH@/defaults/pref/marionette.js
+#endif
+
 @RESPATH@/components/nsAsyncShutdown.manifest
 @RESPATH@/components/nsAsyncShutdown.js
 
 @RESPATH@/components/BuiltinProviders.manifest
 @RESPATH@/components/PresentationControlService.js
 
 ; Phishing Protection