-
Notifications
You must be signed in to change notification settings - Fork 15
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
Surrogates test #32
Surrogates test #32
Changes from 3 commits
c132e31
0d325fe
ccade59
f6ba5fb
a37a71e
6e026ce
02c5c15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>Tracker surrogates</title> | ||
<script src='./main.js'></script> | ||
<style> | ||
#results-table { | ||
font-family: Arial, Helvetica, sans-serif; | ||
border-collapse: collapse; | ||
width: 70%; | ||
} | ||
|
||
#results-table td, #results-table th { | ||
border: 1px solid #ddd; | ||
padding: 8px; | ||
} | ||
|
||
#results-table th { | ||
padding-top: 12px; | ||
padding-bottom: 12px; | ||
text-align: left; | ||
background-color: #f2f2f2; | ||
color: black; | ||
} | ||
</style> | ||
</head> | ||
<body onload="loadSurrogates()"> | ||
<p><a href="../index.html">[Home]</a></p> | ||
|
||
<p><b>Test blocking and redirecting to a surrogate</b></p> | ||
<table id='results-table'> | ||
<tr><th>Surrogate</th><th>Loaded</th><th>Passed Test</th><th>Notes</th></tr> | ||
</table> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
function loadSurrogates () { | ||
|
||
for (const [name, testData] of Object.entries(surrogates)) { | ||
const s = document.createElement('script') | ||
testData.crossOrigin ? s.crossOrigin = testData.crossOrigin : '' | ||
s.src = testData.url | ||
|
||
s.onload = () => updateTable({name, testData}) | ||
s.onerror = (error) => updateTable({name, testData, error}) | ||
|
||
document.body.appendChild(s) | ||
} | ||
} | ||
|
||
function updateTable ({name, testData, error}) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we also have a global object with test results like in other tests? This way, when testing this page automatically, you will not need to scrape HTML, you'll just pull info from |
||
|
||
const table = document.getElementById('results-table') | ||
const row = table.insertRow(-1) | ||
const testName = row.insertCell(0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL about |
||
const loaded = row.insertCell(1) | ||
const passed = row.insertCell(2) | ||
const note = row.insertCell(3) | ||
|
||
// set default values and colors | ||
testName.innerText = name | ||
loaded.innerText = 'failed' | ||
passed.innerText = 'failed' | ||
row.style.backgroundColor = '#f97268' | ||
note.style.backgroundColor = "#ffff" | ||
|
||
if (!error || testData.shouldFail) { | ||
loaded.innerText = "pass" | ||
|
||
const result = testData.test() | ||
if (result) { | ||
passed.innerText = "pass" | ||
row.style.backgroundColor = '#71bf69' | ||
} else { | ||
loaded.innerText = "failed" | ||
} | ||
} | ||
|
||
if (testData.notes) { | ||
note.innerText = testData.notes | ||
} | ||
|
||
if (testData.cleanup) { | ||
testData.cleanup() | ||
} | ||
} | ||
|
||
const surrogates = { | ||
"google-analytics.com/analytics.js, crossOrigin" : { | ||
url: "https://google-analytics.com/analytics.js", | ||
crossOrigin: "anonymous", | ||
notes: "Test loading with crossOrigin set on element (should fail on Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1694679", | ||
test: () => { return window.ga.answer === 42 }, | ||
cleanUp: () => { delete window.ga } | ||
}, | ||
"google-analytics.com/analytics.js": { | ||
url: "https://google-analytics.com/analytics.js", | ||
test: () => { return window.ga.answer === 42 }, | ||
cleanUp: () => { delete window.ga } | ||
}, | ||
'google-analytics, ga.js': { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all other tests involve testing different configurations of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, not special, basically the same as analytics. I got rid of it. |
||
url: "https://google-analytics.com/ga.js", | ||
test: () => { return !!window._gaq }, | ||
cleanUp: () => { delete window._gaq } | ||
}, | ||
'Directly accessing a web resouce' : { | ||
url: "chrome-extension://lfpgfgegioonagopmelghcelfgffmjnh/web_accessible_resources/analytics.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wait, what extension ID is this? Doesn't look like ours: https://chrome.google.com/webstore/detail/duckduckgo-privacy-essent/bkdgflcldnnnapblkhphbgpggdiikppg ? |
||
notes: "Chromium browsers Only: need access key for web resources", | ||
shouldFail: true, | ||
test: () => { return true } | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move this to script to make the linter happy?