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

Organize sliders into expandable summary, add first party protections section #2748

Merged
merged 52 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
65ffbf0
add messages to english locale for firstparty protections info in popup
ablanathtanalba Mar 28, 2021
d14a37b
add section to popup html for firstparty protections
ablanathtanalba Mar 28, 2021
ae0809e
basic styling to firstparty section in popup
ablanathtanalba Mar 28, 2021
4e59434
add click handlers to toggle firstparty info visibility on popup
ablanathtanalba Mar 28, 2021
108661e
add popup html for toggling blocked resources visibility
ablanathtanalba Mar 28, 2021
7938eb2
add click handlers for toggling blocked resources visibility in popup
ablanathtanalba Mar 28, 2021
330322c
basic persistence of blocked resources visibility preference in popup
ablanathtanalba Mar 28, 2021
abb3fa8
fix selenium popup test by clicking to expand blocked resources section
ablanathtanalba Mar 28, 2021
d959710
fix styling edge case where no trackers detected but firstparty prote…
ablanathtanalba Mar 29, 2021
7040294
styling cleanup on firstparty text and hidden sliders in popup
ablanathtanalba Mar 29, 2021
bc6e930
add en_us message for popup click to expand tooltips
ablanathtanalba Apr 14, 2021
0bedddb
cleanup click to expand section event listeners in popup script
ablanathtanalba Apr 14, 2021
9af80f2
cleanup click handler for blocked resources section in popup
ablanathtanalba Apr 14, 2021
ca7c71d
cleanup styling for dropdown portions of popup
ablanathtanalba Apr 14, 2021
111e8a7
more css cleanup for expandable popup sections
ablanathtanalba Apr 15, 2021
97ace1f
set firstparties url schemes to badger object
ablanathtanalba Apr 22, 2021
786691f
handle checking if current tab is in firstparty protections in webreq…
ablanathtanalba Apr 22, 2021
501ccaa
cleanup popup script handlers showing firstparty and blocked resource…
ablanathtanalba Apr 22, 2021
c2a7b79
fix broken selenium popup test selecting wrong element type
ablanathtanalba Apr 22, 2021
874c3f0
simplify firstparty popup message
ablanathtanalba Apr 29, 2021
380156a
add hover transform effect on popup dropdown carets
ablanathtanalba Apr 29, 2021
53fa187
remove tooltip from dropdown sections popup
ablanathtanalba Apr 29, 2021
8d0c014
move firstparty detection method to utils
ablanathtanalba Apr 29, 2021
68b04f8
add unit test for firstparty detection util method
ablanathtanalba Apr 29, 2021
6598953
cleanup fetching manifest in background script
ablanathtanalba Apr 29, 2021
58b68b6
cleanup and delint method to check if firstparty protections are enab…
ablanathtanalba Apr 30, 2021
825d69e
fix cursor hovering error on popup expandable sections
ablanathtanalba Apr 30, 2021
63c7f3d
cleanup badger firstparties list obj and avoid false positives when l…
ablanathtanalba May 3, 2021
0c098a1
fix broken firstparty detection test script
ablanathtanalba May 3, 2021
cad1393
fix wildcard url matching firstparty detection and add test coverage
ablanathtanalba May 6, 2021
6408edb
simplify updating setting showing blocked resources container in popup
ablanathtanalba May 6, 2021
284907b
visual consistency between descriptions sections in dropdowns on popup
ablanathtanalba May 6, 2021
123b2a4
only fetch badger firstparties list when its first needed
ablanathtanalba May 10, 2021
7438813
fix broken utils text
ablanathtanalba May 10, 2021
98b2e84
Move HTML link into a placeholder
ghostwords May 12, 2021
c5fb566
Tweak locale message order
ghostwords May 12, 2021
09a602a
Tweak link tracking protection messages
ghostwords May 12, 2021
b778566
Restyle popup categories
ghostwords May 12, 2021
e4f0d64
Don't toggle slider visibility when clicking links
ghostwords May 12, 2021
5b3453a
Fix reverting control test
ghostwords May 12, 2021
1a97a81
Revert "pbInstructions" to ID as there is only one
ghostwords May 12, 2021
d2b7f5b
cleanup util method to check if firstparty protections are enabled
ablanathtanalba May 13, 2021
95dfb69
simplify checking against wildcards in firstPartyProtectionsEnabled u…
ablanathtanalba May 13, 2021
b86df58
Expand sliders always on any breakage warnings
ghostwords May 13, 2021
75127cd
Show breakage warning sliders above the rest
ghostwords May 13, 2021
48d2b2a
Tweak unit tests
ghostwords May 13, 2021
ea35530
Tweak firstPartyProtectionsEnabled() documentation
ghostwords May 13, 2021
ff82451
Tweak link tracking protection wording
ghostwords May 13, 2021
7abed9e
Fix no-tab-data (special browser page) popup state
ghostwords May 13, 2021
d6e318b
Tweak link tracking protection wording again
ghostwords May 14, 2021
9089db1
Remove unnecessary CSS IDs
ghostwords May 14, 2021
aa4fe37
Send all settings in single object to popup too
ghostwords May 14, 2021
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
36 changes: 20 additions & 16 deletions src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,10 @@ function isThirdPartyDomain(domain1, domain2) {
*
* @return {Boolean} true if the domains are third party
*/
function firstPartyProtectionsEnabled(domain, badger) {
// if the firstparties list hasn't been set yet, fetch it and set it
if (!badger.firstPartiesList) {
let firstPartyProtectionsEnabled = (function () {
let firstPartiesList;

function getFirstParties() {
let manifestJson = chrome.runtime.getManifest();
let firstParties = [];

Expand All @@ -468,23 +469,26 @@ function firstPartyProtectionsEnabled(domain, badger) {
firstParties.push(extractedUrls);
}
}
// clean up the gathered sets of url matches into a single flat list
badger.firstPartiesList = [].concat.apply([], firstParties);
return [].concat.apply([], firstParties);
}
// check for presence of given domain in firstparties list
for (let url_pattern of badger.firstPartiesList) {
// account for wildcards in entries on firstPartiesList & avoid false positives
if (url_pattern.startsWith("*")) {
// compare against pattern without '*.' and the domain without 'www.'
if (url_pattern.slice(2) == domain.slice(4)) {

return function (tab_host) {
if (!firstPartiesList) {
firstPartiesList = getFirstParties();
}

for (let url_pattern of firstPartiesList) {
if (url_pattern.startsWith("*")) {
if ((url_pattern.slice(2) == tab_host.slice(4)) || url_pattern.slice(2) == tab_host.slice(2)) {
ghostwords marked this conversation as resolved.
Show resolved Hide resolved
return true;
}
} else if (url_pattern == tab_host) {
return true;
}
} else if (url_pattern == domain) {
return true;
}
}
return false;
}
return false;
};
})();

/**
* Checks whether a given URL is a special browser page.
Expand Down
2 changes: 1 addition & 1 deletion src/js/webrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ function dispatcher(request, sender, sendResponse) {
let tab_host = window.extractHostFromURL(request.tabUrl),
origins = badger.tabData[tab_id].origins,
cookieblocked = {},
isOnFirstParty = utils.firstPartyProtectionsEnabled(tab_host, badger);
isOnFirstParty = utils.firstPartyProtectionsEnabled(tab_host);

for (let origin in origins) {
// see if origin would be cookieblocked if not for user override
Expand Down
6 changes: 3 additions & 3 deletions src/tests/tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,19 +573,19 @@ QUnit.test("estimateMaxEntropy", assert => {

QUnit.test("firstPartyProtectionsEnabled", assert => {
assert.equal(
utils.firstPartyProtectionsEnabled("www.google.com", badger),
utils.firstPartyProtectionsEnabled("www.google.com"),
true,
"properly identifies a url pattern from our firstparties list"
);

assert.equal(
utils.firstPartyProtectionsEnabled("foobar.com", badger),
utils.firstPartyProtectionsEnabled("foobar.com"),
false,
"determines that a url not in the firstparties list is not protected by a firstparty script"
);

assert.equal(
utils.firstPartyProtectionsEnabled("www.messenger.com", badger),
utils.firstPartyProtectionsEnabled("www.messenger.com"),
true,
"accurately IDs a site with firstparty protections covered by a wildcard url match"
);
Expand Down