@whotracksme/reporting 12.1.18 → 12.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/package.json +1 -1
- package/reporting/src/network.js +14 -4
- package/reporting/src/pages.js +3 -1
- package/reporting/test/network.spec.js +59 -0
- package/reporting/test/pages.spec.js +167 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
# v12.1.20 (Fri Nov 20 2026)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- Fixed: do not change the pageId on title updates [#262](https://github.com/whotracksme/webextension-packages/pull/262) ([@philipp-classen](https://github.com/philipp-classen))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Philipp Claßen ([@philipp-classen](https://github.com/philipp-classen))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# v12.1.19 (Thu Nov 19 2026)
|
|
14
|
+
|
|
15
|
+
#### 🐛 Bug Fix
|
|
16
|
+
|
|
17
|
+
- fixed: only write DNS mappings if something changes [#261](https://github.com/whotracksme/webextension-packages/pull/261) ([@philipp-classen](https://github.com/philipp-classen))
|
|
18
|
+
|
|
19
|
+
#### Authors: 1
|
|
20
|
+
|
|
21
|
+
- Philipp Claßen ([@philipp-classen](https://github.com/philipp-classen))
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
1
25
|
# v12.1.18 (Thu Nov 19 2026)
|
|
2
26
|
|
|
3
27
|
#### 🐛 Bug Fix
|
package/package.json
CHANGED
package/reporting/src/network.js
CHANGED
|
@@ -257,13 +257,23 @@ export class DnsResolver {
|
|
|
257
257
|
return false;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
+
// Returns true if the cache changed. The caller can then persist it.
|
|
260
261
|
cacheDnsResolution({ url, hostname, ip, now = Date.now() }) {
|
|
261
262
|
const hostname_ = hostname || this._tryParseHostname(url);
|
|
262
|
-
if (hostname_) {
|
|
263
|
-
|
|
264
|
-
return true;
|
|
263
|
+
if (!hostname_) {
|
|
264
|
+
return false;
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
|
|
267
|
+
// Most requests bring no new information. Skip them, but refresh the
|
|
268
|
+
// timestamp from time to time; otherwise, a hostname in use expires.
|
|
269
|
+
const oldEntry = this.dns.get(hostname_);
|
|
270
|
+
const isFresh = oldEntry && Math.abs(now - oldEntry.updatedAt) < 2 * MINUTE;
|
|
271
|
+
if (isFresh && oldEntry.ip === ip) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
this.dns.set(hostname_, { ip, updatedAt: now });
|
|
276
|
+
return true;
|
|
267
277
|
}
|
|
268
278
|
|
|
269
279
|
expireEntries(now = Date.now()) {
|
package/reporting/src/pages.js
CHANGED
|
@@ -1163,8 +1163,9 @@ export default class Pages {
|
|
|
1163
1163
|
|
|
1164
1164
|
let updated = false;
|
|
1165
1165
|
if (tab.title && tab.title !== entry.title) {
|
|
1166
|
+
// A new title is not a navigation. Keep the page id, or pending
|
|
1167
|
+
// lazy variables (e.g. the page structure) are lost for this page.
|
|
1166
1168
|
entry.title = tab.title;
|
|
1167
|
-
entry.pageId = ++this._pageIdGenerator;
|
|
1168
1169
|
updated = true;
|
|
1169
1170
|
}
|
|
1170
1171
|
if (tab.url && tab.url !== entry.url) {
|
|
@@ -1914,6 +1915,7 @@ export default class Pages {
|
|
|
1914
1915
|
type: 'lazy-init',
|
|
1915
1916
|
field,
|
|
1916
1917
|
tabId,
|
|
1918
|
+
cancelled: result === CANCEL_LAZY_VAR,
|
|
1917
1919
|
});
|
|
1918
1920
|
})
|
|
1919
1921
|
.catch((e) => {
|
|
@@ -125,4 +125,63 @@ describe('DnsResolver', function () {
|
|
|
125
125
|
expect(uut.isPrivateURL('not-a-url')).to.be.true;
|
|
126
126
|
});
|
|
127
127
|
});
|
|
128
|
+
|
|
129
|
+
describe('#cacheDnsResolution', function () {
|
|
130
|
+
const SECOND = 1000;
|
|
131
|
+
const MINUTE = 60 * SECOND;
|
|
132
|
+
const HOUR = 60 * MINUTE;
|
|
133
|
+
const hostname = 'www.example.com';
|
|
134
|
+
const now = Date.now();
|
|
135
|
+
|
|
136
|
+
it('should report a change for a new hostname', function () {
|
|
137
|
+
expect(uut.cacheDnsResolution({ hostname, ip: '1.2.3.4', now })).to.be
|
|
138
|
+
.true;
|
|
139
|
+
expect(uut.serialize({ now })).to.have.lengthOf(1);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should report no change if the same IP is seen again shortly after', function () {
|
|
143
|
+
uut.cacheDnsResolution({ hostname, ip: '1.2.3.4', now });
|
|
144
|
+
|
|
145
|
+
for (let i = 1; i <= 10; i += 1) {
|
|
146
|
+
const later = now + i * 10 * SECOND;
|
|
147
|
+
expect(uut.cacheDnsResolution({ hostname, ip: '1.2.3.4', now: later }))
|
|
148
|
+
.to.be.false;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('should report a change if the IP is different', function () {
|
|
153
|
+
uut.cacheDnsResolution({
|
|
154
|
+
hostname: 'router.example',
|
|
155
|
+
ip: '1.2.3.4',
|
|
156
|
+
now,
|
|
157
|
+
});
|
|
158
|
+
expect(uut.isPrivateHostname('router.example')).to.be.false;
|
|
159
|
+
|
|
160
|
+
const later = now + MINUTE;
|
|
161
|
+
expect(
|
|
162
|
+
uut.cacheDnsResolution({
|
|
163
|
+
hostname: 'router.example',
|
|
164
|
+
ip: '192.168.0.1',
|
|
165
|
+
now: later,
|
|
166
|
+
}),
|
|
167
|
+
).to.be.true;
|
|
168
|
+
expect(uut.isPrivateHostname('router.example')).to.be.true;
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('should not let a hostname expire that is in use', function () {
|
|
172
|
+
let numCalls = 0;
|
|
173
|
+
let numChanges = 0;
|
|
174
|
+
for (let t = now; t <= now + 48 * HOUR; t += 10 * SECOND) {
|
|
175
|
+
numCalls += 1;
|
|
176
|
+
if (uut.cacheDnsResolution({ hostname, ip: '1.2.3.4', now: t })) {
|
|
177
|
+
numChanges += 1;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
expect(uut.serialize({ now: now + 48 * HOUR })).to.have.lengthOf(1);
|
|
181
|
+
|
|
182
|
+
// the timestamp is refreshed from time to time, but not on each call
|
|
183
|
+
expect(numChanges).to.be.greaterThan(48);
|
|
184
|
+
expect(numChanges).to.be.lessThan(numCalls / 10);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
128
187
|
});
|
|
@@ -767,6 +767,173 @@ describe('#Pages', function () {
|
|
|
767
767
|
});
|
|
768
768
|
});
|
|
769
769
|
|
|
770
|
+
describe('DNS cache in the session storage', function () {
|
|
771
|
+
let numWritesOfDnsCache;
|
|
772
|
+
|
|
773
|
+
function responseFrom(hostname, ip) {
|
|
774
|
+
chromeApiMock.webRequest.onResponseStarted.dispatch({
|
|
775
|
+
tabId: 1,
|
|
776
|
+
type: 'image',
|
|
777
|
+
url: `https://${hostname}/some/image.png`,
|
|
778
|
+
ip,
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
beforeEach(function () {
|
|
783
|
+
numWritesOfDnsCache = 0;
|
|
784
|
+
const originalSet = uut.sessionStore.set.bind(uut.sessionStore);
|
|
785
|
+
uut.sessionStore.set = (key, value) => {
|
|
786
|
+
if (key === 'dnsResolver') {
|
|
787
|
+
numWritesOfDnsCache += 1;
|
|
788
|
+
}
|
|
789
|
+
originalSet(key, value);
|
|
790
|
+
};
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
it('should write the cache only if a response has new information', function () {
|
|
794
|
+
for (let i = 0; i < 100; i += 1) {
|
|
795
|
+
responseFrom('cdn.example.com', '203.0.113.1');
|
|
796
|
+
}
|
|
797
|
+
expect(numWritesOfDnsCache).to.eql(1);
|
|
798
|
+
|
|
799
|
+
responseFrom('www.example.com', '203.0.113.2');
|
|
800
|
+
expect(numWritesOfDnsCache).to.eql(2);
|
|
801
|
+
expect(uut.sessionStore.get('dnsResolver')).to.have.lengthOf(2);
|
|
802
|
+
});
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
describe('when the title changes during the page analysis', function () {
|
|
806
|
+
const TAB_ID = 7;
|
|
807
|
+
const WINDOW_ID = 1;
|
|
808
|
+
const PAGE_URL = 'https://www.example.com/app';
|
|
809
|
+
const OTHER_URL = 'https://www.example.com/other';
|
|
810
|
+
let finishPageAnalysis;
|
|
811
|
+
let pageEvents;
|
|
812
|
+
|
|
813
|
+
function tab({
|
|
814
|
+
url = PAGE_URL,
|
|
815
|
+
title = 'App',
|
|
816
|
+
status = 'complete',
|
|
817
|
+
} = {}) {
|
|
818
|
+
return {
|
|
819
|
+
id: TAB_ID,
|
|
820
|
+
windowId: WINDOW_ID,
|
|
821
|
+
incognito: false,
|
|
822
|
+
active: true,
|
|
823
|
+
status,
|
|
824
|
+
title,
|
|
825
|
+
url,
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
function beginPageLoad(url) {
|
|
830
|
+
chromeApiMock.tabs.onUpdated.dispatch(
|
|
831
|
+
TAB_ID,
|
|
832
|
+
{ status: 'loading', url },
|
|
833
|
+
tab({ url, status: 'loading' }),
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
function finishPageLoad(url) {
|
|
838
|
+
chromeApiMock.tabs.onUpdated.dispatch(
|
|
839
|
+
TAB_ID,
|
|
840
|
+
{ status: 'complete' },
|
|
841
|
+
tab({ url }),
|
|
842
|
+
);
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
function changeTitle(title) {
|
|
846
|
+
chromeApiMock.tabs.onUpdated.dispatch(
|
|
847
|
+
TAB_ID,
|
|
848
|
+
{ title },
|
|
849
|
+
tab({ title }),
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
function pageAnalysisEvents() {
|
|
854
|
+
return pageEvents.filter(
|
|
855
|
+
({ type, field }) =>
|
|
856
|
+
type === 'lazy-init' && field === 'pageStructure',
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
beforeEach(function () {
|
|
861
|
+
// the page analysis script runs until the test ends it
|
|
862
|
+
chromeApiMock.scripting = {
|
|
863
|
+
executeScript: () =>
|
|
864
|
+
new Promise((resolve) => {
|
|
865
|
+
finishPageAnalysis = async () => {
|
|
866
|
+
const result = {
|
|
867
|
+
title: 'App',
|
|
868
|
+
url: PAGE_URL,
|
|
869
|
+
noindex: false,
|
|
870
|
+
};
|
|
871
|
+
resolve([{ result }]);
|
|
872
|
+
await waitForPendingMicrotasks();
|
|
873
|
+
};
|
|
874
|
+
}),
|
|
875
|
+
};
|
|
876
|
+
pageEvents = [];
|
|
877
|
+
uut.addObserver((event) => pageEvents.push(event));
|
|
878
|
+
chromeApiMock.tabs.onActivated.dispatch({
|
|
879
|
+
tabId: TAB_ID,
|
|
880
|
+
windowId: WINDOW_ID,
|
|
881
|
+
});
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
it('should not cancel the page analysis', async function () {
|
|
885
|
+
beginPageLoad(PAGE_URL);
|
|
886
|
+
finishPageLoad(PAGE_URL);
|
|
887
|
+
changeTitle('(1) App');
|
|
888
|
+
await finishPageAnalysis();
|
|
889
|
+
|
|
890
|
+
expect(pageAnalysisEvents()).to.eql([
|
|
891
|
+
{
|
|
892
|
+
type: 'lazy-init',
|
|
893
|
+
field: 'pageStructure',
|
|
894
|
+
tabId: TAB_ID,
|
|
895
|
+
cancelled: false,
|
|
896
|
+
},
|
|
897
|
+
]);
|
|
898
|
+
const page = uut.describeTab(TAB_ID);
|
|
899
|
+
expect(page.title).to.eql('(1) App');
|
|
900
|
+
expect(page.preDoublefetch).to.include({
|
|
901
|
+
title: 'App',
|
|
902
|
+
noindex: false,
|
|
903
|
+
});
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
it('should still report the new title', function () {
|
|
907
|
+
beginPageLoad(PAGE_URL);
|
|
908
|
+
finishPageLoad(PAGE_URL);
|
|
909
|
+
changeTitle('(1) App');
|
|
910
|
+
|
|
911
|
+
expect(pageEvents).to.deep.include({
|
|
912
|
+
type: 'page-updated',
|
|
913
|
+
tabId: TAB_ID,
|
|
914
|
+
});
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
it('should cancel the page analysis if the tab loads another page', async function () {
|
|
918
|
+
beginPageLoad(PAGE_URL);
|
|
919
|
+
finishPageLoad(PAGE_URL);
|
|
920
|
+
beginPageLoad(OTHER_URL);
|
|
921
|
+
await finishPageAnalysis();
|
|
922
|
+
|
|
923
|
+
expect(pageAnalysisEvents()).to.eql([
|
|
924
|
+
{
|
|
925
|
+
type: 'lazy-init',
|
|
926
|
+
field: 'pageStructure',
|
|
927
|
+
tabId: TAB_ID,
|
|
928
|
+
cancelled: true,
|
|
929
|
+
},
|
|
930
|
+
]);
|
|
931
|
+
const page = uut.describeTab(TAB_ID);
|
|
932
|
+
expect(page.url).to.eql(OTHER_URL);
|
|
933
|
+
expect(page.preDoublefetch).to.be.undefined;
|
|
934
|
+
});
|
|
935
|
+
});
|
|
936
|
+
|
|
770
937
|
// This are optional tests that can be enabled if the REPLAY_FIXTURES_URL
|
|
771
938
|
// environment variable is defined. Karma lacks access to the filesystem,
|
|
772
939
|
// but we can fetch fixtures over the network.
|