-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce bounce tracking test page. (#229)
- Loading branch information
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters