test_webgl_vendor_sanitize_fpp.html (2000B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>WebGL Vendor Sanitize with FPP - Vendor should be sanitized</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 WebGLVendorSanitize 10 await SpecialPowers.pushPrefEnv({ 11 set: [ 12 ["privacy.fingerprintingProtection", true], 13 ["privacy.fingerprintingProtection.overrides", "+WebGLVendorSanitize"], 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 WebGLVendorSanitize enabled, the vendor should be sanitized 41 // to one of the known values 42 let vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL); 43 44 // List of valid sanitized vendor strings 45 const validVendors = [ 46 "NVIDIA Corporation", 47 "Intel", 48 "AMD", 49 "Qualcomm", 50 "ARM", 51 "Apple", 52 "Samsung", 53 "Mesa", 54 "Microsoft", 55 "VMware", 56 "Google", 57 "Other" 58 ]; 59 60 SimpleTest.ok(validVendors.includes(vendor), 61 "UNMASKED_VENDOR_WEBGL should be sanitized to one of the known values. Got: " + vendor); 62 63 // Verify it's NOT "Mozilla" (which would indicate WebGLRenderInfo is active) 64 SimpleTest.isnot(vendor, "Mozilla", 65 "UNMASKED_VENDOR_WEBGL should be sanitized, not 'Mozilla' (WebGLRenderInfo not active)"); 66 67 SimpleTest.finish(); 68 }); 69 </script>