Bug 1217290 - Add test cases for WebGL fingerprinting resistance draft
authorChung-Sheng Fu <cfu@mozilla.com>
Thu, 27 Jul 2017 15:54:36 +0800
changeset 643925 e0357f9d7a6b861bf8f6ffa8cac62822e8fe62c6
parent 643924 d9b1a469e6b7f501b25aa4d535e64a98d31006ca
child 725443 2fcb9d0f7591a68ae17590d308615c9777815d77
push id73257
push userbmo:cfu@mozilla.com
push dateThu, 10 Aug 2017 08:27:09 +0000
bugs1217290
milestone56.0a1
Bug 1217290 - Add test cases for WebGL fingerprinting resistance MozReview-Commit-ID: LeEJ4V7iYto
browser/components/resistfingerprinting/test/mochitest/mochitest.ini
browser/components/resistfingerprinting/test/mochitest/test_webgl_parameters.html
--- a/browser/components/resistfingerprinting/test/mochitest/mochitest.ini
+++ b/browser/components/resistfingerprinting/test/mochitest/mochitest.ini
@@ -7,8 +7,9 @@ support-files =
 
 [test_device_sensor_event.html]
 [test_geolocation.html]
 scheme = https
 [test_reduce_time_precision.html]
 [test_hide_gamepad_info.html]
 support-files = test_hide_gamepad_info_iframe.html
 [test_speech_synthesis.html]
+[test_webgl_parameters.html]
new file mode 100644
--- /dev/null
+++ b/browser/components/resistfingerprinting/test/mochitest/test_webgl_parameters.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<meta charset="utf8">
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script>
+/* global SimpleTest SpecialPowers */
+SimpleTest.waitForExplicitFinish();
+document.addEventListener("DOMContentLoaded", async function() {
+  await SpecialPowers.pushPrefEnv({
+    set: [
+      ["privacy.resistFingerprinting", true]
+    ]
+  });
+
+  let canvas = document.getElementById("webgl-test");
+  SimpleTest.ok(canvas, "Get canvas");
+  let gl = canvas.getContext("webgl");
+  SimpleTest.ok(gl, "Get WebGL context");
+  SimpleTest.ok(gl.getParameter(gl.MAX_TEXTURE_SIZE) <= 2048, "MAX_TEXTURE_SIZE <= 2048");
+  SimpleTest.ok(gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE) <= 2048, "MAX_CUBE_MAP_TEXTURE_SIZE <= 2048");
+  SimpleTest.ok(gl.getParameter(gl.MAX_RENDERBUFFER_SIZE) <= 2048, "MAX_RENDERBUFFER_SIZE <= 2048");
+  SimpleTest.ok(gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS) <= 8, "MAX_VERTEX_TEXTURE_IMAGE_UNITS <= 8");
+  SimpleTest.ok(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS) <= 8, "MAX_TEXTURE_IMAGE_UNITS <= 8");
+  SimpleTest.ok(gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS) <= 16, "MAX_COMBINED_TEXTURE_IMAGE_UNITS <= 16");
+  SimpleTest.ok(gl.getParameter(gl.MAX_VERTEX_ATTRIBS) <= 16, "MAX_VERTEX_ATTRIBS <= 16");
+  SimpleTest.ok(gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS) <= 256, "MAX_VERTEX_UNIFORM_VECTORS <= 256");
+  SimpleTest.ok(gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS) <= 224, "MAX_FRAGMENT_UNIFORM_VECTORS <= 224");
+  SimpleTest.ok(gl.getParameter(gl.MAX_VARYING_VECTORS) <= 8, "MAX_VARYING_VECTORS <= 8");
+  let viewportDims = gl.getParameter(gl.MAX_VIEWPORT_DIMS);
+  SimpleTest.ok(viewportDims[0] <= 4096, "MAX_VIEWPORT_DIMS[0] <= 4096");
+  SimpleTest.ok(viewportDims[1] <= 4096, "MAX_VIEWPORT_DIMS[1] <= 4096");
+  let aliasedPointSizeRange = gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE);
+  SimpleTest.ok(aliasedPointSizeRange[0] <= 1, "ALIASED_POINT_SIZE_RANGE[0] <= 1");
+  SimpleTest.ok(aliasedPointSizeRange[1] <= 63, "ALIASED_POINT_SIZE_RANGE[1] <= 63");
+  let aliasedLineWIdthRange = gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE);
+  SimpleTest.ok(aliasedLineWIdthRange[0] <= 1, "ALIASED_LINE_WIDTH_RANGE[0] <= 1");
+  SimpleTest.ok(aliasedLineWIdthRange[1] <= 5, "ALIASED_LINE_WIDTH_RANGE[1] <= 5");
+  SimpleTest.finish();
+});
+</script>
+<canvas id="webgl-test"></canvas>