Skip to content

Commit

Permalink
Add delayed src setter test
Browse files Browse the repository at this point in the history
  • Loading branch information
sammacbeth committed Nov 3, 2023
1 parent 94c77d1 commit c6835cf
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion privacy-protections/surrogates/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ const surrogates = {

return promise;
}
},
'delayed-set': {
notes: 'Set script src after insert',
url: 'https://google-analytics.com/analytics.js',
delay: true,
test: checkSurrogate,
cleanUp: () => { delete window.ga; }
}
};

Expand All @@ -140,9 +147,17 @@ async function injectSurrogate (testData) {
resolve();
};

s.src = testData.url;
if (!testData.delay) {
s.src = testData.url;
}

document.body.appendChild(s);

if (testData.delay) {
setTimeout(() => {
s.src = testData.url;
}, 500);
}
});
}

Expand Down

0 comments on commit c6835cf

Please sign in to comment.