@whotracksme/reporting 8.0.1 β†’ 8.0.2

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 CHANGED
@@ -1,3 +1,24 @@
1
+ # v8.0.2 (Mon Apr 27 2026)
2
+
3
+ #### πŸ› Bug Fix
4
+
5
+ - Guarantee deterministic key orders in messages with nested payloads [#200](https://github.com/whotracksme/webextension-packages/pull/200) ([@philipp-classen](https://github.com/philipp-classen))
6
+
7
+ #### 🏠 Internal
8
+
9
+ - Refresh request-pipeline fixtures to 2026-04-23 Chromium recordings [#198](https://github.com/whotracksme/webextension-packages/pull/198) ([@chrmod](https://github.com/chrmod))
10
+
11
+ #### πŸ“ Documentation
12
+
13
+ - Fixed comment (session storage, not local storage) [#199](https://github.com/whotracksme/webextension-packages/pull/199) ([@philipp-classen](https://github.com/philipp-classen))
14
+
15
+ #### Authors: 2
16
+
17
+ - Krzysztof Modras ([@chrmod](https://github.com/chrmod))
18
+ - Philipp Claßen ([@philipp-classen](https://github.com/philipp-classen))
19
+
20
+ ---
21
+
1
22
  # v8.0.1 (Tue Apr 21 2026)
2
23
 
3
24
  #### πŸ› Bug Fix
@@ -13,20 +13,21 @@
13
13
  * Use case: when running object through JSON.stringify, it
14
14
  * should not be distinguishable in which order the object keys
15
15
  * where added.
16
- *
17
- * Note: The current implement only operates on the first level.
18
- * In our context, that should be suffient, since
19
- * anonymous-communication will not add nested structures.
20
- * The only nested structure is the payload, which means the
21
- * message creator will be responsible for the ordering.
22
- *
23
- * Should that become a burden, we could extend this function
24
- * to recursively sort the object keys.
25
16
  */
26
17
  export function sortObjectKeys(obj) {
18
+ if (Array.isArray(obj)) {
19
+ return obj.map(sortObjectKeys);
20
+ }
21
+ if (obj === null || typeof obj !== 'object') {
22
+ return obj;
23
+ }
27
24
  const sortByKeys = (x, y) => {
28
25
  if (x[0] === y[0]) return 0;
29
26
  return x[0] < y[0] ? -1 : 1;
30
27
  };
31
- return Object.fromEntries(Object.entries(obj).sort(sortByKeys));
28
+ return Object.fromEntries(
29
+ Object.entries(obj)
30
+ .sort(sortByKeys)
31
+ .map(([k, v]) => [k, sortObjectKeys(v)]),
32
+ );
32
33
  }
@@ -41,6 +41,80 @@ describe('#sortObjectKeys', function () {
41
41
  );
42
42
  });
43
43
 
44
+ describe('should handle primitive values', function () {
45
+ for (const x of [
46
+ true,
47
+ false,
48
+ undefined,
49
+ null,
50
+ 0,
51
+ 1,
52
+ 1.23,
53
+ '',
54
+ 'foo',
55
+ // not primitive, but include:
56
+ [],
57
+ {},
58
+ ]) {
59
+ it(`- <<${x}>>`, function () {
60
+ const { x: xAfter } = sortObjectKeys({ x });
61
+ expect(xAfter).to.eql(x);
62
+ });
63
+
64
+ it(`- [${x}]`, function () {
65
+ const { x: xAfter } = sortObjectKeys({ x: [x] });
66
+ expect(xAfter).to.eql([x]);
67
+ });
68
+ }
69
+ });
70
+
71
+ it('should sort keys in nested structures', function () {
72
+ const obj1 = {
73
+ payload: {
74
+ paused: false,
75
+ mode: 'default',
76
+ },
77
+ };
78
+ const obj2 = {
79
+ payload: {
80
+ mode: 'default',
81
+ paused: false,
82
+ },
83
+ };
84
+
85
+ const obj1Json = JSON.stringify(sortObjectKeys(obj1));
86
+ const obj2Json = JSON.stringify(sortObjectKeys(obj2));
87
+ expect(obj1Json).to.eql(obj2Json);
88
+ });
89
+
90
+ it('should sort numeric-string keys in numeric order', function () {
91
+ const obj = {
92
+ payload: {
93
+ r: {
94
+ '11': { foo: 42, bar: null },
95
+ '10': { foo: 42, bar: null },
96
+ '2': { foo: 42, bar: null },
97
+ '1': { foo: 42, bar: null },
98
+ '0': { foo: 42, bar: null },
99
+ },
100
+ },
101
+ };
102
+ const objJson = JSON.stringify(sortObjectKeys(obj));
103
+
104
+ const expectedJson = JSON.stringify({
105
+ payload: {
106
+ r: {
107
+ '0': { bar: null, foo: 42 },
108
+ '1': { bar: null, foo: 42 },
109
+ '2': { bar: null, foo: 42 },
110
+ '10': { bar: null, foo: 42 },
111
+ '11': { bar: null, foo: 42 },
112
+ },
113
+ },
114
+ });
115
+ expect(objJson).to.eql(expectedJson);
116
+ });
117
+
44
118
  it('should support object with "toString" property', function () {
45
119
  // Note: used to throw (found by QuickCheck)
46
120
  const obj1 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whotracksme/reporting",
3
- "version": "8.0.1",
3
+ "version": "8.0.2",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "scripts": {
@@ -26,18 +26,20 @@ Scenarios actively used by `reporting/test/request/index.test.js`:
26
26
 
27
27
  | Release | Scenario | What it covers |
28
28
  | ---------------- | ----------------- | ------------------------------------------------------------------ |
29
- | `2024-08-02` | `0001-empty-page` | Plain page load with no third-party resources β€” `requestStats` must stay empty. |
30
- | `2024-08-02` | `0002-3rd-party` | Page with a single third-party script; verifies detection + the `wtm.attrack.tp_events` report shape. |
31
- | `2024-08-02` | `0005-preload` | `<link rel=preload>` triggers the tracker path through a different webRequest ordering. |
32
- | `2024-08-02-1` | `0004-ping` | Navigator `sendBeacon`/ping endpoints (non-XHR background request). |
33
- | `2024-08-02-2` | `0008-navigation` | Two successive navigations on the same tab; each page's trackers must be reported to the right page hostname. |
34
-
35
- Scenarios present on disk but not referenced by any current test (likely
36
- WIP or kept for a future regression test):
37
-
38
- - `2024-08-02-02/` (empty)
39
- - `2024-09-27/{0001-quick-close,0002-quick-navigation,0003-prefetch}`
40
- - `2024-09-30/0003-prefetch`
29
+ | `2026-04-23` | `0001-empty-page` | Plain page load with no third-party resources β€” `requestStats` must stay empty. |
30
+ | `2026-04-23` | `0002-3rd-party` | Page with a single third-party script; verifies detection + the `wtm.attrack.tp_events` report shape. |
31
+ | `2026-04-23` | `0004-ping` | Navigator `sendBeacon`/ping endpoints (non-XHR background request). |
32
+ | `2026-04-23` | `0005-preload` | `<link rel=preload>` triggers the tracker path through a different webRequest ordering. |
33
+ | `2026-04-23` | `0008-navigation` | Two successive navigations on the same tab; each page's trackers must be reported to the right page hostname. |
34
+
35
+ The `2026-04-23` release also ships Chromium recordings for scenarios
36
+ not yet wired into the test suite: `0003-prefetch`, `0006-preconnect`,
37
+ `0007-prerender`, `0009-beacon` β€” useful targets for exercising the
38
+ document-centric attribution paths.
39
+
40
+ Earlier releases (`2024-08-02`, `2024-08-02-1`, `2024-08-02-2`,
41
+ `2024-09-27`, `2024-09-30`) remain available via the on-demand
42
+ download path and are referenced by tests pinned to them.
41
43
 
42
44
  ## Related: `../snapshots/`
43
45
 
@@ -11,7 +11,7 @@
11
11
  */
12
12
 
13
13
  // This global provides an API like an ES Map but will sync
14
- // with local storage from time to time. That is done to prevent
14
+ // with session storage from time to time. That is done to prevent
15
15
  // the loss of all stats when the browser terminates the execution
16
16
  // context (background script or service worker).
17
17
  export default class ChromeStorageMap {
@@ -34,7 +34,7 @@ export default class ChromeStorageMap {
34
34
  this.maxEntries = maxEntries;
35
35
 
36
36
  // Make sure old entries that were not cleaned up are eventually
37
- // removed. Otherwise, we could exceed the local storage quota.
37
+ // removed. Otherwise, we could exceed the session storage quota.
38
38
  // Plus, when the maps get big, serializing and deserializing
39
39
  // may become expensive. If the actively triggered clean up works,
40
40
  // there should be no need to make this expiration too aggressive.
@@ -171,7 +171,7 @@ describe('RequestReporter', function () {
171
171
  it('detects no 3rd parties', async function () {
172
172
  const { seenTabIds } = await playScenario(chrome, {
173
173
  scenarioName: this.test.parent.title,
174
- scenarioRelease: '2024-08-02',
174
+ scenarioRelease: '2026-04-23',
175
175
  });
176
176
  await clock.runToLast();
177
177
  expect(
@@ -191,7 +191,7 @@ describe('RequestReporter', function () {
191
191
  it('detects 3rd parties', async function () {
192
192
  const { seenTabIds } = await playScenario(chrome, {
193
193
  scenarioName: this.test.parent.title,
194
- scenarioRelease: '2024-08-02',
194
+ scenarioRelease: '2026-04-23',
195
195
  });
196
196
  await clock.runToLast();
197
197
  expect(
@@ -209,7 +209,7 @@ describe('RequestReporter', function () {
209
209
  it('reports 3rd parties', async function () {
210
210
  const { seenTabIds } = await playScenario(chrome, {
211
211
  scenarioName: this.test.parent.title,
212
- scenarioRelease: '2024-08-02',
212
+ scenarioRelease: '2026-04-23',
213
213
  });
214
214
  await clock.runToLast();
215
215
  const eventPromise = new Promise((resolve) =>
@@ -226,17 +226,40 @@ describe('RequestReporter', function () {
226
226
  });
227
227
  });
228
228
 
229
- context('0004-ping', function () {
230
- it('reports pings', async function () {
229
+ context('0003-prefetch', function () {
230
+ it('reports prefetched 3rd parties', async function () {
231
+ const { seenTabIds } = await playScenario(chrome, {
232
+ scenarioName: this.test.parent.title,
233
+ scenarioRelease: '2026-04-23',
234
+ });
235
+ await clock.runToLast();
231
236
  const eventPromise = new Promise((resolve) =>
232
237
  communicationEmitter.once('send', resolve),
233
238
  );
234
- await playScenario(chrome, {
239
+ // force stage all pages
240
+ seenTabIds.forEach((tabId) => chrome.tabs.onRemoved.dispatch(tabId));
241
+ await clock.runToLast();
242
+ const event = await eventPromise;
243
+ expect(event).to.deep.include({
244
+ action: 'wtm.attrack.tp_events',
245
+ });
246
+ expect(event.payload.data[0].tps).to.have.keys(['subdomain.localhost']);
247
+ });
248
+ });
249
+
250
+ context('0004-ping', function () {
251
+ it('reports pings', async function () {
252
+ const { seenTabIds } = await playScenario(chrome, {
235
253
  scenarioName: this.test.parent.title,
236
- scenarioRelease: '2024-08-02-1',
254
+ scenarioRelease: '2026-04-23',
237
255
  });
238
256
  await clock.runToLast();
239
- // first tp_event from the page that sent ping
257
+ const eventPromise = new Promise((resolve) =>
258
+ communicationEmitter.once('send', resolve),
259
+ );
260
+ // force stage all pages
261
+ seenTabIds.forEach((tabId) => chrome.tabs.onRemoved.dispatch(tabId));
262
+ await clock.runToLast();
240
263
  const event = await eventPromise;
241
264
  expect(event).to.deep.include({
242
265
  action: 'wtm.attrack.tp_events',
@@ -249,7 +272,7 @@ describe('RequestReporter', function () {
249
272
  it('reports 3rd parties', async function () {
250
273
  const { seenTabIds } = await playScenario(chrome, {
251
274
  scenarioName: this.test.parent.title,
252
- scenarioRelease: '2024-08-02',
275
+ scenarioRelease: '2026-04-23',
253
276
  });
254
277
  await clock.runToLast();
255
278
  const eventPromise = new Promise((resolve) =>
@@ -266,6 +289,43 @@ describe('RequestReporter', function () {
266
289
  });
267
290
  });
268
291
 
292
+ context('0006-preconnect', function () {
293
+ it('does not attribute preconnect hints as 3rd parties', async function () {
294
+ const { seenTabIds } = await playScenario(chrome, {
295
+ scenarioName: this.test.parent.title,
296
+ scenarioRelease: '2026-04-23',
297
+ });
298
+ await clock.runToLast();
299
+ expect(reporter.pageStore.checkIfEmpty()).to.be.false;
300
+ expect(seenTabIds).to.have.property('size', 1);
301
+ const tabId = seenTabIds.values().next().value;
302
+ const tab = reporter.pageStore.getPageForRequest({ tabId, frameId: 0 });
303
+ // preconnect opens a socket but fires no webRequest, so no
304
+ // third-party counters should accumulate.
305
+ expect(tab.requestStats).to.be.empty;
306
+ });
307
+ });
308
+
309
+ context('0007-prerender', function () {
310
+ it('keeps prerender stats off the visible page', async function () {
311
+ const { seenTabIds } = await playScenario(chrome, {
312
+ scenarioName: this.test.parent.title,
313
+ scenarioRelease: '2026-04-23',
314
+ });
315
+ await clock.runToLast();
316
+ expect(reporter.pageStore.checkIfEmpty()).to.be.false;
317
+ // The visible localhost:8080 page has no third parties; the
318
+ // prerendered document lives on a separate tab and is not
319
+ // counted against the one the user is looking at.
320
+ const visibleTabId = seenTabIds.values().next().value;
321
+ const tab = reporter.pageStore.getPageForRequest({
322
+ tabId: visibleTabId,
323
+ frameId: 0,
324
+ });
325
+ expect(tab.requestStats).to.be.empty;
326
+ });
327
+ });
328
+
269
329
  context('0008-navigation', function () {
270
330
  it('reports 3rd parties', async function () {
271
331
  const eventPromise1 = new Promise((resolve) =>
@@ -273,7 +333,7 @@ describe('RequestReporter', function () {
273
333
  );
274
334
  const { seenTabIds } = await playScenario(chrome, {
275
335
  scenarioName: this.test.parent.title,
276
- scenarioRelease: '2024-08-02-2',
336
+ scenarioRelease: '2026-04-23',
277
337
  });
278
338
  await clock.runToLast();
279
339
  const event1 = await eventPromise1;
@@ -299,6 +359,39 @@ describe('RequestReporter', function () {
299
359
  });
300
360
  });
301
361
 
362
+ context('0009-beacon', function () {
363
+ // SKIP: passes only on the documentId-centric attribution
364
+ // branch. User searches on search.localhost, clicks through to
365
+ // landing.localhost, and the search document fires two beacons
366
+ // to beacon.localhost (click handler + pagehide). Each beacon
367
+ // webRequest carries the search document's documentId, so
368
+ // correct attribution keeps beacon.localhost on search's
369
+ // tp_events. Main's tabId+previous-chain logic misattributes
370
+ // the beacons to a staged-and-dead page, silently dropping
371
+ // them.
372
+ it.skip('attributes late beacon to the source document', async function () {
373
+ const events = [];
374
+ communicationEmitter.on('send', (msg) => {
375
+ if (msg.action === 'wtm.attrack.tp_events') {
376
+ events.push(msg);
377
+ }
378
+ });
379
+ const { seenTabIds } = await playScenario(chrome, {
380
+ scenarioName: this.test.parent.title,
381
+ scenarioRelease: '2026-04-23',
382
+ });
383
+ await clock.runToLast();
384
+ // Force-stage remaining pages so any held documents flush.
385
+ seenTabIds.forEach((tabId) => chrome.tabs.onRemoved.dispatch(tabId));
386
+ await clock.runToLast();
387
+ const emittedBeacon = events.some((e) =>
388
+ Object.keys(e.payload.data[0].tps).includes('beacon.localhost'),
389
+ );
390
+ expect(emittedBeacon, 'beacon.localhost must land in some tp_events')
391
+ .to.be.true;
392
+ });
393
+ });
394
+
302
395
  context('snapshots', function () {
303
396
  this.timeout(10000);
304
397