Skip to content

Commit

Permalink
Don't create Tab objects for initial tabs until config is loaded. (#1056
Browse files Browse the repository at this point in the history
)

* Don't create Tab objects for initial tabs until config is loaded.

* Update tab block info for non-200 status codes
  • Loading branch information
sammacbeth committed Feb 21, 2022
1 parent 2082d08 commit 8790d51
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
18 changes: 9 additions & 9 deletions shared/js/background/events.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,15 +489,6 @@ browser.alarms.onAlarm.addListener(async alarmEvent => {
* on start up
*/
const onStartup = async () => {
const savedTabs = await browser.tabs.query({ currentWindow: true, status: 'complete' })
for (let i = 0; i < savedTabs.length; i++) {
const tab = savedTabs[i]

if (tab.url) {
tabManager.create(tab)
}
}

await settings.ready()
experiment.setActiveExperiment()

Expand All @@ -521,6 +512,15 @@ const onStartup = async () => {
if (!userData.nextAlias) await fetchAlias()
showContextMenuAction()
}

const savedTabs = await browser.tabs.query({ currentWindow: true, status: 'complete' })
for (let i = 0; i < savedTabs.length; i++) {
const tab = savedTabs[i]

if (tab.url) {
tabManager.create(tab)
}
}
}

// Count https upgrade failures to allow bad data to be removed from lists
Expand Down
10 changes: 4 additions & 6 deletions shared/js/background/redirect.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ function handleRequest (requestData) {
// just default to true.
const sameDomain = isSameDomainRequest(thisTab, requestData)

// only count trackers on pages with 200 response. Trackers on these sites are still
// Trackers on these sites are still
// blocked below but not counted on the popup. We can also run into a case where
// we block a tracker faster then we can update the tab so we check sameDomain.
if (thisTab.statusCode === 200 && sameDomain) {
if (sameDomain) {
// record all tracker urls on a site even if we don't block them
thisTab.site.addTracker(tracker)

Expand All @@ -179,10 +179,8 @@ function handleRequest (requestData) {
browserWrapper.notifyPopup({ updateTabData: true })
// Block the request if the site is not allowlisted
if (blockingEnabled && tracker.action.match(/block|redirect/)) {
if (thisTab.statusCode === 200) {
Companies.add(tracker.tracker.owner)
if (sameDomain) thisTab.addOrUpdateTrackersBlocked(tracker)
}
Companies.add(tracker.tracker.owner)
if (sameDomain) thisTab.addOrUpdateTrackersBlocked(tracker)

// for debugging specific requests. see test/tests/debugSite.js
if (debugRequest && debugRequest.length) {
Expand Down

0 comments on commit 8790d51

Please sign in to comment.