Skip to content

Commit

Permalink
Enable single test runs (#98)
Browse files Browse the repository at this point in the history
* Add test delays and individual tests

* Call after delay

* lint

* Pass around testid

* Prevent passing undefined testid

* Typo
  • Loading branch information
SlayterDev authored Aug 31, 2022
1 parent 5319fac commit d1e81db
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
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

0 comments on commit d1e81db

Please sign in to comment.