commit 67328f0f76c61e65dd869bdf25d636c06d3c48fb
parent 988dc26f437bd875ce8417a485cb50b550c86876
Author: Tom Ritter <tom@mozilla.com>
Date: Wed, 17 Dec 2025 17:44:39 +0000
Bug 1976287: Add an RFP Target to return a a constant WebGL Renderer r=timhuang
Differential Revision: https://phabricator.services.mozilla.com/D276244
Diffstat:
6 files changed, 154 insertions(+), 2 deletions(-)
diff --git a/dom/canvas/ClientWebGLContext.cpp b/dom/canvas/ClientWebGLContext.cpp
@@ -2406,7 +2406,8 @@ void ClientWebGLContext::GetParameter(JSContext* cx, GLenum pname,
case LOCAL_GL_RENDERER: {
bool allowRenderer = StaticPrefs::webgl_enable_renderer_query();
- if (ShouldResistFingerprinting(RFPTarget::WebGLRenderInfo)) {
+ if (ShouldResistFingerprinting(RFPTarget::WebGLRenderInfo) ||
+ ShouldResistFingerprinting(RFPTarget::WebGLRendererConstant)) {
allowRenderer = false;
}
if (allowRenderer) {
@@ -2446,7 +2447,8 @@ void ClientWebGLContext::GetParameter(JSContext* cx, GLenum pname,
switch (pname) {
case dom::WEBGL_debug_renderer_info_Binding::UNMASKED_RENDERER_WEBGL:
- if (ShouldResistFingerprinting(RFPTarget::WebGLRenderInfo)) {
+ if (ShouldResistFingerprinting(RFPTarget::WebGLRenderInfo) ||
+ ShouldResistFingerprinting(RFPTarget::WebGLRendererConstant)) {
ret = Some("Mozilla"_ns);
} else {
ret = GetUnmaskedRenderer();
diff --git a/dom/canvas/test/webgl-mochitest/mochitest.toml b/dom/canvas/test/webgl-mochitest/mochitest.toml
@@ -275,6 +275,12 @@ skip-if = [
["test_webgl_force_enable.html"]
+["test_webgl_renderer_constant_fpp.html"]
+
+["test_webgl_renderer_constant_fpp_explicit.html"]
+
+["test_webgl_renderer_constant_rfp.html"]
+
["test_webgl_request_context.html"]
skip-if = [
"os == 'android'", # bug 865443- seperate suite - the non_conf* tests pass except for one on armv6 tests
diff --git a/dom/canvas/test/webgl-mochitest/test_webgl_renderer_constant_fpp.html b/dom/canvas/test/webgl-mochitest/test_webgl_renderer_constant_fpp.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>WebGL Renderer Constant with FPP - Renderer should be "Mozilla"</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script>
+/* global SimpleTest SpecialPowers */
+SimpleTest.waitForExplicitFinish();
+document.addEventListener("DOMContentLoaded", async function() {
+ // Enable FPP with WebGLRendererConstant
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["privacy.fingerprintingProtection", true],
+ ["privacy.fingerprintingProtection.overrides", "+WebGLRendererConstant"],
+ ["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 WebGLRendererConstant enabled, the renderer should be "Mozilla"
+ let renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
+
+ SimpleTest.is(renderer, "Mozilla",
+ "UNMASKED_RENDERER_WEBGL should be 'Mozilla' with WebGLRendererConstant enabled");
+
+ SimpleTest.finish();
+});
+</script>
diff --git a/dom/canvas/test/webgl-mochitest/test_webgl_renderer_constant_fpp_explicit.html b/dom/canvas/test/webgl-mochitest/test_webgl_renderer_constant_fpp_explicit.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>WebGL Renderer Constant with FPP (explicit) - Renderer should be "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,+WebGLRendererConstant
+ // This ensures only WebGLRendererConstant is active, nothing else
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["privacy.fingerprintingProtection", true],
+ ["privacy.fingerprintingProtection.overrides", "-AllTargets,+WebGLRendererConstant"],
+ ["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 WebGLRendererConstant enabled, the renderer should be "Mozilla"
+ let renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
+
+ SimpleTest.is(renderer, "Mozilla",
+ "UNMASKED_RENDERER_WEBGL should be 'Mozilla' with WebGLRendererConstant enabled");
+
+ SimpleTest.finish();
+});
+</script>
diff --git a/dom/canvas/test/webgl-mochitest/test_webgl_renderer_constant_rfp.html b/dom/canvas/test/webgl-mochitest/test_webgl_renderer_constant_rfp.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>WebGL Renderer Constant with RFP - Renderer should be "Mozilla"</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script>
+/* global SimpleTest SpecialPowers */
+SimpleTest.waitForExplicitFinish();
+document.addEventListener("DOMContentLoaded", async function() {
+ // Enable RFP
+ await SpecialPowers.pushPrefEnv({
+ set: [["privacy.resistFingerprinting", true],
+ ["privacy.fingerprintingProtection.overrides", "+WebGLRendererConstant"],
+ ["privacy.fingerprintingProtection", true]]
+ });
+
+ 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 and the renderer should be "Mozilla"
+ let renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
+
+ SimpleTest.is(renderer, "Mozilla",
+ "UNMASKED_RENDERER_WEBGL should be 'Mozilla' with RFP enabled");
+
+ SimpleTest.finish();
+});
+</script>
diff --git a/toolkit/components/resistfingerprinting/RFPTargets.inc b/toolkit/components/resistfingerprinting/RFPTargets.inc
@@ -112,6 +112,7 @@ ITEM_VALUE(EfficientCanvasRandomization, 76)
ITEM_VALUE(WebGLVendorSanitize, 77)
ITEM_VALUE(WebGLVendorConstant, 78)
ITEM_VALUE(WebGLVendorRandomize, 79)
+ITEM_VALUE(WebGLRendererConstant, 80)
// !!! Adding a new target? Rename PointerId and repurpose it.