Skip to content

Commit

Permalink
Introduce bounce tracking test page. (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdzwinel authored Sep 24, 2024
1 parent 6338a1b commit da7719b
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ <h2>Privacy Protections Tests</h2>
<li><a href='./privacy-protections/query-parameters/'>Query Parameters</a></li>
<li><a href='./content-scope-scripts/runtime-checks/'>Runtime checks</a></li>
<li><a href='./privacy-protections/local-port-scan/'>Local port scanning</a></li>
<li><a href='./privacy-protections/bounce-tracking/'>Bounce tracking</a></li>
</ul>

<h2 id="autofill">Autofill</h2>
Expand Down
53 changes: 53 additions & 0 deletions privacy-protections/bounce-tracking/bounce.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bounce Tracking Test Page - Bounce Page</title>
</head>
<body>

<p>Log:</p>
<textarea id='note' style='width: 500px; height: 200px;' readonly></textarea>

<script>
const destinationSafelist = ['privacy-test-pages.site', 'first-party.site', 'good.third-party.site', '127.0.0.1:3000'];
const fieldName = 'bounceUID';
let uid = localStorage.getItem(fieldName);
const pageURL = new URL(location.href);

function say (text) {
document.getElementById('note').value += text + '\n';
}

function run () {
if (!uid) {
say('No ID found, generating new ID. ');

uid = Math.round(Math.random() * 100);
localStorage.setItem(fieldName, uid);
}
say(`ID is ${uid}.`);

if (!pageURL.searchParams.has('destination')) {
say('No destination provided.');
} else {
const destination = pageURL.searchParams.get('destination');
const delay = Number.parseInt(pageURL.searchParams.get('delay')) || 0;

if (!destinationSafelist.includes(destination)) {
say(`Invalid destination '${destination}'.`);
} else {
const redirectURL = new URL(`/privacy-protections/bounce-tracking/?bounceUIDlocalStorage=${uid}`, 'https://' + destination);
say(`Redirecting to '${redirectURL.toString()}'.`);

setTimeout(() => { location.href = redirectURL; }, delay);
}
}
}

run();
</script>

</body>
</html>
30 changes: 30 additions & 0 deletions privacy-protections/bounce-tracking/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bounce Tracking Test Page</title>

<script src='./main.js' defer></script>
</head>
<body>
<p><a href="../../">[Home]</a><a href="../">[Privacy Protections Tests]</a><strong>[Bounce Tracking Test Page]</strong></p>

<p>Below links allow to bounce of bad.third-party.site to different locations. bad.third-party.site will pass its local UID to the destination via URL param.</p>

<p><a href='https://bad.third-party.site/privacy-protections/bounce-tracking/bounce.html?destination=good.third-party.site'>Go to good.third-party.site</a></p>
<p><a href='https://bad.third-party.site/privacy-protections/bounce-tracking/bounce.html?destination=first-party.site'>Go to first-party.site</a></p>
<p><a href='https://bad.third-party.site/privacy-protections/bounce-tracking/bounce.html?destination=privacy-test-pages.site'>Go to privacy-test-pages.site</a></p>
<!--<p><a href='./bounce.html?destination=127.0.0.1:3000'>Bounce local test</a></p>-->

<p id="result" style="font-weight: bold;"></p>

<script>
const pageURL = new URL(location.href);

if (pageURL.searchParams.has('bounceUIDlocalStorage')) {
document.getElementById('result').innerText = `ID received back is "${pageURL.searchParams.get('bounceUIDlocalStorage')}".`;
}
</script>
</body>
</html>
1 change: 1 addition & 0 deletions privacy-protections/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ <h1>Privacy Protections Tests</h1>
<li><a href='./amp-loop-protection/'>AMP Loop Protection</a></li>
<li><a href='./query-parameters/'>Query Parameters</a></li>
<li><a href='./local-port-scan/'>Local port scanning</a></li>
<li><a href='./bounce-tracking/'>Bounce tracking</a></li>
</ul>

</body>
Expand Down

0 comments on commit da7719b

Please sign in to comment.