[tor-commits] [tor-browser] 58/73: Bug 1776222 - Disable fullscreen on audio tags. r=jaws, a=RyanVM

gitolite role git at cupani.torproject.org
Wed Sep 21 20:17:51 UTC 2022


This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch geckoview-102.3.0esr-12.0-1
in repository tor-browser.

commit 5404656aa22632296e1ae00d41609a979a828a35
Author: Bernard Igiri <bigiri at mozilla.com>
AuthorDate: Wed Jul 27 17:25:48 2022 +0000

    Bug 1776222 - Disable fullscreen on audio tags. r=jaws, a=RyanVM
    
    Disabling fullscreen on audio tags so that double clicking does not cause those tags to display as full screen.
    
    Differential Revision: https://phabricator.services.mozilla.com/D152564
---
 toolkit/content/tests/widgets/mochitest.ini        |  3 ++
 .../content/tests/widgets/test_videocontrols.html  |  8 ++++
 .../tests/widgets/test_videocontrols_audio.html    | 45 ++++++++++++++++++++--
 toolkit/content/widgets/videocontrols.js           |  9 +++--
 4 files changed, 58 insertions(+), 7 deletions(-)

diff --git a/toolkit/content/tests/widgets/mochitest.ini b/toolkit/content/tests/widgets/mochitest.ini
index a78cbac927887..1e8cc1b3a3d94 100644
--- a/toolkit/content/tests/widgets/mochitest.ini
+++ b/toolkit/content/tests/widgets/mochitest.ini
@@ -37,6 +37,9 @@ skip-if = (toolkit == 'android') || (os == 'linux') #Bug 1366957
 [test_videocontrols_iframe_fullscreen.html]
 [test_videocontrols_size.html]
 [test_videocontrols_audio.html]
+skip-if = 
+  win10_2004 && !debug # Bug 1781917
+  apple_catalina && !debug # Bug 1781917
 [test_videocontrols_audio_direction.html]
 skip-if = xorigin # Rendering of reftest videocontrols_direction-2a.html should not be different to the reference, fails/passes inconsistently
 [test_videocontrols_jsdisabled.html]
diff --git a/toolkit/content/tests/widgets/test_videocontrols.html b/toolkit/content/tests/widgets/test_videocontrols.html
index 40cb1c2a09b2b..865e1c9076fa7 100644
--- a/toolkit/content/tests/widgets/test_videocontrols.html
+++ b/toolkit/content/tests/widgets/test_videocontrols.html
@@ -445,6 +445,14 @@ add_task(async function ensure_fullscreen_button() {
   document.getElementById("content").appendChild(video);
 });
 
+add_task(async function ensure_doubleclick_triggers_fullscreen() {
+  const { x, y } = video.getBoundingClientRect();
+  info("attempt double click");
+  synthesizeMouse(video, x, y, { clickCount: 2 });
+  await waitForEvent("play");
+  await waitForEvent("mozfullscreenchange");
+});
+
 </script>
 </pre>
 </body>
diff --git a/toolkit/content/tests/widgets/test_videocontrols_audio.html b/toolkit/content/tests/widgets/test_videocontrols_audio.html
index 5c095df430d3f..4c7f14c1a1f6f 100644
--- a/toolkit/content/tests/widgets/test_videocontrols_audio.html
+++ b/toolkit/content/tests/widgets/test_videocontrols_audio.html
@@ -16,6 +16,36 @@
 <pre id="test">
 <script class="testbody" type="application/javascript">
 
+  const video = document.getElementById("video");
+
+  class EventLogger {
+    constructor() {
+      this._log = [];
+      this._xEventsPromise = new Promise(r => this._xReached = r);
+      this._x = Number.MAX_VALUE;
+    }
+    createListener() {
+      return e => {
+        this._log.push(e);
+        if (this._log.length >= this._x) {
+          this._xReached(this._log);
+        }
+      }
+    }
+    waitForXEvents(x) {
+      this._x = x;
+      return this._xEventsPromise;
+    }
+    clearEvents() {
+      this._log = [];
+    }
+  }
+  const logger = new EventLogger();
+
+  video.addEventListener("play", logger.createListener());
+  video.addEventListener("pause", logger.createListener());
+  document.addEventListener("mozfullscreenchange", logger.createListener());
+
   const InspectorUtils = SpecialPowers.InspectorUtils;
 
   function findElementByAttribute(element, aName, aValue) {
@@ -37,15 +67,22 @@
   }
 
   function loadedmetadata(event) {
-    SimpleTest.executeSoon(function() {
-      var controlBar = findElementByAttribute(video, "class", "controlBar");
+    SimpleTest.executeSoon(async function test_fullscreen_unavailable() {
+      const { x, y } = video.getBoundingClientRect();
+      const controlBar = findElementByAttribute(video, "class", "controlBar");
       is(controlBar.getAttribute("fullscreen-unavailable"), "true", "Fullscreen button is hidden");
+      logger.clearEvents();
+      synthesizeMouse(video, x, y, { clickCount: 2 });
+      const events = await logger.waitForXEvents(2);
+      ok(
+        !events.find(e => e.type === "mozfullscreenchange"),
+        "Double clicking should not trigger fullscreen event"
+      );
+      is(events.length, 2, "Two events should have been fired.");
       SimpleTest.finish();
     });
   }
 
-  var video = document.getElementById("video");
-
   SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, startTest);
   function startTest() {
     // Kick off test once audio has loaded.
diff --git a/toolkit/content/widgets/videocontrols.js b/toolkit/content/widgets/videocontrols.js
index a411b0150c1a4..f962a0fa39508 100644
--- a/toolkit/content/widgets/videocontrols.js
+++ b/toolkit/content/widgets/videocontrols.js
@@ -1705,9 +1705,12 @@ this.VideoControlsImplWidget = class {
       },
 
       toggleFullscreen() {
-        this.isVideoInFullScreen
-          ? this.document.exitFullscreen()
-          : this.video.requestFullscreen();
+        // audio tags cannot toggle fullscreen
+        if (!this.isAudioOnly) {
+          this.isVideoInFullScreen
+            ? this.document.exitFullscreen()
+            : this.video.requestFullscreen();
+        }
       },
 
       setFullscreenButtonState() {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list