diff --git a/src/js/heuristicblocking.js b/src/js/heuristicblocking.js index fe2f1b77c0..b9dbd5412b 100644 --- a/src/js/heuristicblocking.js +++ b/src/js/heuristicblocking.js @@ -138,24 +138,30 @@ HeuristicBlocker.prototype = { /** * Wraps _recordPrevalence for use outside of webRequest listeners. * - * @param tracker_fqdn The fully qualified domain name of the tracker - * @param page_origin The base domain of the page where the tracker - * was detected - * @returns {*} + * @param {String} tracker_fqdn The fully qualified domain name of the tracker + * @param {String} page_origin The base domain of the page + * where the tracker was detected. + * @param {Boolean} skip_dnt_check Skip DNT policy checking if flag is true. + * */ - updateTrackerPrevalence: function(tracker_fqdn, page_origin) { + updateTrackerPrevalence: function(tracker_fqdn, page_origin, skip_dnt_check) { // abort if we already made a decision for this fqdn let action = this.storage.getAction(tracker_fqdn); if (action != constants.NO_TRACKING && action != constants.ALLOW) { return; } - this._recordPrevalence(tracker_fqdn, window.getBaseDomain(tracker_fqdn), page_origin); + this._recordPrevalence( + tracker_fqdn, + window.getBaseDomain(tracker_fqdn), + page_origin, + skip_dnt_check + ); }, /** * Record HTTP request prevalence. Block a tracker if seen on more - * than [constants.TRACKING_THRESHOLD] pages + * than constants.TRACKING_THRESHOLD pages * * NOTE: This is a private function and should never be called directly. * All calls should be routed through heuristicBlockingAccounting for normal usage @@ -165,9 +171,10 @@ HeuristicBlocker.prototype = { * @param {String} tracker_fqdn The FQDN of the third party tracker * @param {String} tracker_origin Base domain of the third party tracker * @param {String} page_origin The origin of the page where the third party - * tracker was loaded + * tracker was loaded. + * @param {Boolean} skip_dnt_check Skip DNT policy checking if flag is true. */ - _recordPrevalence: function (tracker_fqdn, tracker_origin, page_origin) { + _recordPrevalence: function (tracker_fqdn, tracker_origin, page_origin, skip_dnt_check) { var snitch_map = this.storage.getBadgerStorageObject('snitch_map'); var firstParties = []; if (snitch_map.hasItem(tracker_origin)) { @@ -181,9 +188,11 @@ HeuristicBlocker.prototype = { // Check this just-seen-tracking-on-this-site, // not-yet-blocked domain for DNT policy. // We check heuristically-blocked domains in webrequest.js. - window.setTimeout(function () { - badger.checkForDNTPolicy(tracker_fqdn); - }, 10); + if (!skip_dnt_check) { + window.setTimeout(function () { + badger.checkForDNTPolicy(tracker_fqdn); + }, 10); + } // record that we've seen this tracker on this domain (in snitch map) firstParties.push(page_origin); diff --git a/src/js/storage.js b/src/js/storage.js index 02fc4c3e5b..d9a0f7365a 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -499,7 +499,8 @@ BadgerStorage.prototype = { for (let origin in firstPartyOrigins) { badger.heuristicBlocking.updateTrackerPrevalence( tracker_fqdn, - firstPartyOrigins[origin] + firstPartyOrigins[origin], + true // skip DNT policy checking on data import ); } }