Bug 1452342 - Toggle cursor visibility correctly in video fullscreen mode r=Gijs draft
authorTimothy Guan-tin Chien <timdream@gmail.com>
Mon, 09 Apr 2018 13:00:15 +0800
changeset 779241 92a1918e277f3625308e544df3fb3d6f9e70dda1
parent 779089 b4bc6b2401738b78fd47127a4c716bb9178e1a09
push id105714
push usertimdream@gmail.com
push dateMon, 09 Apr 2018 14:25:35 +0000
reviewersGijs
bugs1452342
milestone61.0a1
Bug 1452342 - Toggle cursor visibility correctly in video fullscreen mode r=Gijs MozReview-Commit-ID: K3a40Q4hgZb
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
@@ -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;
           }