Bug 1274879 - Terminate event listeners of videocontrols in destructor. r?jaws draft
authorXidorn Quan <me@upsuper.org>
Thu, 02 Jun 2016 16:48:13 +1000
changeset 374398 85dc6764b0f822ddfe16f07b10b62194c6b3df6c
parent 374397 7aaad114f4d6bed67d979b56d0aaed8ea135e886
child 522621 029f75caa2cd005c1b00d9e634fd2d2d29510c79
push id20007
push userxquan@mozilla.com
push dateThu, 02 Jun 2016 09:21:53 +0000
reviewersjaws
bugs1274879
milestone49.0a1
Bug 1274879 - Terminate event listeners of videocontrols in destructor. r?jaws MozReview-Commit-ID: CXXGXIsheAN
toolkit/content/tests/widgets/test_videocontrols.html
toolkit/content/widgets/videocontrols.xml
--- a/toolkit/content/tests/widgets/test_videocontrols.html
+++ b/toolkit/content/tests/widgets/test_videocontrols.html
@@ -69,16 +69,25 @@ function isMuteButtonMuted() {
 
 function isVolumeSliderShowingCorrectVolume(expectedVolume) {
   var volumeButton = getButtonByAttribute('anonid', 'volumeForeground');
   let expectedPaddingRight = (1 - expectedVolume) * volumeSliderWidth + "px";
   is(volumeButton.style.paddingRight, expectedPaddingRight,
      "volume slider should match expected volume");
 }
 
+function forceReframe() {
+  // Setting display then getting the bounding rect to force a frame
+  // reconstruction on the video element.
+  video.style.display = "block";
+  video.getBoundingClientRect();
+  video.style.display = "";
+  video.getBoundingClientRect();
+}
+
 function runTest(event) {
   ok(true, "----- test #" + testnum + " -----");
 
   switch (testnum) {
     /*
      * Check operation of play/pause/mute/unmute buttons.
      */
     case 1:
@@ -340,16 +349,27 @@ function runTest(event) {
       });
       break;
 
     case 25:
       is(event.type, "mozfullscreenchange", "checking event type");
       is(video.volume, 0.6, "Volume should still be 0.6");
       SimpleTest.executeSoon(function() {
         isVolumeSliderShowingCorrectVolume(video.volume);
+        forceReframe();
+        video.focus();
+        synthesizeKey("VK_DOWN", {});
+      });
+      break;
+
+    case 26:
+      is(event.type, "volumechange", "checking event type");
+      is(video.volume, 0.5, "Volume should be decreased by 0.1");
+      SimpleTest.executeSoon(function() {
+        isVolumeSliderShowingCorrectVolume(video.volume);
         SimpleTest.finish();
       });
       break;
 
     default:
       throw "unexpected test #" + testnum + " w/ event " + event.type;
   }
 
--- a/toolkit/content/widgets/videocontrols.xml
+++ b/toolkit/content/widgets/videocontrols.xml
@@ -1372,16 +1372,17 @@
                     this.log("--- videocontrols initialized ---");
                 }
             };
             this.Utils.init(this);
             ]]>
         </constructor>
         <destructor>
             <![CDATA[
+            this.Utils.terminateEventListeners();
             // randomID used to be a <field>, which meant that the XBL machinery
             // undefined the property when the element was unbound. The code in
             // this file actually depends on this, so now that randomID is an
             // expando, we need to make sure to explicitly delete it.
             delete this.randomID;
             ]]>
         </destructor>
 
@@ -1760,16 +1761,17 @@
             }
           };
           this.Utils.init(this);
           this.Utils.video.dispatchEvent(new CustomEvent("MozNoControlsVideoBindingAttached"));
           ]]>
       </constructor>
       <destructor>
           <![CDATA[
+          this.Utils.terminateEventListeners();
           // randomID used to be a <field>, which meant that the XBL machinery
           // undefined the property when the element was unbound. The code in
           // this file actually depends on this, so now that randomID is an
           // expando, we need to make sure to explicitly delete it.
           delete this.randomID;
           ]]>
       </destructor>
     </implementation>