Bug 1439021 - Check for browser in loadFrameScript() to support Thunderbird. r=jryans
authorJorg K <jorgk@jorgk.com>
Tue, 27 Feb 2018 03:26:00 +0200
changeset 405585 6188bb22f81e855084b4d266525d23fb8e1030bd
parent 405584 00ba29877dafcf59abeba25f8ab1597cdcf92323
child 405586 54ad50a2582638cba1fd6c8236df539a252c01ec
push id100255
push useraciure@mozilla.com
push dateWed, 28 Feb 2018 01:00:48 +0000
treeherdermozilla-inbound@e283310058ba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1439021
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1439021 - Check for browser in loadFrameScript() to support Thunderbird. r=jryans
toolkit/components/viewsource/ViewSourceBrowser.jsm
--- a/toolkit/components/viewsource/ViewSourceBrowser.jsm
+++ b/toolkit/components/viewsource/ViewSourceBrowser.jsm
@@ -68,17 +68,16 @@ ViewSourceBrowser.prototype = {
    * This should be called as soon as the script loads. When this function
    * executes, we can assume the DOM content has not yet loaded.
    */
   init() {
     this.messages.forEach((msgName) => {
       this.mm.addMessageListener(msgName, this);
     });
 
-    // If we have a known <browser> already, load the frame script here.
     this.loadFrameScript();
   },
 
   /**
    * This should be called when the window is closing. This function should
    * clean up event and message listeners.
    */
   uninit() {
@@ -86,16 +85,22 @@ ViewSourceBrowser.prototype = {
       this.mm.removeMessageListener(msgName, this);
     });
   },
 
   /**
    * For a new browser we've not seen before, load the frame script.
    */
   loadFrameScript() {
+    // Check for a browser first. There won't be one for the window case
+    // (still used by other applications like Thunderbird), as the element
+    // does not exist until the XUL document loads.
+    if (!this.browser) {
+      return;
+    }
     if (!gKnownBrowsers.has(this.browser)) {
       gKnownBrowsers.add(this.browser);
       this.mm.loadFrameScript(FRAME_SCRIPT, false);
     }
   },
 
   /**
    * Anything added to the messages array will get handled here, and should