tor-browser

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

test_webgl_vendor_randomize_fpp.html (2028B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>WebGL Vendor Randomize with FPP - Vendor should be randomized</title>
      4 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      5 <script>
      6 /* global SimpleTest SpecialPowers */
      7 SimpleTest.waitForExplicitFinish();
      8 document.addEventListener("DOMContentLoaded", async function() {
      9  // Enable FPP with WebGLVendorRandomize
     10  await SpecialPowers.pushPrefEnv({
     11    set: [
     12      ["privacy.fingerprintingProtection", true],
     13      ["privacy.fingerprintingProtection.overrides", "+WebGLVendorRandomize"],
     14      ["privacy.resistFingerprinting", false]
     15    ]
     16  });
     17 
     18  let canvas = document.body.appendChild(document.createElement("canvas"));
     19  if (!canvas) {
     20    SimpleTest.ok(false, "Cannot create canvas");
     21    SimpleTest.finish();
     22    return;
     23  }
     24 
     25  let gl = canvas.getContext("webgl");
     26  if (!gl) {
     27    SimpleTest.ok(false, "Cannot get WebGL context");
     28    SimpleTest.finish();
     29    return;
     30  }
     31 
     32  // Try to get the WEBGL_debug_renderer_info extension
     33  let ext = gl.getExtension("WEBGL_debug_renderer_info");
     34  if (!ext) {
     35    SimpleTest.ok(false, "WEBGL_debug_renderer_info extension should be available with FPP");
     36    SimpleTest.finish();
     37    return;
     38  }
     39 
     40  // With FPP and WebGLVendorRandomize enabled, the vendor should be "Mozilla <Base64>"
     41  let vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
     42 
     43  // Verify it starts with "Mozilla "
     44  SimpleTest.ok(vendor.startsWith("Mozilla "),
     45    "UNMASKED_VENDOR_WEBGL should start with 'Mozilla ' with WebGLVendorRandomize enabled. Got: " + vendor);
     46 
     47  // Verify it has additional content (the Base64 part)
     48  SimpleTest.ok(vendor.length > "Mozilla ".length,
     49    "UNMASKED_VENDOR_WEBGL should have Base64 suffix. Got: " + vendor);
     50 
     51  // Verify the Base64 part looks like Base64 (alphanumeric and =)
     52  let base64Part = vendor.substring("Mozilla ".length);
     53  let base64Regex = /^[A-Za-z0-9+/=]+$/;
     54  SimpleTest.ok(base64Regex.test(base64Part),
     55    "Base64 part should be valid Base64. Got: " + base64Part);
     56 
     57  SimpleTest.finish();
     58 });
     59 </script>