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

Add autoconsent test page #65

Merged
merged 4 commits into from
Nov 16, 2021
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
35 changes: 35 additions & 0 deletions features/autoconsent/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Autoconsent Test</title>

<script src='./main.js' defer></script>
</head>
<body>
<p><a href="/index.html">[Home]</a></p>

<p>Tests for automatic consent popup clicking.</P>

<p id="privacy-test-page-cmp-test">
This is a fake consent popup:
<button id="reject-all">This should be clicked automatically.</button>
</p>

<p>Real sites to test on:</p>
<details id="test-sites">
</details>

<template id="test-cmp-row">
<li>
<span class="cmp-name"></span>
<ul class="cmp-sites"></ul>
</li>
</template>
<template id="test-site-row">
<li><a href="" target="_blank" rel="noreferrer noopener"></a></li>
</template>

</body>
</html>
82 changes: 82 additions & 0 deletions features/autoconsent/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// populate test sites
const testSites = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this format is easier than keeping it in HTML? We use this format elsewhere and it's easier to update in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way is less verbose, and allows test-cases to be easily copied over to/from the tests in the autoconsent project: https://github.com/cliqz-oss/autoconsent/blob/master/addon/test.ts#L82-L91

Sourcepoint: [
'https://www.brianmadden.com/',
'https://www.channelpro.co.uk/news',
'https://www.csoonline.com/blogs',
'https://www.theguardian.com/',
'https://www.independent.co.uk/',
'https://www.n-tv.de/'
],
Onetrust: [
'https://www.accenture.com/',
'https://edition.cnn.com/',
'https://mailchimp.com/',
'https://www.okcupid.com/',
'https://arstechnica.com/',
'https://www.jeux.fr/',
'https://www.adobe.com/de/',
'https://genius.com/',
'https://bitbucket.org/',
'https://www.atlassian.com/',
'https://www.digitaltrends.com/',
'https://about.gitlab.com',
'https://research.polyu.edu.hk/en/publications/a-survey-of-intel-sgx-and-its-applications',
'https://www.lifewire.com/write-if-statements-in-bash-script-2200578',
'https://www.zoom.us'
],
Cybotcookiebot: [
'https://www.ab-in-den-urlaub.de/',
'https://www.vatera.hu/',
'https://www.smartsheet.com/'
],
Sirdata: [
'https://www.futura-sciences.com/',
'https://www.abcbourse.com/',
'https://www.journaldugeek.com/'
],
quantcast: [
'https://imgur.com',
'https://www.cyclingnews.com/',
'https://9gag.com',
'https://www.anandtech.com/',
'https://myanimelist.net/',
'https://www.techradar.com/',
'https://www.livescience.com',
'https://www.gamesradar.com'
],
'funding-choices': [
'https://www.dinarguru.com/'
],
'com_onetrust-stackoverflow': [
'https://stackoverflow.com/'
]
};
const root = document.getElementById('test-sites');
const cmpTemplate = document.getElementById('test-cmp-row');
const siteTemplate = document.getElementById('test-site-row');

Object.keys(testSites).forEach((cmpName) => {
const cmpEntry = cmpTemplate.content.cloneNode(true);
cmpEntry.querySelector('.cmp-name').innerText = cmpName;
const siteList = cmpEntry.querySelector('.cmp-sites');
testSites[cmpName].forEach((site) => {
const siteEntry = siteTemplate.content.cloneNode(true);
const link = siteEntry.querySelector('a');
link.setAttribute('href', site);
link.innerText = site;
siteList.appendChild(siteEntry);
});
root.appendChild(cmpEntry);
});

// dummy CMP
document.getElementById('reject-all').addEventListener('click', (ev) => {
ev.target.innerText = 'I was clicked!';
window.results.results.push('button_clicked');
});

window.results = {
page: 'autoconsent',
results: []
};
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ <h2>Browser Features</h2>
<li><a href="./features/canvas-draw.html">Canvas draw</a></li>
<li><a href="./features/download.html">Downloads</a></li>
<li><a href="./features/fonts.html">Fonts</a></li>
<li><a href="./features/autoconsent/">Cookie consent</a></li>
</ul>

<h2>Security</h2>
Expand Down