Bug 1613069 - don't trip over null mousemove tasks when destroying PictureInPictureChild actors, r=jaws
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 06 Feb 2020 17:32:28 +0000
changeset 512776 ef9ca2da9e697105072e72f321785e08665d2fe7
parent 512775 b372743705c9c955e3f5cc08a1aa4cf09b6a0c2d
child 512777 ec4e3e080c1ccaa196b973713657acec5fa97a0c
push id37098
push usercsabou@mozilla.com
push dateFri, 07 Feb 2020 03:55:51 +0000
treeherdermozilla-central@7dcafc398876 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1613069
milestone74.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 1613069 - don't trip over null mousemove tasks when destroying PictureInPictureChild actors, r=jaws Differential Revision: https://phabricator.services.mozilla.com/D61551
toolkit/actors/PictureInPictureChild.jsm
--- a/toolkit/actors/PictureInPictureChild.jsm
+++ b/toolkit/actors/PictureInPictureChild.jsm
@@ -406,16 +406,23 @@ class PictureInPictureToggleChild extend
 
   /**
    * If we no longer have any interesting videos in the viewport, we deregister
    * the mousemove and click listeners, and also remove any toggles that might
    * be on the page still.
    */
   stopTrackingMouseOverVideos() {
     let state = this.docState;
+    // We initialize `mousemoveDeferredTask` in `beginTrackingMouseOverVideos`.
+    // If it doesn't exist, that can't have happened. Nothing else ever sets
+    // this value (though we arm/disarm in various places). So we don't need
+    // to do anything else here and can return early.
+    if (!state.mousemoveDeferredTask) {
+      return;
+    }
     state.mousemoveDeferredTask.disarm();
     this.document.removeEventListener("mousemove", this, {
       mozSystemGroup: true,
       capture: true,
     });
     this.contentWindow.removeEventListener("pageshow", this, {
       mozSystemGroup: true,
     });