How to detect "privacy.resistFingerprinting"

I’m using OffscreenCanvas API in my addon and some users complains that it won’t work and it’s because of the privacy.resistFingerprinting.randomDataOnCanvasExtract.

Is there a simple way to detect that the privacy.resistFingerprinting is enabled?

I’ve probably misunderstood the question, but can’t you use the privacy API?

let setting = await browser.privacy.websites.resistFingerprinting.get({});

1 Like

That’s interesting, I didn’t know there is a “privacy” API.
Sadly, it requires “privacy” permission which would be alerted to users.

In any case, just hour ago I’ve finished implementing a manual test of canvas which draws a 2x2 px image and then exports it as Base64 string and I compares it with what’s expected:

export function testOffscreenCanvas() {
  if (!self.OffscreenCanvas) return false;
  const offscreen = new self.OffscreenCanvas(2, 2);
  const canvas = offscreen.getContext('2d');
  canvas.fillStyle = "rgb(255, 0, 0)";
  canvas.fillRect(0, 0, 1, 1);
  const base64 = await blobToDataUrl(await offscreen.convertToBlob({type: 'image/png'}));
  // the string represents 4 pixels, one red and 3 white
  const isOK = base64 === 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFElEQVQIW2P8z8Dwn5GBgRGIIQAAHyUCAymYnnsAAAAASUVORK5CYII=';
  if (!isOK) console.log('canvas test failed, is "privacy.resistFingerprinting" enabled?');
  return isOK;
}
1 Like