Bug 1452342 - Toggle cursor visibility correctly in video fullscreen mode r=Gijs
MozReview-Commit-ID: K3a40Q4hgZb
--- a/toolkit/content/tests/widgets/test_videocontrols.html
+++ b/toolkit/content/tests/widgets/test_videocontrols.html
@@ -101,17 +101,24 @@ async function waitForEvent(...eventType
await new Promise((resolve, reject) => expectingEventPromise = {resolve, reject}).catch(e => {
// Throw error here to get the caller in error stack.
ok(false, e);
});
}
add_task(async function setup() {
- await SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]});
+ await SpecialPowers.pushPrefEnv({
+ "set": [
+ ["media.cache_size", 40000],
+ ["full-screen-api.enabled", true],
+ ["full-screen-api.allow-trusted-requests-only", false],
+ ["full-screen-api.transition-duration.enter", "0 0"],
+ ["full-screen-api.transition-duration.leave", "0 0"]
+ ]});
await new Promise(resolve => {
video.addEventListener("canplaythrough", resolve, {once: true});
video.src = "seek_with_sound.ogg";
});
video.addEventListener("play", verifyExpectedEvent);
video.addEventListener("pause", verifyExpectedEvent);
video.addEventListener("volumechange", verifyExpectedEvent);
@@ -373,12 +380,34 @@ add_task(async function click_event_disp
// Bug 1367194: Always ensure video is paused before finishing the test.
add_task(async function ensure_video_pause() {
if (!video.paused) {
video.pause();
await waitForEvent("pause");
}
});
+// Bug 1452342: Make sure the cursor hides and shows on full screen mode.
+add_task(async function ensure_fullscreen_cursor() {
+ video.removeAttribute("mozNoDynamicControls");
+ video.play();
+ await waitForEvent("play");
+
+ video.mozRequestFullScreen();
+ await waitForEvent("mozfullscreenchange");
+
+ const controlsSpacer = getAnonElementWithinVideoByAttribute(video, "anonid", "controlsSpacer");
+ is(controlsSpacer.hasAttribute("hideCursor"), true, "Cursor is hidden");
+
+ // Wiggle the mouse a bit
+ synthesizeMouse(video, playButtonCenterX, playButtonCenterY, { type: "mousemove" });
+
+ is(controlsSpacer.hasAttribute("hideCursor"), false, "Cursor is shown");
+
+ // Restore
+ video.setAttribute("mozNoDynamicControls", "");
+ document.mozCancelFullScreen();
+});
+
</script>
</pre>
</body>
</html>
--- a/toolkit/content/widgets/videocontrols.xml
+++ b/toolkit/content/widgets/videocontrols.xml
@@ -1188,16 +1188,20 @@
return;
}
// No need to fade in again if the element is visible and not fading out
if (!element.hidden && !element.classList.contains("fadeout")) {
return;
}
+ if (element == this.controlBar) {
+ this.controlsSpacer.removeAttribute("hideCursor");
+ }
+
// Unhide
element.hidden = false;
} else {
// No need to fade out if the element is already no visible.
if (element.hidden) {
return;
}