tor-browser

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

test_webgl_vendor_randomize_fpp_explicit.html (2141B)


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