tor-browser

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

test_bug1354633_media_error.html (1434B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      4 <script>
      5 /* global SimpleTest SpecialPowers */
      6 
      7 let errorMessageMap = {};
      8 
      9 let testPromise = (resistFingerprinting, src, allowlist) => new Promise(resolve => {
     10  let video = document.createElement("video");
     11  video.src = src;
     12  video.controls = "true";
     13  video.onerror = () => {
     14    let message = video.error.message;
     15    if (!resistFingerprinting) {
     16      SimpleTest.isnot(message, "", "Message should not be blank");
     17      SimpleTest.info(src + ": " + message);
     18      errorMessageMap[src] = message;
     19    } else if (allowlist) {
     20      SimpleTest.is(message, allowlist, "Error message in allowlist: " + allowlist);
     21    } else {
     22      SimpleTest.is(message, "", "Blank error message: " + errorMessageMap[src]);
     23    }
     24    resolve();
     25  };
     26  document.body.appendChild(video);
     27 });
     28 
     29 async function testBody(resistFingerprinting) {
     30  await SpecialPowers.pushPrefEnv({
     31    set: [
     32      ["privacy.resistFingerprinting", resistFingerprinting],
     33    ],
     34  });
     35  await testPromise(
     36    resistFingerprinting,
     37    "load_error.mp4",
     38    "404: Not Found" // allowlist
     39  );
     40  await testPromise(
     41    resistFingerprinting,
     42    "decode_error.mp4",
     43    false // allowlist
     44  );
     45 }
     46 
     47 SimpleTest.waitForExplicitFinish();
     48 document.addEventListener("DOMContentLoaded", async () => {
     49  await testBody(false);
     50  await testBody(true);
     51  SimpleTest.finish();
     52 });
     53 </script>