commit 88e897fd97c61714e4f03d19ef23b6de43bfcb1c
parent 0513c93aee2080340797e7e846c4d80ba8190fd6
Author: Tom Ritter <tom@mozilla.com>
Date: Wed, 17 Dec 2025 17:44:39 +0000
Bug 1976287: Add tests for the constant WebGL Vendor r=timhuang
Differential Revision: https://phabricator.services.mozilla.com/D276180
Diffstat:
4 files changed, 150 insertions(+), 0 deletions(-)
diff --git a/dom/canvas/test/webgl-mochitest/mochitest.toml b/dom/canvas/test/webgl-mochitest/mochitest.toml
@@ -265,6 +265,12 @@ skip-if = [
# 2020-01-07 00:00:11.839 F/MOZ_Assert( 6742): Assertion failure: [GFX1]: void mozilla::gl::GLContext::raw_fClear(GLbitfield): Generated unexpected GL_OUT_OF_MEMORY error, at /builds/worker/workspace/build/src/gfx/2d/Logging.h:746
# 2020-01-07 00:01:28.281 F/MOZ_Assert( 8333): Assertion failure: [GFX1]: Unexpected error from driver: DoCompressedTexSubImage(0x0de1, 0, 0,4,0, 4,4,1, 0x9270, 8) -> 0x0501, at /builds/worker/workspace/build/src/gfx/2d/Logging.h:746
+["test_webgl_constant_vendor_fpp.html"]
+
+["test_webgl_constant_vendor_fpp_explicit.html"]
+
+["test_webgl_constant_vendor_rfp.html"]
+
["test_webgl_fingerprinting_resistance.html"]
["test_webgl_force_enable.html"]
diff --git a/dom/canvas/test/webgl-mochitest/test_webgl_constant_vendor_fpp.html b/dom/canvas/test/webgl-mochitest/test_webgl_constant_vendor_fpp.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>WebGL Constant Vendor with FPP - Vendor should be constant "Mozilla"</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script>
+/* global SimpleTest SpecialPowers */
+SimpleTest.waitForExplicitFinish();
+document.addEventListener("DOMContentLoaded", async function() {
+ // Enable FPP with WebGLVendorConstant
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["privacy.fingerprintingProtection", true],
+ ["privacy.fingerprintingProtection.overrides", "+WebGLVendorConstant"],
+ ["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 WebGLVendorConstant enabled, the vendor should be "Mozilla"
+ let vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
+ SimpleTest.is(vendor, "Mozilla", "UNMASKED_VENDOR_WEBGL should be constant 'Mozilla' with WebGLVendorConstant enabled");
+
+ SimpleTest.finish();
+});
+</script>
diff --git a/dom/canvas/test/webgl-mochitest/test_webgl_constant_vendor_fpp_explicit.html b/dom/canvas/test/webgl-mochitest/test_webgl_constant_vendor_fpp_explicit.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>WebGL Constant Vendor with FPP (explicit) - Vendor should be constant "Mozilla"</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script>
+/* global SimpleTest SpecialPowers */
+SimpleTest.waitForExplicitFinish();
+document.addEventListener("DOMContentLoaded", async function() {
+ // Enable FPP with explicit -AllTargets,+WebGLVendorConstant
+ // This ensures only WebGLVendorConstant is active, nothing else
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["privacy.fingerprintingProtection", true],
+ ["privacy.fingerprintingProtection.overrides", "-AllTargets,+WebGLVendorConstant"],
+ ["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 WebGLVendorConstant enabled, the vendor should be "Mozilla"
+ let vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
+ SimpleTest.is(vendor, "Mozilla", "UNMASKED_VENDOR_WEBGL should be constant 'Mozilla' with WebGLVendorConstant enabled");
+
+ SimpleTest.finish();
+});
+</script>
diff --git a/dom/canvas/test/webgl-mochitest/test_webgl_constant_vendor_rfp.html b/dom/canvas/test/webgl-mochitest/test_webgl_constant_vendor_rfp.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>WebGL Constant Vendor with RFP - WebGLRenderInfo takes precedence</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script>
+/* global SimpleTest SpecialPowers */
+SimpleTest.waitForExplicitFinish();
+document.addEventListener("DOMContentLoaded", async function() {
+ // Enable RFP - WebGLRenderInfo should take precedence over WebGLVendorConstant
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["privacy.resistFingerprinting", true],
+ ["privacy.fingerprintingProtection", true],
+ ["privacy.fingerprintingProtection.overrides", "+WebGLVendorConstant"],
+ ]
+ });
+
+ 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 RFP");
+ SimpleTest.finish();
+ return;
+ }
+
+ // With RFP enabled, WebGLRenderInfo takes precedence over WebGLVendorConstant
+ // The vendor should be "Mozilla"
+ let vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
+ SimpleTest.is(vendor, "Mozilla", "UNMASKED_VENDOR_WEBGL should be 'Mozilla' with RFP enabled (WebGLRenderInfo precedence)");
+
+ // Also check renderer for completeness
+ let renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
+ SimpleTest.is(renderer, "Mozilla", "UNMASKED_RENDERER_WEBGL should be 'Mozilla' with RFP enabled");
+
+ SimpleTest.finish();
+});
+</script>