Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
<!DOCTYPE html>
<meta charset="utf-8">
<title>WebGL Vendor Randomize with FPP - Vendor should be randomized</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script>
/* global SimpleTest SpecialPowers */
SimpleTest.waitForExplicitFinish();
document.addEventListener("DOMContentLoaded", async function() {
// Enable FPP with WebGLVendorRandomize
await SpecialPowers.pushPrefEnv({
set: [
["privacy.fingerprintingProtection", true],
["privacy.fingerprintingProtection.overrides", "+WebGLVendorRandomize"],
["privacy.resistFingerprinting", false]
]
});
let canvas = document.body.appendChild(document.createElement("canvas"));
if (!canvas) {
SimpleTest.ok(false, "Cannot create canvas");
SimpleTest.finish();
return;
}
let gl = canvas.getContext("webgl");
if (!gl) {
SimpleTest.ok(false, "Cannot get WebGL context");
SimpleTest.finish();
return;
}
// Try to get the WEBGL_debug_renderer_info extension
let ext = gl.getExtension("WEBGL_debug_renderer_info");
if (!ext) {
SimpleTest.ok(false, "WEBGL_debug_renderer_info extension should be available with FPP");
SimpleTest.finish();
return;
}
// With FPP and WebGLVendorRandomize enabled, the vendor should be "Mozilla <Base64>"
let vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
// Verify it starts with "Mozilla "
SimpleTest.ok(vendor.startsWith("Mozilla "),
"UNMASKED_VENDOR_WEBGL should start with 'Mozilla ' with WebGLVendorRandomize enabled. Got: " + vendor);
// Verify it has additional content (the Base64 part)
SimpleTest.ok(vendor.length > "Mozilla ".length,
"UNMASKED_VENDOR_WEBGL should have Base64 suffix. Got: " + vendor);
// Verify the Base64 part looks like Base64 (alphanumeric and =)
let base64Part = vendor.substring("Mozilla ".length);
let base64Regex = /^[A-Za-z0-9+/=]+$/;
SimpleTest.ok(base64Regex.test(base64Part),
"Base64 part should be valid Base64. Got: " + base64Part);
SimpleTest.finish();
});
</script>