Bug 1274879 - Terminate event listeners of videocontrols in destructor. r?jaws
MozReview-Commit-ID: CXXGXIsheAN
--- 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>