Bug 1285234 - Check for valid videoEvents and controlListeners before dereferencing them in case the videocontrols have been cleaned up already. r=Gijs
authorJared Wein <jwein@mozilla.com>
Tue, 19 Jul 2016 12:35:22 -0700
changeset 305757 067b8bda91edf07737a97e094677810c3156853e
parent 305756 ea595eb22b9cb18c9268ecf8d7c98bfb156f63c8
child 305758 1b135c0869e1aa0fba03801d3fd6bf43e1e3cd7e
push id79665
push usercbook@mozilla.com
push dateWed, 20 Jul 2016 09:36:22 +0000
treeherdermozilla-inbound@744232e7c04a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1285234
milestone50.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 1285234 - Check for valid videoEvents and controlListeners before dereferencing them in case the videocontrols have been cleaned up already. r=Gijs MozReview-Commit-ID: HAnjW0F3kFo
toolkit/content/widgets/videocontrols.xml
--- a/toolkit/content/widgets/videocontrols.xml
+++ b/toolkit/content/widgets/videocontrols.xml
@@ -636,30 +636,34 @@
                             // Nothing to do...
                             break;
                         default:
                             this.log("!!! event " + aEvent.type + " not handled!");
                     }
                 },
 
                 terminateEventListeners : function () {
-                    for (let event of this.videoEvents) {
-                        this.video.removeEventListener(event, this, {
-                            capture: true,
-                            mozSystemGroup: true
-                        });
+                    if (this.videoEvents) {
+                      for (let event of this.videoEvents) {
+                          this.video.removeEventListener(event, this, {
+                              capture: true,
+                              mozSystemGroup: true
+                          });
+                      }
                     }
 
-                    for (let element of this.controlListeners) {
-                        element.item.removeEventListener(element.event, element.func,
-                                                         { mozSystemGroup: true });
+                    if (this.controlListeners) {
+                      for (let element of this.controlListeners) {
+                          element.item.removeEventListener(element.event, element.func,
+                                                           { mozSystemGroup: true });
+                      }
+
+                      delete this.controlListeners;
                     }
 
-                    delete this.controlListeners;
-
                     this.log("--- videocontrols terminated ---");
                 },
 
                 hasError : function () {
                     // We either have an explicit error, or the resource selection
                     // algorithm is running and we've tried to load something and failed.
                     // Note: we don't consider the case where we've tried to load but
                     // there's no sources to load as an error condition, as sites may