tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_autoplay_gvobserver_late_auth.html (1438B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4  <title>GeckoView asynchronous autoplay permission grant test (GVAutoplayObserver)</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <script type="text/javascript" src="manifest.js"></script>
      7  <script type="text/javascript" src="AutoplayTestUtils.js"></script>
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      9 </head>
     10 <body>
     11 <script>
     12 
     13 const TIMEOUT_IN_MS = 1000;
     14 SimpleTest.requestFlakyTimeout(`Need a ${TIMEOUT_IN_MS}ms timer to check whether autoplay begins.`);
     15 SimpleTest.requestCompleteLog();
     16 
     17 add_task(async function testGVDelayedAutoplayStart() {
     18  await SpecialPowers.pushPrefEnv({
     19    set: [
     20      // Below must be true to hit async permission code path
     21      // https://searchfox.org/mozilla-central/rev/6e2b186c296474e032d9ae2e000b7c870396775c/dom/media/autoplay/AutoplayPolicy.cpp#229-232
     22      ["media.geckoview.autoplay.request", true],
     23      // 8 = Generate asynchronous eALLOWED permission grants.
     24      ["media.geckoview.autoplay.request.testing", 8],
     25    ],
     26  });
     27 
     28  // Replicate setup for Bug 1913709
     29  const video = document.createElement("video");
     30  const playingPromise = once(video, "playing");
     31  video.muted = true;
     32  video.preload = "none";
     33  video.src = "short.mp4"
     34  video.setAttribute("autoplay", "");
     35 
     36  document.body.appendChild(video);
     37 
     38  await playingPromise;
     39  ok(true, "Video should autoplay.");
     40 });
     41 </script>
     42 </body>
     43 </html>