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

added option to disable DNT policy checking #1391

Merged
merged 9 commits into from
May 25, 2017

Conversation

Ghoughpteighbteau
Copy link

@Ghoughpteighbteau Ghoughpteighbteau commented May 22, 2017

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!

@ghostwords
Copy link
Member

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

@ghostwords
Copy link
Member

ghostwords commented May 23, 2017

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.

@Ghoughpteighbteau
Copy link
Author

Ghoughpteighbteau commented May 23, 2017

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. 😅

<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>
Copy link
Member

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.


assert.expect(NUM_TESTS);

badger.isCheckingDNTPolicyEnabled = () => false;
Copy link
Member

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.

Copy link
Author

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.

Copy link
Member

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.

Copy link
Author

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

Copy link
Member

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.

Copy link
Member

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.

@@ -164,6 +164,8 @@
});

QUnit.test("DNT does not cascade", (assert) => {
let settings_map = storage.getBadgerStorageObject('settings_map');
settings_map.setItem("checkForDNTPolicy", true);
Copy link
Member

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?

Copy link
Author

@Ghoughpteighbteau Ghoughpteighbteau May 23, 2017

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

Copy link
Member

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.

QUnit.test("blocking still cascades after domain declares DNT", (assert) => {
let settings_map = storage.getBadgerStorageObject('settings_map');
settings_map.setItem("checkForDNTPolicy", true);
Copy link
Member

Choose a reason for hiding this comment

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

Ditto: unnecessary, remove?

@@ -312,6 +333,8 @@
});

QUnit.test("user actions overrule everything else", (assert) => {
let settings_map = storage.getBadgerStorageObject('settings_map');
settings_map.setItem("checkForDNTPolicy", true);
Copy link
Member

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) => {
Copy link
Member

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.

Copy link
Author

@Ghoughpteighbteau Ghoughpteighbteau May 23, 2017

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);??

Copy link
Member

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.

assert.equal(
storage.getAction(DOMAIN),
constants.NO_TRACKING,
"domain is marked as DNT directly"
Copy link
Member

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.

assert.equal(
storage.getBestAction(DOMAIN),
constants.NO_TRACKING,
"domain is marked as DNT"
Copy link
Member

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.

@@ -99,11 +99,13 @@ BadgerPen.prototype = {
* @returns {String} the presumed action for this FQDN
**/
getAction: function (domain, ignoreDNT) {
let checking_dnt = badger.isCheckingDNTPolicyEnabled();
Copy link
Member

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.

@@ -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"
Copy link
Member

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"?

Copy link
Author

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 ?

Copy link
Member

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.

@ghostwords
Copy link
Member

Let me know if this is ready for me to look over again.

@Ghoughpteighbteau
Copy link
Author

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.

@ghostwords ghostwords self-requested a review May 24, 2017 22:48
@ghostwords ghostwords dismissed their stale review May 24, 2017 23:22

Feedback addressed.

@ghostwords ghostwords merged commit f6a67f6 into EFForg:master May 25, 2017
@ghostwords
Copy link
Member

ghostwords commented May 25, 2017

Looks good, thank you! I'll open a pull request with some follow up tweaks.

@ghostwords
Copy link
Member

ghostwords commented May 25, 2017

@Ghoughpteighbteau Take a look at my follow-up in #1400 if you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants