diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js')
-rw-r--r-- | toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js | 42 |
1 files changed, 4 insertions, 38 deletions
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js index 723d7382f8..4bf0f34811 100644 --- a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js +++ b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js @@ -35,29 +35,7 @@ var TEST_CASES = [ return [imageData.data, imageDataSecond.data]; }, - isDataRandomized(name, data1, data2, isCompareOriginal) { - let diffCnt = countDifferencesInUint8Arrays(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - - // The Canvas randomization adds at most 512 bits noise to the image data. - // We compare the image data arrays to see if they are different and the - // difference is within the range. - - // If we are compare two randomized arrays, the difference can be doubled. - let expected = isCompareOriginal - ? NUM_RANDOMIZED_CANVAS_BITS - : NUM_RANDOMIZED_CANVAS_BITS * 2; - - // The number of difference bits should never bigger than the expected - // number. It could be zero if the randomization is disabled. - Assert.lessOrEqual( - diffCnt, - expected, - "The number of noise bits is expected." - ); - - return diffCnt <= expected && diffCnt > 0; - }, + isDataRandomized: isDataRandomizedFuzzy, }, { name: "OffscreenCanvas.convertToBlob() with a 2d context", @@ -94,11 +72,7 @@ var TEST_CASES = [ return [data, dataSecond]; }, - isDataRandomized(name, data1, data2) { - let diffCnt = countDifferencesInArrayBuffers(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - return diffCnt > 0; - }, + isDataRandomized: isDataRandomizedGreaterThanZero, }, { name: "OffscreenCanvas.convertToBlob() with a webgl context", @@ -140,11 +114,7 @@ var TEST_CASES = [ return [data, dataSecond]; }, - isDataRandomized(name, data1, data2) { - let diffCnt = countDifferencesInArrayBuffers(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - return diffCnt > 0; - }, + isDataRandomized: isDataRandomizedGreaterThanZero, }, { name: "OffscreenCanvas.convertToBlob() with a bitmaprenderer context", @@ -187,11 +157,7 @@ var TEST_CASES = [ return [data, dataSecond]; }, - isDataRandomized(name, data1, data2) { - let diffCnt = countDifferencesInArrayBuffers(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - return diffCnt > 0; - }, + isDataRandomized: isDataRandomizedGreaterThanZero, }, ]; |