Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable single test runs #98

Merged
merged 8 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions privacy-protections/referrer-trimming/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
<p>This page will test if, and how, referrer header value changes in various scenarios.</p>
<p>⚠️ Please note that the page will redirect couple of times after you start the test. This is expected, please wait till all the tests finish.</p>

<details id="manual-tests">
<summary id='manual-summary'>Manual Tests</summary>
<ul>
<li><a href="/come-back?testid=1p%20navigation">1p navigation</a></li>
<li><a href="https://good.third-party.site/come-back?testid=3p%20navigation">3p navigation</a></li>
<li><a href="https://bad.third-party.site/come-back?testid=3p%20tracker%20navigation">3p tracker navigation</a></li>
</ul>
</details>

<p><button id='start'>Start test</button></p>

<details id='tests' hidden>
Expand Down
14 changes: 9 additions & 5 deletions privacy-protections/referrer-trimming/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const results = {
// list of localStorage entries with partial test results that we need to clear at the end of all testing
const lsEntriesToClear = [];

function generateNavigationTest (url) {
function generateNavigationTest (url, testid) {
const key = `referrer-trimming-${url}`;
lsEntriesToClear.push(key);
const currentURL = new URL(location.href);
Expand All @@ -40,6 +40,10 @@ function generateNavigationTest (url) {

return result;
} else { // test haven't run yet
if (testid) {
url += `?testid=${testid}`;
}

window.location.href = url;

// let test runner know that it should not run other tests
Expand Down Expand Up @@ -81,15 +85,15 @@ function generateFrameTest (url) {
const tests = [
{
id: '1p navigation',
run: () => generateNavigationTest('/come-back')
run: (testid) => generateNavigationTest('/come-back', testid)
},
{
id: '3p navigation',
run: () => generateNavigationTest('https://good.third-party.site/come-back')
run: (testid) => generateNavigationTest('https://good.third-party.site/come-back', testid)
},
{
id: '3p tracker navigation',
run: () => generateNavigationTest('https://bad.third-party.site/come-back')
run: (testid) => generateNavigationTest('https://bad.third-party.site/come-back', testid)
},
{
id: '1p request',
Expand Down Expand Up @@ -168,7 +172,7 @@ function runTests () {
testsDetailsDiv.appendChild(li);

try {
const result = test.run();
const result = test.run(paramTestId);

if (result === 'stop') {
updateSummary();
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ app.get('/come-back', (req, res) => {
const jsReferrer = document.referrer;
document.body.innerHTML += '<p>header: <strong>${req.headers.referer || ''}</strong></p><p>js: <strong>' + jsReferrer + '</strong></p>';
setTimeout(() => {
location.href = 'https://privacy-test-pages.glitch.me/privacy-protections/referrer-trimming/?run&header=${req.headers.referer || ''}&js=' + jsReferrer;
location.href = 'https://privacy-test-pages.glitch.me/privacy-protections/referrer-trimming/?run&header=${req.headers.referer || ''}&js=' + jsReferrer + '&testid=${req.query.testid || ''}';
}, 1000);
</script>
</body>
Expand Down