22 * Tests for fingerprint defenses. Ensure that fingerprinting is actually being blocked.
33 */
44import { test as base , expect } from '@playwright/test' ;
5- import { testContextForExtension } from './helpers/harness.js' ;
5+ import { testContextForExtension , gotoAndWait } from './helpers/harness.js' ;
66import { createRequire } from 'node:module' ;
77
88// eslint-disable-next-line no-redeclare
@@ -23,13 +23,23 @@ const expectedFingerprintValues = {
2323
2424const pagePath = '/index.html' ;
2525const tests = [ { url : `http://localhost:3220${ pagePath } ` } , { url : `http://127.0.0.1:8383${ pagePath } ` } ] ;
26+ const enabledCanvasArgs = {
27+ site : {
28+ enabledFeatures : [ 'fingerprintingCanvas' ] ,
29+ } ,
30+ featureSettings : {
31+ fingerprintingCanvas : {
32+ additionalEnabledCheck : 'enabled' ,
33+ } ,
34+ } ,
35+ } ;
2636
2737test . describe . serial ( 'All Fingerprint Defense Tests (must run in serial)' , ( ) => {
2838 test . describe . serial ( 'Fingerprint Defense Tests' , ( ) => {
2939 for ( const _test of tests ) {
3040 test ( `${ _test . url } should include anti-fingerprinting code` , async ( { page, altServerPort } ) => {
3141 console . log ( 'running:' , altServerPort ) ;
32- await page . goto ( _test . url ) ;
42+ await gotoAndWait ( page , _test . url , enabledCanvasArgs ) ;
3343 const values = await page . evaluate ( ( ) => {
3444 return {
3545 // @ts -expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
@@ -64,7 +74,7 @@ test.describe.serial('All Fingerprint Defense Tests (must run in serial)', () =>
6474 * @param {tests[number] } test
6575 */
6676 async function runTest ( page , test ) {
67- await page . goto ( test . url ) ;
77+ await gotoAndWait ( page , test . url , enabledCanvasArgs ) ;
6878 const lib = require . resolve ( '@fingerprintjs/fingerprintjs/dist/fp.js' ) ;
6979 await page . addScriptTag ( { path : lib } ) ;
7080
@@ -117,7 +127,7 @@ test.describe.serial('All Fingerprint Defense Tests (must run in serial)', () =>
117127 tests . forEach ( ( testCase ) => {
118128 test ( `Fingerprints should not match across first parties ${ testCase . url } ` , async ( { page, altServerPort } ) => {
119129 console . log ( 'running:' , altServerPort ) ;
120- await page . goto ( testCase . url ) ;
130+ await gotoAndWait ( page , testCase . url , enabledCanvasArgs ) ;
121131
122132 // give it another second just to be sure
123133 await page . waitForTimeout ( 1000 ) ;
0 commit comments