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