-
-
Notifications
You must be signed in to change notification settings - Fork 391
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
added option to disable DNT policy checking #1391
Conversation
Cool, thank you, I'll go over this tomorrow. Looks like some tests are failing; let me know if I can help getting them to run locally. For our reference, here is where the toggle happened in the legacy Firefox repo: EFForg/privacybadgerfirefox-legacy#236 |
One bit of feedback I have now is that in order for Privacy Badger to continue to function as a force for effecting positive change on the Web, Do Not Track policy checking must be enabled by default. |
erg. I'll have to get selenium running to see what I broke. darn! BTW it's enabled by default! edit: ARG I'M DUMB. it was not enabled by default. All the tests that expected DNT to work broke, obviously. 😅 |
src/skin/options.html
Outdated
<input type="checkbox" id="check_dnt_policy_checkbox"> | ||
<span class="i18n_options_dnt_policy_setting"></span> | ||
</label> | ||
<a target="_blank" href="https://www.eff.org/dnt-policy"/><span class="i18n_options_dnt_policy_learn_more"></span></a> |
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.
Typo: unwanted "/" in opening "a" tag.
src/tests/tests/background.js
Outdated
|
||
assert.expect(NUM_TESTS); | ||
|
||
badger.isCheckingDNTPolicyEnabled = () => false; |
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.
Should just change (and restore) the setting inside this test. Since we don't reuse this override, no need for "before" and "after" bits, I think.
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.
I've been thinking about this one. I think this needs to be more generalized for the state of the local storage in all unit tests. The thing that happens in the storage.js test should happen in all tests. All unit tests should save the local storage, replace with a standard one, and per test change it depending on the thing they are looking at. I think this wasn't done before because I think all the unit tests just avoided messing with anything that changed with settings.
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.
Agree that the fact that unit tests can modify local settings when run against your local Badger is a bug. It would be good to get it fixed, but it's not a blocker for this pull request.
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.
K. in the mean time I'll move the set and unset bits to this test, and mark it with a TODO
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.
OK now I think we are running into an annoying async test issue. I'm seeing other DNT-related tests break I think because we don't restore isCheckingDNTPolicyEnabled
at exactly the right time: restoring at the end of the test isn't guaranteed to work because the test is async.
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.
Ah, never mind, I somehow modified my local settings messing with the tests. Yeah, would be great to avoid this issue entirely.
src/tests/tests/storage.js
Outdated
@@ -164,6 +164,8 @@ | |||
}); | |||
|
|||
QUnit.test("DNT does not cascade", (assert) => { | |||
let settings_map = storage.getBadgerStorageObject('settings_map'); | |||
settings_map.setItem("checkForDNTPolicy", 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.
These two lines should be removed as unnecessary, right?
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.
nope. nasty catch there, if your local version is false then this gets messed up. If I hit the unit tests of the version of privacy badger currently installed on my browser, my settings would change the context of the test, and in the case of this feature, alter the outcome of several tests :S
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.
Good point, but that's a bug with our testing setup. Let's fix or open a ticket to fix this unit tests bug instead of resetting settings in every test that uses them.
src/tests/tests/storage.js
Outdated
QUnit.test("blocking still cascades after domain declares DNT", (assert) => { | ||
let settings_map = storage.getBadgerStorageObject('settings_map'); | ||
settings_map.setItem("checkForDNTPolicy", 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.
Ditto: unnecessary, remove?
src/tests/tests/storage.js
Outdated
@@ -312,6 +333,8 @@ | |||
}); | |||
|
|||
QUnit.test("user actions overrule everything else", (assert) => { | |||
let settings_map = storage.getBadgerStorageObject('settings_map'); | |||
settings_map.setItem("checkForDNTPolicy", 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.
Ditto: unnecessary, remove?
@@ -191,7 +193,26 @@ | |||
); | |||
}); | |||
|
|||
QUnit.test("DNT does not return as an action if user has chosen not to", (assert) => { |
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.
This test doesn't seem to test anything: try getting it to fail by removing the "is DNT checking enabled" checks in the code. The test will still pass because DOMAIN is always seen as NO_TRACKING, not DNT.
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.
hmm. this test works in the suite, but does not work on its own because I mistakenly depended on the leftover state of a previous test.
QUnit.test("DNT does not cascade", (assert) => {
runs storage.setupDNT(DOMAIN);
because that marks down DOMAIN as having a DNT policy, the next test disabling it does test it. I'll add that setupDNT to the disable test explicitly.
edit: wait... no... I already added that. now I'm confused. I'm running storage.setupDNT(DOMAIN);
??
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.
Yep, seems fine now, I don't know what I was seeing earlier.
src/tests/tests/storage.js
Outdated
assert.equal( | ||
storage.getAction(DOMAIN), | ||
constants.NO_TRACKING, | ||
"domain is marked as DNT directly" |
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.
Should update the message describing the assertion.
src/tests/tests/storage.js
Outdated
assert.equal( | ||
storage.getBestAction(DOMAIN), | ||
constants.NO_TRACKING, | ||
"domain is marked as DNT" |
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.
Should update the message describing the assertion.
src/js/storage.js
Outdated
@@ -99,11 +99,13 @@ BadgerPen.prototype = { | |||
* @returns {String} the presumed action for this FQDN | |||
**/ | |||
getAction: function (domain, ignoreDNT) { | |||
let checking_dnt = badger.isCheckingDNTPolicyEnabled(); |
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.
Could avoid making another variable by setting ignoreDNT
to true if badger.isCheckingDNTPolicyEnabled()
is false.
src/_locales/en_US/messages.json
Outdated
@@ -89,6 +89,12 @@ | |||
"options_title": { | |||
"message": "Privacy Badger Options" | |||
}, | |||
"options_dnt_policy_setting": { | |||
"message": "Check if sites have a DNT policy and unblock them" |
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.
How about "Check if sites comply with EFF's Do Not Track policy"?
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.
sure.
BTW. maybe we should change that "learn more" link to this: https://www.eff.org/pages/understanding-effs-do-not-track-policy-universal-opt-out-tracking ?
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.
I dunno, https://www.eff.org/dnt-policy links there already. We might add some more explanatory text to this checkbox in the future too, but no need to wait on that I think.
this should be fixed in a different way.
Let me know if this is ready for me to look over again. |
ah, yes it is. Could you double check your findings on that unit test? I was able to get it to fail by removing the check in getAction. |
Looks good, thank you! I'll open a pull request with some follow up tweaks. |
@Ghoughpteighbteau Take a look at my follow-up in #1400 if you like. |
Fixes #1389.
http://imgur.com/a/N8DqL
adds an option to disable DNT policy checks. When this option is disabled, domains fall back to heuristics and privacy badger stops asking the EFF for updated policy hashes.
I couldn't think of a better way to test these settings, and I couldn't find any of the other settings being tested, so I didn't have anything to emulate.
Let me know what needs changed here!