Skip to content

Commit d26d4a6

Browse files
Release build 8.13.0 [ci release]
1 parent 15523c9 commit d26d4a6

File tree

12 files changed

+51
-11
lines changed

12 files changed

+51
-11
lines changed

CHANGELOG.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
- ntp: support default background colors (#1596)
1+
- Setting of document for tracker analysis (#1613)

Sources/ContentScopeScripts/dist/contentScope.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,9 @@
885885
const style = createStyleElement(css);
886886
getInjectionElement().appendChild(style);
887887
}
888+
function getGlobal() {
889+
return globalObj;
890+
}
888891
function nextRandom(v) {
889892
return Math.abs(v >> 1 | (v << 62 ^ v << 61) & ~(~0 << 63) << 62);
890893
}
@@ -2578,7 +2581,7 @@
25782581

25792582
// src/trackers.js
25802583
init_define_import_meta_trackerLookup();
2581-
function isTrackerOrigin(trackerLookup, originHostname = document.location.hostname) {
2584+
function isTrackerOrigin(trackerLookup, originHostname = getGlobal().document.location.hostname) {
25822585
const parts = originHostname.split(".").reverse();
25832586
let node = trackerLookup;
25842587
for (const sub of parts) {

Sources/ContentScopeScripts/dist/contentScopeIsolated.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,9 @@
16071607
function registerMessageSecret(secret) {
16081608
messageSecret = secret;
16091609
}
1610+
function getGlobal() {
1611+
return globalObj;
1612+
}
16101613
var exemptionLists = {};
16111614
var debug = false;
16121615
function initStringExemptionLists(args) {
@@ -3133,7 +3136,7 @@
31333136

31343137
// src/trackers.js
31353138
init_define_import_meta_trackerLookup();
3136-
function isTrackerOrigin(trackerLookup, originHostname = document.location.hostname) {
3139+
function isTrackerOrigin(trackerLookup, originHostname = getGlobal().document.location.hostname) {
31373140
const parts = originHostname.split(".").reverse();
31383141
let node = trackerLookup;
31393142
for (const sub of parts) {

build/android/autofillPasswordImport.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
function registerMessageSecret(secret) {
5050
messageSecret = secret;
5151
}
52+
function getGlobal() {
53+
return globalObj;
54+
}
5255
var exemptionLists = {};
5356
function shouldExemptUrl(type, url) {
5457
for (const regex of exemptionLists[type]) {
@@ -1719,7 +1722,7 @@
17191722
};
17201723

17211724
// src/trackers.js
1722-
function isTrackerOrigin(trackerLookup, originHostname = document.location.hostname) {
1725+
function isTrackerOrigin(trackerLookup, originHostname = getGlobal().document.location.hostname) {
17231726
const parts = originHostname.split(".").reverse();
17241727
let node = trackerLookup;
17251728
for (const sub of parts) {

build/android/brokerProtection.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,9 @@
15731573
function registerMessageSecret(secret) {
15741574
messageSecret = secret;
15751575
}
1576+
function getGlobal() {
1577+
return globalObj;
1578+
}
15761579
var exemptionLists = {};
15771580
var debug = false;
15781581
function initStringExemptionLists(args) {
@@ -3093,7 +3096,7 @@
30933096

30943097
// src/trackers.js
30953098
init_define_import_meta_trackerLookup();
3096-
function isTrackerOrigin(trackerLookup, originHostname = document.location.hostname) {
3099+
function isTrackerOrigin(trackerLookup, originHostname = getGlobal().document.location.hostname) {
30973100
const parts = originHostname.split(".").reverse();
30983101
let node = trackerLookup;
30993102
for (const sub of parts) {

build/android/contentScope.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,9 @@
885885
const style = createStyleElement(css);
886886
getInjectionElement().appendChild(style);
887887
}
888+
function getGlobal() {
889+
return globalObj;
890+
}
888891
function nextRandom(v) {
889892
return Math.abs(v >> 1 | (v << 62 ^ v << 61) & ~(~0 << 63) << 62);
890893
}
@@ -3089,7 +3092,7 @@
30893092

30903093
// src/trackers.js
30913094
init_define_import_meta_trackerLookup();
3092-
function isTrackerOrigin(trackerLookup, originHostname = document.location.hostname) {
3095+
function isTrackerOrigin(trackerLookup, originHostname = getGlobal().document.location.hostname) {
30933096
const parts = originHostname.split(".").reverse();
30943097
let node = trackerLookup;
30953098
for (const sub of parts) {

build/chrome-mv3/inject.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,9 @@
855855
const style = createStyleElement(css);
856856
getInjectionElement().appendChild(style);
857857
}
858+
function getGlobal() {
859+
return globalObj;
860+
}
858861
function nextRandom(v) {
859862
return Math.abs(v >> 1 | (v << 62 ^ v << 61) & ~(~0 << 63) << 62);
860863
}
@@ -2549,7 +2552,7 @@
25492552
};
25502553

25512554
// src/trackers.js
2552-
function isTrackerOrigin(trackerLookup2, originHostname = document.location.hostname) {
2555+
function isTrackerOrigin(trackerLookup2, originHostname = getGlobal().document.location.hostname) {
25532556
const parts = originHostname.split(".").reverse();
25542557
let node = trackerLookup2;
25552558
for (const sub of parts) {

build/firefox/inject.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,9 @@
855855
const style = createStyleElement(css);
856856
getInjectionElement().appendChild(style);
857857
}
858+
function getGlobal() {
859+
return globalObj;
860+
}
858861
function nextRandom(v) {
859862
return Math.abs(v >> 1 | (v << 62 ^ v << 61) & ~(~0 << 63) << 62);
860863
}
@@ -2549,7 +2552,7 @@
25492552
};
25502553

25512554
// src/trackers.js
2552-
function isTrackerOrigin(trackerLookup2, originHostname = document.location.hostname) {
2555+
function isTrackerOrigin(trackerLookup2, originHostname = getGlobal().document.location.hostname) {
25532556
const parts = originHostname.split(".").reverse();
25542557
let node = trackerLookup2;
25552558
for (const sub of parts) {

build/integration/contentScope.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -2367,6 +2367,9 @@
23672367
const style = createStyleElement(css);
23682368
getInjectionElement().appendChild(style);
23692369
}
2370+
function getGlobal() {
2371+
return globalObj;
2372+
}
23702373
function nextRandom(v) {
23712374
return Math.abs(v >> 1 | (v << 62 ^ v << 61) & ~(~0 << 63) << 62);
23722375
}
@@ -4586,7 +4589,7 @@
45864589

45874590
// src/trackers.js
45884591
init_define_import_meta_trackerLookup();
4589-
function isTrackerOrigin(trackerLookup2, originHostname = document.location.hostname) {
4592+
function isTrackerOrigin(trackerLookup2, originHostname = getGlobal().document.location.hostname) {
45904593
const parts = originHostname.split(".").reverse();
45914594
let node = trackerLookup2;
45924595
for (const sub of parts) {

build/windows/contentScope.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -2367,6 +2367,9 @@
23672367
const style = createStyleElement(css);
23682368
getInjectionElement().appendChild(style);
23692369
}
2370+
function getGlobal() {
2371+
return globalObj;
2372+
}
23702373
function nextRandom(v) {
23712374
return Math.abs(v >> 1 | (v << 62 ^ v << 61) & ~(~0 << 63) << 62);
23722375
}
@@ -4119,7 +4122,7 @@
41194122

41204123
// src/trackers.js
41214124
init_define_import_meta_trackerLookup();
4122-
function isTrackerOrigin(trackerLookup2, originHostname = document.location.hostname) {
4125+
function isTrackerOrigin(trackerLookup2, originHostname = getGlobal().document.location.hostname) {
41234126
const parts = originHostname.split(".").reverse();
41244127
let node = trackerLookup2;
41254128
for (const sub of parts) {

injected/src/trackers.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import { getGlobal } from './utils.js';
2+
13
/**
24
* Check if the current document origin is on the tracker list, using the provided lookup trie.
35
* @param {object} trackerLookup Trie lookup of tracker domains
46
* @returns {boolean} True iff the origin is a tracker.
7+
*
8+
* Note: getGlobal() is used in testing to get the global object,
9+
* it's a work around for ESM modules are essentially singletons preventing overriding of global variables.
510
*/
6-
export function isTrackerOrigin(trackerLookup, originHostname = document.location.hostname) {
11+
export function isTrackerOrigin(trackerLookup, originHostname = getGlobal().document.location.hostname) {
712
const parts = originHostname.split('.').reverse();
813
let node = trackerLookup;
914
for (const sub of parts) {

injected/src/utils.js

+8
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ export function setGlobal(globalObjIn) {
4949
Error = globalObj.Error;
5050
}
5151

52+
/**
53+
* Used for testing to allow other files to override the globals used within this file.
54+
* @returns {globalThis} the global object
55+
*/
56+
export function getGlobal() {
57+
return globalObj;
58+
}
59+
5260
// linear feedback shift register to find a random approximation
5361
export function nextRandom(v) {
5462
return Math.abs((v >> 1) | (((v << 62) ^ (v << 61)) & (~(~0 << 63) << 62)));

0 commit comments

Comments
 (0)