From c132e312b362662a15aad0b1629a9211b47acba7 Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 3 Mar 2021 11:35:50 -0700 Subject: [PATCH 1/7] add surrogate tests --- index.html | 1 + privacy-protections/index.html | 3 +- .../surrogates/.index.html.swp | Bin 0 -> 12288 bytes privacy-protections/surrogates/index.html | 37 +++++++++ privacy-protections/surrogates/main.js | 73 ++++++++++++++++++ 5 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 privacy-protections/surrogates/.index.html.swp create mode 100644 privacy-protections/surrogates/index.html create mode 100644 privacy-protections/surrogates/main.js diff --git a/index.html b/index.html index bb1965e..f78b383 100644 --- a/index.html +++ b/index.html @@ -49,6 +49,7 @@

Privacy Protections Tests

  • Referrer trimming
  • HTTPS upgrades
  • Facebook click to load
  • +
  • Surrogates
  • Other

    diff --git a/privacy-protections/index.html b/privacy-protections/index.html index 02f921e..5b76b93 100644 --- a/privacy-protections/index.html +++ b/privacy-protections/index.html @@ -17,7 +17,8 @@

    Privacy Protections Tests

  • Referrer trimming
  • HTTPS upgrades
  • Facebook click to load
  • +
  • Surrogates
  • - \ No newline at end of file + diff --git a/privacy-protections/surrogates/.index.html.swp b/privacy-protections/surrogates/.index.html.swp new file mode 100644 index 0000000000000000000000000000000000000000..0b99db5fca0cd702026215684a0c10a125202aa5 GIT binary patch literal 12288 zcmeI2O=}ZD7=WjG6Kh5Pz%-@ALN=S!gC*Up)(@!FYQZXs2u^k;$+VlDWoFu@6ct7M z1NsB>5BL{6i)TNM;z1NV6cogR=sTNj)U@EqL*?D_bTaRJWr^;0V z&p|>e&yL^x>U|!X*hk0`Gb(ZMzdUnpp7G{cbW*8hZ$YbatRfZ?BDHt0ZNrk?|pp8kOW!ERPuUJ3$qei<7JT| z45eYv2wh&Z0hQ6qGHFqkaH<8D+SNNl-zv&zzvdZ4gn^%iBwNd9TZ?ABP%i&g3S9`V z&#I2N5%{b(HE`~zN@B25FSy@*W9G<2!C7q!#$9Xdy0d!={6;EPx(0c%Xn7j?4QN|h ztt8ybhsK(d?#B&U(X}3nWh<%CSTwDRrHpepfY(sgs!okoC)4ilajVj;;MgBxsBO~? zk|mMvQKM76wGE}YfUK%%ml_pIPRBUs(`0Z1UZR7c{+?@++jfl}tBhyI%64=|idkwz z&7C`Y_-$T+bg wvGqcBvN{*5G7?_afy>=m6}6c*0%m0ezwXxaOV9tpMo(WnwRmme4DI!Q0uA7AwEzGB literal 0 HcmV?d00001 diff --git a/privacy-protections/surrogates/index.html b/privacy-protections/surrogates/index.html new file mode 100644 index 0000000..cb831eb --- /dev/null +++ b/privacy-protections/surrogates/index.html @@ -0,0 +1,37 @@ + + + + + + Tracker surrogates + + + + +

    [Home]

    + +

    Test blocking and redirecting to a surrogate

    + + +
    SurrogateLoadedPassed TestNotes
    + + diff --git a/privacy-protections/surrogates/main.js b/privacy-protections/surrogates/main.js new file mode 100644 index 0000000..27b8c15 --- /dev/null +++ b/privacy-protections/surrogates/main.js @@ -0,0 +1,73 @@ +function loadSurrogates () { + + for (const [name, test] of Object.entries(surrogates)) { + const s = document.createElement('script') + test.crossOrigin ? s.crossOrigin = test.crossOrigin : '' + s.src = test.url + + s.onload = () => updateTable({name, test: test.test, notes: test.notes}) + s.onerror = (error) => updateTable({name, error, test: test.test, notes: test.notes, shouldFail: test.shouldFail}) + + document.body.appendChild(s) + + } +} + +function updateTable ({name, test, error='', notes = '', shouldFail}) { + + + const table = document.getElementById('results-table') + const row = table.insertRow(-1) + + const testName = row.insertCell(0) + const loaded = row.insertCell(1) + const passed = row.insertCell(2) + const note = row.insertCell(3) + + // set default values + testName.innerText = name + loaded.innerText = 'failed' + passed.innerText = 'failed' + row.style.backgroundColor = '#f97268' + note.style.backgroundColor = "#ffff" + + if (!error || shouldFail) { + loaded.innerText = "pass" + + const result = test() + if (result) { + passed.innerText = "pass" + row.style.backgroundColor = '#71bf69' + } else { + loaded.innerText = "failed" + } + } + + if (notes) { + note.innerText = notes + } +} + +const surrogates = { + 'google-analytics, 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 } + }, + 'google-analytics, analytics.js': { + url: "https://google-analytics.com/analytics.js", + test: () => { return window.ga.answer === 42 } + }, + 'google-analytics, ga.js': { + url: "https://google-analytics.com/ga.js", + test: () => { return !!window._gaq } + }, + 'Directly accessing a web resouce' : { + url: "chrome-extension://lfpgfgegioonagopmelghcelfgffmjnh/web_accessible_resources/analytics.js", + notes: "Chromium browsers Only: need access key for web resources", + shouldFail: true, + test: () => { return true } + } +} + From 0d325fe216d0949a26d3c3d51b9de6d53bcec574 Mon Sep 17 00:00:00 2001 From: jdorweiler Date: Thu, 4 Mar 2021 12:57:22 -0700 Subject: [PATCH 2/7] update test --- privacy-protections/surrogates/main.js | 42 ++++++++++++++------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/privacy-protections/surrogates/main.js b/privacy-protections/surrogates/main.js index 27b8c15..fb8415e 100644 --- a/privacy-protections/surrogates/main.js +++ b/privacy-protections/surrogates/main.js @@ -1,40 +1,37 @@ function loadSurrogates () { - for (const [name, test] of Object.entries(surrogates)) { + for (const [name, testData] of Object.entries(surrogates)) { const s = document.createElement('script') - test.crossOrigin ? s.crossOrigin = test.crossOrigin : '' - s.src = test.url + testData.crossOrigin ? s.crossOrigin = testData.crossOrigin : '' + s.src = testData.url - s.onload = () => updateTable({name, test: test.test, notes: test.notes}) - s.onerror = (error) => updateTable({name, error, test: test.test, notes: test.notes, shouldFail: test.shouldFail}) + s.onload = () => updateTable({name, testData}) + s.onerror = (error) => updateTable({name, testData, error}) document.body.appendChild(s) - } } -function updateTable ({name, test, error='', notes = '', shouldFail}) { - +function updateTable ({name, testData, error}) { const table = document.getElementById('results-table') const row = table.insertRow(-1) - const testName = row.insertCell(0) const loaded = row.insertCell(1) const passed = row.insertCell(2) const note = row.insertCell(3) - // set default values + // set default values and colors testName.innerText = name loaded.innerText = 'failed' passed.innerText = 'failed' row.style.backgroundColor = '#f97268' note.style.backgroundColor = "#ffff" - if (!error || shouldFail) { + if (!error || testData.shouldFail) { loaded.innerText = "pass" - const result = test() + const result = testData.test() if (result) { passed.innerText = "pass" row.style.backgroundColor = '#71bf69' @@ -43,25 +40,32 @@ function updateTable ({name, test, error='', notes = '', shouldFail}) { } } - if (notes) { - note.innerText = notes + if (testData.notes) { + note.innerText = testData.notes + } + + if (testData.cleanup) { + testData.cleanup() } } const surrogates = { - 'google-analytics, analytics.js, crossOrigin': { + "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 } + test: () => { return window.ga.answer === 42 }, + cleanUp: () => { delete window.ga } }, - 'google-analytics, analytics.js': { + "google-analytics.com/analytics.js": { url: "https://google-analytics.com/analytics.js", - test: () => { return window.ga.answer === 42 } + test: () => { return window.ga.answer === 42 }, + cleanUp: () => { delete window.ga } }, 'google-analytics, ga.js': { url: "https://google-analytics.com/ga.js", - test: () => { return !!window._gaq } + test: () => { return !!window._gaq }, + cleanUp: () => { delete window._gaq } }, 'Directly accessing a web resouce' : { url: "chrome-extension://lfpgfgegioonagopmelghcelfgffmjnh/web_accessible_resources/analytics.js", From ccade59b13072df27833d17ac5698789342a48d1 Mon Sep 17 00:00:00 2001 From: jdorweiler Date: Thu, 4 Mar 2021 13:29:59 -0700 Subject: [PATCH 3/7] remove temp file --- privacy-protections/surrogates/.index.html.swp | Bin 12288 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 privacy-protections/surrogates/.index.html.swp diff --git a/privacy-protections/surrogates/.index.html.swp b/privacy-protections/surrogates/.index.html.swp deleted file mode 100644 index 0b99db5fca0cd702026215684a0c10a125202aa5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2O=}ZD7=WjG6Kh5Pz%-@ALN=S!gC*Up)(@!FYQZXs2u^k;$+VlDWoFu@6ct7M z1NsB>5BL{6i)TNM;z1NV6cogR=sTNj)U@EqL*?D_bTaRJWr^;0V z&p|>e&yL^x>U|!X*hk0`Gb(ZMzdUnpp7G{cbW*8hZ$YbatRfZ?BDHt0ZNrk?|pp8kOW!ERPuUJ3$qei<7JT| z45eYv2wh&Z0hQ6qGHFqkaH<8D+SNNl-zv&zzvdZ4gn^%iBwNd9TZ?ABP%i&g3S9`V z&#I2N5%{b(HE`~zN@B25FSy@*W9G<2!C7q!#$9Xdy0d!={6;EPx(0c%Xn7j?4QN|h ztt8ybhsK(d?#B&U(X}3nWh<%CSTwDRrHpepfY(sgs!okoC)4ilajVj;;MgBxsBO~? zk|mMvQKM76wGE}YfUK%%ml_pIPRBUs(`0Z1UZR7c{+?@++jfl}tBhyI%64=|idkwz z&7C`Y_-$T+bg wvGqcBvN{*5G7?_afy>=m6}6c*0%m0ezwXxaOV9tpMo(WnwRmme4DI!Q0uA7AwEzGB From f6ba5fb68ea23b8d91e6abb8bb98e01754aadbbe Mon Sep 17 00:00:00 2001 From: jdorweiler Date: Tue, 9 Mar 2021 17:04:31 -0700 Subject: [PATCH 4/7] lint, global results --- privacy-protections/surrogates/index.html | 3 +- privacy-protections/surrogates/main.js | 108 +++++++++++----------- 2 files changed, 57 insertions(+), 54 deletions(-) diff --git a/privacy-protections/surrogates/index.html b/privacy-protections/surrogates/index.html index cb831eb..a3df7ee 100644 --- a/privacy-protections/surrogates/index.html +++ b/privacy-protections/surrogates/index.html @@ -4,7 +4,6 @@ Tracker surrogates - -

    [Home]

    Test blocking and redirecting to a surrogate

    @@ -34,4 +32,5 @@ SurrogateLoadedPassed TestNotes + diff --git a/privacy-protections/surrogates/main.js b/privacy-protections/surrogates/main.js index fb8415e..29e7172 100644 --- a/privacy-protections/surrogates/main.js +++ b/privacy-protections/surrogates/main.js @@ -1,77 +1,81 @@ -function loadSurrogates () { +const results = {} - 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}) { - - const table = document.getElementById('results-table') - const row = table.insertRow(-1) - const testName = row.insertCell(0) - const loaded = row.insertCell(1) - const passed = row.insertCell(2) - const note = row.insertCell(3) +function updateTable ({ name, testData, error }) { + const table = document.getElementById('results-table'); + const row = table.insertRow(-1); + const testName = row.insertCell(0); + 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" + testName.innerText = name; + loaded.innerText = 'failed'; + passed.innerText = 'failed'; + row.style.backgroundColor = '#f97268'; + note.style.backgroundColor = '#ffff'; + results[name] = {pass: true}; + if (!error || testData.shouldFail) { - loaded.innerText = "pass" + loaded.innerText = 'pass'; - const result = testData.test() + const result = testData.test(); if (result) { - passed.innerText = "pass" - row.style.backgroundColor = '#71bf69' + passed.innerText = 'pass'; + row.style.backgroundColor = '#71bf69'; } else { - loaded.innerText = "failed" + results[name].pass = false; + loaded.innerText = 'failed'; } } if (testData.notes) { - note.innerText = testData.notes + results[name].notes = testData.notes; + note.innerText = testData.notes; } if (testData.cleanup) { - 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, 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.com/analytics.js': { + url: 'https://google-analytics.com/analytics.js', + test: () => { return window.ga.answer === 42; }, + cleanUp: () => { delete window.ga; } }, 'google-analytics, ga.js': { - url: "https://google-analytics.com/ga.js", - test: () => { return !!window._gaq }, - cleanUp: () => { delete window._gaq } + 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", - notes: "Chromium browsers Only: need access key for web resources", + 'Directly accessing a web resouce': { + url: 'chrome-extension://bkdgflcldnnnapblkhphbgpggdiikppg/web_accessible_resources/analytics.js', + notes: 'Chromium browsers Only: need access key for web resources', shouldFail: true, - test: () => { return true } + test: () => { return true; } } -} - +}; + +(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); + } +})() + From a37a71e9b557a033a61ed920bf7ddabd514d1649 Mon Sep 17 00:00:00 2001 From: jdorweiler Date: Tue, 9 Mar 2021 17:12:45 -0700 Subject: [PATCH 5/7] =?UTF-8?q?make=20linter=20happy=20=F0=9F=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- privacy-protections/surrogates/main.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/privacy-protections/surrogates/main.js b/privacy-protections/surrogates/main.js index 29e7172..5a0b64f 100644 --- a/privacy-protections/surrogates/main.js +++ b/privacy-protections/surrogates/main.js @@ -1,4 +1,4 @@ -const results = {} +const results = {}; function updateTable ({ name, testData, error }) { const table = document.getElementById('results-table'); @@ -15,8 +15,8 @@ function updateTable ({ name, testData, error }) { row.style.backgroundColor = '#f97268'; note.style.backgroundColor = '#ffff'; - results[name] = {pass: true}; - + results[name] = { pass: true }; + if (!error || testData.shouldFail) { loaded.innerText = 'pass'; @@ -69,7 +69,11 @@ const surrogates = { (function loadSurrogates () { for (const [name, testData] of Object.entries(surrogates)) { const s = document.createElement('script'); - testData.crossOrigin ? s.crossOrigin = testData.crossOrigin : ''; + + if (testData.crossOrigin) { + s.crossOrigin = testData.crossOrigin; + } + s.src = testData.url; s.onload = () => updateTable({ name, testData }); @@ -77,5 +81,4 @@ const surrogates = { document.body.appendChild(s); } -})() - +})(); From 6e026ce759922425b43975c68240acec9de2de6e Mon Sep 17 00:00:00 2001 From: jdorweiler Date: Wed, 10 Mar 2021 08:31:35 -0700 Subject: [PATCH 6/7] update surrogate test --- privacy-protections/surrogates/main.js | 40 ++++++++++++++------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/privacy-protections/surrogates/main.js b/privacy-protections/surrogates/main.js index 5a0b64f..8063a14 100644 --- a/privacy-protections/surrogates/main.js +++ b/privacy-protections/surrogates/main.js @@ -35,8 +35,8 @@ function updateTable ({ name, testData, error }) { note.innerText = testData.notes; } - if (testData.cleanup) { - testData.cleanup(); + if (testData.cleanUp) { + testData.cleanUp(); } } @@ -45,19 +45,14 @@ const surrogates = { 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; }, + test: () => { return !!(window.ga && Object.keys(window.ga.create()).length === 0); }, cleanUp: () => { delete window.ga; } }, 'google-analytics.com/analytics.js': { url: 'https://google-analytics.com/analytics.js', - test: () => { return window.ga.answer === 42; }, + test: () => { return !!(window.ga && Object.keys(window.ga.create()).length === 0); }, cleanUp: () => { delete window.ga; } }, - 'google-analytics, ga.js': { - url: 'https://google-analytics.com/ga.js', - test: () => { return !!window._gaq; }, - cleanUp: () => { delete window._gaq; } - }, 'Directly accessing a web resouce': { url: 'chrome-extension://bkdgflcldnnnapblkhphbgpggdiikppg/web_accessible_resources/analytics.js', notes: 'Chromium browsers Only: need access key for web resources', @@ -66,19 +61,28 @@ const surrogates = { } }; -(function loadSurrogates () { +(async function loadSurrogates () { for (const [name, testData] of Object.entries(surrogates)) { - const s = document.createElement('script'); + await new Promise((resolve, reject) => { + const s = document.createElement('script'); - if (testData.crossOrigin) { - s.crossOrigin = testData.crossOrigin; - } + if (testData.crossOrigin) { + s.crossOrigin = testData.crossOrigin; + } + + s.onload = () => { + updateTable({ name, testData }); + resolve(); + }; - s.src = testData.url; + s.onerror = (error) => { + updateTable({ name, testData, error }); + resolve(); + }; - s.onload = () => updateTable({ name, testData }); - s.onerror = (error) => updateTable({ name, testData, error }); + s.src = testData.url; - document.body.appendChild(s); + document.body.appendChild(s); + }); } })(); From 02c5c15c6cfab5b344abd3289da7095e26b14e53 Mon Sep 17 00:00:00 2001 From: jdorweiler Date: Wed, 10 Mar 2021 10:22:48 -0700 Subject: [PATCH 7/7] update failing test logic --- privacy-protections/surrogates/main.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/privacy-protections/surrogates/main.js b/privacy-protections/surrogates/main.js index 8063a14..e09c094 100644 --- a/privacy-protections/surrogates/main.js +++ b/privacy-protections/surrogates/main.js @@ -17,7 +17,13 @@ function updateTable ({ name, testData, error }) { results[name] = { pass: true }; - if (!error || testData.shouldFail) { + let testPassed = true; + + if (!error && testData.shouldFail) { + testPassed = false; + } + + if (testPassed) { loaded.innerText = 'pass'; const result = testData.test(); @@ -45,11 +51,13 @@ const surrogates = { 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', + shouldFail: false, test: () => { return !!(window.ga && Object.keys(window.ga.create()).length === 0); }, cleanUp: () => { delete window.ga; } }, 'google-analytics.com/analytics.js': { url: 'https://google-analytics.com/analytics.js', + shouldFail: false, test: () => { return !!(window.ga && Object.keys(window.ga.create()).length === 0); }, cleanUp: () => { delete window.ga; } },