tor-browser

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

autoplaypolicy_media_element.html (1688B)


      1 <!DOCTYPE html>
      2 <title>Autoplay policy basic behavior test for media element</title>
      3 <script src="/common/media.js"></script>
      4 <script src=/resources/testharness.js></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script>
      7 
      8 promise_test(async function playAudibleMediaElement() {
      9  const video = document.createElement('video');
     10  video.src = getVideoURI('/media/movie_5');
     11  await new Promise(r => video.onloadedmetadata = r);
     12  const startPlaying = await video.play().then(_ => true, _ => false);
     13  if (startPlaying) {
     14    assert_equals(
     15      window.navigator.getAutoplayPolicy(video),
     16      "allowed",
     17      'Correct value when audible video is allowed to play');
     18  } else {
     19    assert_in_array(
     20      window.navigator.getAutoplayPolicy(video),
     21      ["disallowed", "allowed-muted"],
     22      'Correct value when audible video is not allowed to play'
     23    );
     24  }
     25 }, "Check autoplay policy when playing audible media element");
     26 
     27 promise_test(async function playInaudibleMediaElement() {
     28  const video = document.createElement('video');
     29  video.src = getVideoURI('/media/movie_5');
     30  video.muted = true;
     31  await new Promise(r => video.onloadedmetadata = r);
     32  const startPlaying = await video.play().then(_ => true, _ => false);
     33  if (startPlaying) {
     34    assert_in_array(
     35      window.navigator.getAutoplayPolicy(video),
     36      ["allowed", "allowed-muted"],
     37      'Correct value when inaudible video is allowed to play');
     38  } else {
     39    assert_equals(
     40      window.navigator.getAutoplayPolicy(video),
     41      "disallowed",
     42      'Correct value when inaudible video is not allowed to play'
     43    );
     44  }
     45 }, "Check autoplay policy when playing inaudible media element");
     46 
     47 </script>