Bug 1614031 - Check chat window selection is not null before adding magic copy listener. r=clokep a=wsmwk
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 13 Feb 2020 12:25:09 +0200
changeset 38171 0e08687e9ecdbc62f6ad391d859710e965a39bd2
parent 38170 af9061aaf712df08e2a2f3fe989bf342a634417b
child 38172 f76618ef7750b160074178b5c1f1325ed03b0d6c
push id398
push userclokep@gmail.com
push dateMon, 09 Mar 2020 19:10:28 +0000
reviewersclokep, wsmwk
bugs1614031
Bug 1614031 - Check chat window selection is not null before adding magic copy listener. r=clokep a=wsmwk
chat/content/conversation-browser.js
--- a/chat/content/conversation-browser.js
+++ b/chat/content/conversation-browser.js
@@ -330,28 +330,30 @@
     }
 
     enableMagicCopy() {
       this.contentWindow.controllers.insertControllerAt(0, this.copyController);
       this.autoCopyEnabled =
         Services.clipboard.supportsSelectionClipboard() &&
         Services.prefs.getBoolPref("clipboard.autocopy");
       if (this.autoCopyEnabled) {
-        this.contentWindow
-          .getSelection()
-          .addSelectionListener(this.chatSelectionListener);
+        let selection = this.contentWindow.getSelection();
+        if (selection) {
+          selection.addSelectionListener(this.chatSelectionListener);
+        }
       }
     }
 
     disableMagicCopy() {
       this.contentWindow.controllers.removeController(this.copyController);
       if (this.autoCopyEnabled) {
-        this.contentWindow
-          .getSelection()
-          .removeSelectionListener(this.chatSelectionListener);
+        let selection = this.contentWindow.getSelection();
+        if (selection) {
+          selection.removeSelectionListener(this.chatSelectionListener);
+        }
       }
     }
 
     initMagicCopy() {
       if (this.magicCopyInitialized) {
         return;
       }
       Services.prefs.addObserver(this.magicCopyPref, this.prefObserver);