@whotracksme/reporting 8.0.1 → 9.0.0

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.
@@ -120,6 +120,20 @@ describe('request/index', function () {
120
120
 
121
121
  function simulatePageLoad(pageSpec) {
122
122
  chrome.tabs.onCreated.dispatch(pageSpec.tab);
123
+
124
+ const seen = new Set();
125
+ for (const req of pageSpec.onBeforeRequest) {
126
+ if (seen.has(req.documentId)) continue;
127
+ seen.add(req.documentId);
128
+ chrome.webNavigation.onCommitted.dispatch({
129
+ tabId: req.tabId,
130
+ frameId: req.frameId,
131
+ documentId: req.documentId,
132
+ parentDocumentId: req.parentDocumentId,
133
+ url: req.url,
134
+ });
135
+ }
136
+
123
137
  return {
124
138
  onBeforeRequest: pageSpec.onBeforeRequest.map(function (reqData) {
125
139
  const response = attrack.onBeforeRequest(reqData);
@@ -264,15 +278,26 @@ describe('request/index', function () {
264
278
  attrack.config.tokenDomainCountThreshold = 0; // block first time
265
279
  });
266
280
 
267
- it('removes all occurances of uid in the request', function () {
281
+ function commitTab() {
268
282
  chrome.tabs.onCreated.dispatch({
269
283
  id: 34,
270
284
  url: 'http://cliqztest.com/',
271
285
  });
286
+ chrome.webNavigation.onCommitted.dispatch({
287
+ tabId: 34,
288
+ frameId: 0,
289
+ documentId: 'doc-34-0',
290
+ url: 'http://cliqztest.com/',
291
+ });
292
+ }
293
+
294
+ it('removes all occurances of uid in the request', function () {
295
+ commitTab();
272
296
  const response = attrack.onBeforeRequest({
273
297
  tabId: 34,
274
298
  frameId: 0,
275
299
  parentFrameId: -1,
300
+ documentId: 'doc-34-0',
276
301
  method: 'GET',
277
302
  type: 'xmlhttprequest',
278
303
  url: `http://tracker.com/track;uid=${uid}?uid2=${uid}&encuid=${encodeURIComponent(
@@ -288,14 +313,12 @@ describe('request/index', function () {
288
313
  });
289
314
 
290
315
  it('removes also after subsequent redirect with same uid', function () {
291
- chrome.tabs.onCreated.dispatch({
292
- id: 34,
293
- url: 'http://cliqztest.com/',
294
- });
316
+ commitTab();
295
317
  let response = attrack.onBeforeRequest({
296
318
  tabId: 34,
297
319
  frameId: 0,
298
320
  parentFrameId: -1,
321
+ documentId: 'doc-34-0',
299
322
  method: 'GET',
300
323
  type: 'xmlhttprequest',
301
324
  url: `http://tracker.com/track;uid=${uid}?uid2=${uid}&encuid=${encodeURIComponent(
@@ -314,6 +337,7 @@ describe('request/index', function () {
314
337
  tabId: 34,
315
338
  frameId: 0,
316
339
  parentFrameId: -1,
340
+ documentId: 'doc-34-0',
317
341
  method: 'GET',
318
342
  type: 'xmlhttprequest',
319
343
  url: `http://tracker.com/track;uid=cliqz.com/tracking&uid2=cliqz.com/tracking&uid=${uid}?uid2=${uid}&encuid=${encodeURIComponent(
@@ -1,4 +1,3 @@
1
- /* eslint-disable prettier/prettier */
2
1
  /**
3
2
  * WhoTracks.Me
4
3
  * https://ghostery.com/whotracksme
@@ -13,7 +12,7 @@
13
12
  import chrome from 'sinon-chrome';
14
13
  import sinon from 'sinon';
15
14
  import { expect } from 'chai';
16
- import EventEmitter, { once } from 'node:events';
15
+ import EventEmitter from 'node:events';
17
16
  import { IDBFactory } from 'fake-indexeddb';
18
17
 
19
18
  import {
@@ -25,6 +24,7 @@ import {
25
24
  import { base64ToArrayBuffer } from '../helpers/fetch-mock.js';
26
25
 
27
26
  import { setLogLevel } from '../../src/logger.js';
27
+ import { truncatedHash } from '../../src/md5.js';
28
28
  import RequestReporter from '../../src/request/index.js';
29
29
 
30
30
  const config = {
@@ -119,70 +119,17 @@ describe('RequestReporter', function () {
119
119
  delete globalThis.indexedDB;
120
120
  });
121
121
 
122
- context('synthetic events', function () {
123
- it('records stats from redirects', async function () {
124
- const events = once(communicationEmitter, 'send');
125
-
126
- const tab = { id: 1, url: 'https://www.onet.pl/' };
127
- // creates a page
128
- chrome.tabs.onCreated.dispatch(tab);
129
- // changes state to 'completed'
130
- chrome.webNavigation.onCompleted.dispatch({ tabId: tab.id, frameId: 0, });
131
-
132
- // prepare iframe
133
- chrome.webNavigation.onCommitted.dispatch({ tabId: tab.id, parentFrameId: 0, frameId:15032385542, url: "https://pulsembed.eu/p2em/3VgyZUiWT/"});
134
- chrome.webNavigation.onCommitted.dispatch({ tabId: tab.id, parentFrameId: 15032385542, frameId: 17179869195, url: "https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1"});
135
-
136
- // Fragment of 0002 snapshot
137
- chrome.webRequest.onBeforeRequest.dispatch({"requestId":"294","url":"https://googleads.g.doubleclick.net/pagead/id","originUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","documentUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","method":"GET","type":"xmlhttprequest","timeStamp":1729760357996,"tabId":tab.id,"frameId":17179869195,"parentFrameId":15032385542,"incognito":false,"thirdParty":true,"cookieStoreId":"firefox-default","proxyInfo":null,"ip":null,"frameAncestors":[{"frameId":15032385542,"url":"https://pulsembed.eu/p2em/3VgyZUiWT/"},{"frameId":0,"url":"https://www.onet.pl/"}],"urlClassification":{"firstParty":[],"thirdParty":["tracking_ad","any_basic_tracking","any_strict_tracking"]},"requestSize":0,"responseSize":0});
138
- chrome.webRequest.onBeforeSendHeaders.dispatch({"requestId":"294","url":"https://googleads.g.doubleclick.net/pagead/id","originUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","documentUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","method":"GET","type":"xmlhttprequest","timeStamp":1729760357997,"tabId":tab.id,"frameId":17179869195,"parentFrameId":15032385542,"incognito":false,"thirdParty":true,"cookieStoreId":"firefox-default","proxyInfo":null,"ip":null,"frameAncestors":[{"frameId":15032385542,"url":"https://pulsembed.eu/p2em/3VgyZUiWT/"},{"frameId":0,"url":"https://www.onet.pl/"}],"urlClassification":{"firstParty":[],"thirdParty":["tracking_ad","any_basic_tracking","any_strict_tracking"]},"requestSize":0,"responseSize":0});
139
- chrome.webRequest.onSendHeaders.dispatch({"requestId":"294","url":"https://googleads.g.doubleclick.net/pagead/id","originUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","documentUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","method":"GET","type":"xmlhttprequest","timeStamp":1729760357997,"tabId":tab.id,"frameId":17179869195,"parentFrameId":15032385542,"incognito":false,"thirdParty":true,"cookieStoreId":"firefox-default","proxyInfo":null,"ip":null,"frameAncestors":[{"frameId":15032385542,"url":"https://pulsembed.eu/p2em/3VgyZUiWT/"},{"frameId":0,"url":"https://www.onet.pl/"}],"urlClassification":{"firstParty":[],"thirdParty":["tracking_ad","any_basic_tracking","any_strict_tracking"]},"requestSize":0,"responseSize":0});
140
- chrome.webRequest.onHeadersReceived.dispatch({"requestId":"294","url":"https://googleads.g.doubleclick.net/pagead/id","originUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","documentUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","method":"GET","type":"xmlhttprequest","timeStamp":1729760358179,"tabId":tab.id,"frameId":17179869195,"parentFrameId":15032385542,"incognito":false,"thirdParty":true,"cookieStoreId":"firefox-default","fromCache":false,"responseHeaders":[{"name":"p3p","value":"policyref=\"https://googleads.g.doubleclick.net/pagead/gcn_p3p_.xml\", CP=\"CURa ADMa DEVa TAIo PSAo PSDo OUR IND UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR\""},{"name":"timing-allow-origin","value":"*"},{"name":"cross-origin-resource-policy","value":"cross-origin"},{"name":"location","value":"https://googleads.g.doubleclick.net/pagead/id?slf_rd=1"},{"name":"access-control-allow-credentials","value":"true"},{"name":"access-control-allow-origin","value":"https://www.youtube.com"},{"name":"date","value":"Thu, 24 Oct 2024 08:59:18 GMT"},{"name":"pragma","value":"no-cache"},{"name":"expires","value":"Fri, 01 Jan 1990 00:00:00 GMT"},{"name":"cache-control","value":"no-cache, no-store, must-revalidate"},{"name":"content-type","value":"text/html; charset=UTF-8"},{"name":"x-content-type-options","value":"nosniff"},{"name":"server","value":"cafe"},{"name":"content-length","value":"0"},{"name":"x-xss-protection","value":"0"},{"name":"alt-svc","value":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"},{"name":"X-Firefox-Spdy","value":"h2"}],"statusCode":302,"statusLine":"HTTP/2.0 302 ","proxyInfo":null,"ip":"172.217.16.162","frameAncestors":[{"frameId":15032385542,"url":"https://pulsembed.eu/p2em/3VgyZUiWT/"},{"frameId":0,"url":"https://www.onet.pl/"}],"urlClassification":{"firstParty":[],"thirdParty":["tracking_ad","any_basic_tracking","any_strict_tracking"]},"requestSize":0,"responseSize":0});
141
- chrome.webRequest.onBeforeRedirect.dispatch({"requestId":"294","url":"https://googleads.g.doubleclick.net/pagead/id","originUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","documentUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","method":"GET","type":"xmlhttprequest","timeStamp":1729760358180,"tabId":tab.id,"frameId":17179869195,"parentFrameId":15032385542,"incognito":false,"thirdParty":true,"cookieStoreId":"firefox-default","fromCache":false,"responseHeaders":[{"name":"p3p","value":"policyref=\"https://googleads.g.doubleclick.net/pagead/gcn_p3p_.xml\", CP=\"CURa ADMa DEVa TAIo PSAo PSDo OUR IND UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR\""},{"name":"timing-allow-origin","value":"*"},{"name":"cross-origin-resource-policy","value":"cross-origin"},{"name":"location","value":"https://googleads.g.doubleclick.net/pagead/id?slf_rd=1"},{"name":"access-control-allow-credentials","value":"true"},{"name":"access-control-allow-origin","value":"https://www.youtube.com"},{"name":"date","value":"Thu, 24 Oct 2024 08:59:18 GMT"},{"name":"pragma","value":"no-cache"},{"name":"expires","value":"Fri, 01 Jan 1990 00:00:00 GMT"},{"name":"cache-control","value":"no-cache, no-store, must-revalidate"},{"name":"content-type","value":"text/html; charset=UTF-8"},{"name":"x-content-type-options","value":"nosniff"},{"name":"server","value":"cafe"},{"name":"content-length","value":"0"},{"name":"x-xss-protection","value":"0"},{"name":"alt-svc","value":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"},{"name":"X-Firefox-Spdy","value":"h2"}],"statusCode":302,"statusLine":"HTTP/2.0 302 ","redirectUrl":"https://googleads.g.doubleclick.net/pagead/id?slf_rd=1","proxyInfo":null,"ip":"172.217.16.162","frameAncestors":[{"frameId":15032385542,"url":"https://pulsembed.eu/p2em/3VgyZUiWT/"},{"frameId":0,"url":"https://www.onet.pl/"}],"urlClassification":{"firstParty":[],"thirdParty":["tracking_ad","any_basic_tracking","any_strict_tracking"]},"requestSize":0,"responseSize":0});
142
- chrome.webRequest.onBeforeRequest.dispatch({"requestId":"294","url":"https://googleads.g.doubleclick.net/pagead/id?slf_rd=1","originUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","documentUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","method":"GET","type":"xmlhttprequest","timeStamp":1729760358181,"tabId":tab.id,"frameId":17179869195,"parentFrameId":15032385542,"incognito":false,"thirdParty":true,"cookieStoreId":"firefox-default","proxyInfo":null,"ip":null,"frameAncestors":[{"frameId":15032385542,"url":"https://pulsembed.eu/p2em/3VgyZUiWT/"},{"frameId":0,"url":"https://www.onet.pl/"}],"urlClassification":{"firstParty":[],"thirdParty":["tracking_ad","any_basic_tracking","any_strict_tracking"]},"requestSize":0,"responseSize":0});
143
- chrome.webRequest.onBeforeSendHeaders.dispatch({"requestId":"294","url":"https://googleads.g.doubleclick.net/pagead/id?slf_rd=1","originUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","documentUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","method":"GET","type":"xmlhttprequest","timeStamp":1729760358182,"tabId":tab.id,"frameId":17179869195,"parentFrameId":15032385542,"incognito":false,"thirdParty":true,"cookieStoreId":"firefox-default","proxyInfo":null,"ip":null,"frameAncestors":[{"frameId":15032385542,"url":"https://pulsembed.eu/p2em/3VgyZUiWT/"},{"frameId":0,"url":"https://www.onet.pl/"}],"urlClassification":{"firstParty":[],"thirdParty":["tracking_ad","any_basic_tracking","any_strict_tracking"]},"requestSize":0,"responseSize":0});
144
- chrome.webRequest.onSendHeaders.dispatch({"requestId":"294","url":"https://googleads.g.doubleclick.net/pagead/id?slf_rd=1","originUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","documentUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","method":"GET","type":"xmlhttprequest","timeStamp":1729760358182,"tabId":tab.id,"frameId":17179869195,"parentFrameId":15032385542,"incognito":false,"thirdParty":true,"cookieStoreId":"firefox-default","proxyInfo":null,"ip":null,"frameAncestors":[{"frameId":15032385542,"url":"https://pulsembed.eu/p2em/3VgyZUiWT/"},{"frameId":0,"url":"https://www.onet.pl/"}],"urlClassification":{"firstParty":[],"thirdParty":["tracking_ad","any_basic_tracking","any_strict_tracking"]},"requestSize":0,"responseSize":0});
145
- chrome.webRequest.onHeadersReceived.dispatch({"requestId":"294","url":"https://googleads.g.doubleclick.net/pagead/id?slf_rd=1","originUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","documentUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","method":"GET","type":"xmlhttprequest","timeStamp":1729760358221,"tabId":tab.id,"frameId":17179869195,"parentFrameId":15032385542,"incognito":false,"thirdParty":true,"cookieStoreId":"firefox-default","fromCache":false,"responseHeaders":[{"name":"p3p","value":"policyref=\"https://googleads.g.doubleclick.net/pagead/gcn_p3p_.xml\", CP=\"CURa ADMa DEVa TAIo PSAo PSDo OUR IND UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR\""},{"name":"timing-allow-origin","value":"*"},{"name":"cross-origin-resource-policy","value":"cross-origin"},{"name":"access-control-allow-credentials","value":"true"},{"name":"access-control-allow-origin","value":"https://www.youtube.com"},{"name":"content-type","value":"application/json; charset=UTF-8"},{"name":"date","value":"Thu, 24 Oct 2024 08:59:18 GMT"},{"name":"pragma","value":"no-cache"},{"name":"expires","value":"Fri, 01 Jan 1990 00:00:00 GMT"},{"name":"cache-control","value":"no-cache, no-store, must-revalidate"},{"name":"x-content-type-options","value":"nosniff"},{"name":"content-disposition","value":"attachment; filename=\"f.txt\""},{"name":"content-encoding","value":"gzip"},{"name":"server","value":"cafe"},{"name":"content-length","value":"120"},{"name":"x-xss-protection","value":"0"},{"name":"alt-svc","value":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"},{"name":"X-Firefox-Http3","value":"h3"}],"statusCode":200,"statusLine":"HTTP/3.0 200 ","proxyInfo":null,"ip":"172.217.16.162","frameAncestors":[{"frameId":15032385542,"url":"https://pulsembed.eu/p2em/3VgyZUiWT/"},{"frameId":0,"url":"https://www.onet.pl/"}],"urlClassification":{"firstParty":[],"thirdParty":["tracking_ad","any_basic_tracking","any_strict_tracking"]},"requestSize":0,"responseSize":0});
146
- chrome.webRequest.onResponseStarted.dispatch({"requestId":"294","url":"https://googleads.g.doubleclick.net/pagead/id?slf_rd=1","originUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","documentUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","method":"GET","type":"xmlhttprequest","timeStamp":1729760358221,"tabId":tab.id,"frameId":17179869195,"parentFrameId":15032385542,"incognito":false,"thirdParty":true,"cookieStoreId":"firefox-default","fromCache":false,"responseHeaders":[{"name":"p3p","value":"policyref=\"https://googleads.g.doubleclick.net/pagead/gcn_p3p_.xml\", CP=\"CURa ADMa DEVa TAIo PSAo PSDo OUR IND UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR\""},{"name":"timing-allow-origin","value":"*"},{"name":"cross-origin-resource-policy","value":"cross-origin"},{"name":"access-control-allow-credentials","value":"true"},{"name":"access-control-allow-origin","value":"https://www.youtube.com"},{"name":"content-type","value":"application/json; charset=UTF-8"},{"name":"date","value":"Thu, 24 Oct 2024 08:59:18 GMT"},{"name":"pragma","value":"no-cache"},{"name":"expires","value":"Fri, 01 Jan 1990 00:00:00 GMT"},{"name":"cache-control","value":"no-cache, no-store, must-revalidate"},{"name":"x-content-type-options","value":"nosniff"},{"name":"content-disposition","value":"attachment; filename=\"f.txt\""},{"name":"content-encoding","value":"gzip"},{"name":"server","value":"cafe"},{"name":"content-length","value":"120"},{"name":"x-xss-protection","value":"0"},{"name":"alt-svc","value":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"},{"name":"X-Firefox-Http3","value":"h3"}],"statusCode":200,"statusLine":"HTTP/3.0 200 ","proxyInfo":null,"ip":"172.217.16.162","frameAncestors":[{"frameId":15032385542,"url":"https://pulsembed.eu/p2em/3VgyZUiWT/"},{"frameId":0,"url":"https://www.onet.pl/"}],"urlClassification":{"firstParty":[],"thirdParty":["tracking_ad","any_basic_tracking","any_strict_tracking"]},"requestSize":0,"responseSize":0});
147
- chrome.webRequest.onCompleted.dispatch({"requestId":"294","url":"https://googleads.g.doubleclick.net/pagead/id?slf_rd=1","originUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","documentUrl":"https://www.youtube.com/embed/sQpzRs4j1NQ?mute=1&widget_referrer=https%3A%2F%2Fwww.onet.pl%2F&enablejsapi=1&origin=https%3A%2F%2Fpulsembed.eu&widgetid=1","method":"GET","type":"xmlhttprequest","timeStamp":1729760358221,"tabId":tab.id,"frameId":17179869195,"parentFrameId":15032385542,"incognito":false,"thirdParty":true,"cookieStoreId":"firefox-default","fromCache":false,"responseHeaders":[{"name":"p3p","value":"policyref=\"https://googleads.g.doubleclick.net/pagead/gcn_p3p_.xml\", CP=\"CURa ADMa DEVa TAIo PSAo PSDo OUR IND UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR\""},{"name":"timing-allow-origin","value":"*"},{"name":"cross-origin-resource-policy","value":"cross-origin"},{"name":"access-control-allow-credentials","value":"true"},{"name":"access-control-allow-origin","value":"https://www.youtube.com"},{"name":"content-type","value":"application/json; charset=UTF-8"},{"name":"date","value":"Thu, 24 Oct 2024 08:59:18 GMT"},{"name":"pragma","value":"no-cache"},{"name":"expires","value":"Fri, 01 Jan 1990 00:00:00 GMT"},{"name":"cache-control","value":"no-cache, no-store, must-revalidate"},{"name":"x-content-type-options","value":"nosniff"},{"name":"content-disposition","value":"attachment; filename=\"f.txt\""},{"name":"content-encoding","value":"gzip"},{"name":"server","value":"cafe"},{"name":"content-length","value":"120"},{"name":"x-xss-protection","value":"0"},{"name":"alt-svc","value":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"},{"name":"X-Firefox-Http3","value":"h3"}],"statusCode":200,"statusLine":"HTTP/3.0 200 ","proxyInfo":null,"ip":"172.217.16.162","frameAncestors":[{"frameId":15032385542,"url":"https://pulsembed.eu/p2em/3VgyZUiWT/"},{"frameId":0,"url":"https://www.onet.pl/"}],"urlClassification":{"firstParty":[],"thirdParty":["tracking_ad","any_basic_tracking","any_strict_tracking"]},"requestSize":0,"responseSize":0});
148
-
149
- // stages the page for sendout
150
- chrome.tabs.onRemoved.dispatch(tab.id);
151
- await clock.runToLast();
152
-
153
- const [event] = await events;
154
- expect(event).to.include({ action: 'wtm.attrack.tp_events' });
155
- expect(
156
- event.payload.data[0].tps['googleads.g.doubleclick.net'],
157
- ).to.deep.equal({
158
- c: 2,
159
- type_11: 2,
160
- scheme_https: 2,
161
- resp_ob: 2,
162
- content_length: 121,
163
- status_302: 1,
164
- has_qs: 1,
165
- status_200: 1,
166
- });
167
- });
168
- });
169
-
170
122
  context('0001-empty-page', function () {
171
123
  it('detects no 3rd parties', async function () {
172
124
  const { seenTabIds } = await playScenario(chrome, {
173
125
  scenarioName: this.test.parent.title,
174
- scenarioRelease: '2024-08-02',
126
+ scenarioRelease: '2026-04-23',
175
127
  });
176
128
  await clock.runToLast();
177
- expect(
178
- reporter.pageStore.checkIfEmpty(),
179
- ).to.be.false;
129
+ expect(reporter.pageStore.checkIfEmpty()).to.be.false;
180
130
  expect(seenTabIds).to.have.property('size', 1);
181
131
  const tabId = seenTabIds.values().next().value;
182
- const tab = reporter.pageStore.getPageForRequest({
183
- tabId,
184
- frameId: 0,
185
- });
132
+ const tab = reporter.pageStore.findPageForTab(tabId);
186
133
  expect(tab.requestStats).to.be.empty;
187
134
  });
188
135
  });
@@ -191,25 +138,20 @@ describe('RequestReporter', function () {
191
138
  it('detects 3rd parties', async function () {
192
139
  const { seenTabIds } = await playScenario(chrome, {
193
140
  scenarioName: this.test.parent.title,
194
- scenarioRelease: '2024-08-02',
141
+ scenarioRelease: '2026-04-23',
195
142
  });
196
143
  await clock.runToLast();
197
- expect(
198
- reporter.pageStore.checkIfEmpty(),
199
- ).to.be.false;
144
+ expect(reporter.pageStore.checkIfEmpty()).to.be.false;
200
145
  expect(seenTabIds).to.have.property('size', 1);
201
146
  const tabId = seenTabIds.values().next().value;
202
- const tab = reporter.pageStore.getPageForRequest({
203
- tabId,
204
- frameId: 0,
205
- });
147
+ const tab = reporter.pageStore.findPageForTab(tabId);
206
148
  expect(tab.requestStats).to.have.keys(['script.localhost']);
207
149
  });
208
150
 
209
151
  it('reports 3rd parties', async function () {
210
152
  const { seenTabIds } = await playScenario(chrome, {
211
153
  scenarioName: this.test.parent.title,
212
- scenarioRelease: '2024-08-02',
154
+ scenarioRelease: '2026-04-23',
213
155
  });
214
156
  await clock.runToLast();
215
157
  const eventPromise = new Promise((resolve) =>
@@ -217,6 +159,7 @@ describe('RequestReporter', function () {
217
159
  );
218
160
  // force stage all pages
219
161
  seenTabIds.forEach((tabId) => chrome.tabs.onRemoved.dispatch(tabId));
162
+ await reporter.pageStore.flush();
220
163
  await clock.runToLast();
221
164
  const event = await eventPromise;
222
165
  expect(event).to.deep.include({
@@ -226,22 +169,72 @@ describe('RequestReporter', function () {
226
169
  });
227
170
  });
228
171
 
229
- context('0004-ping', function () {
230
- it('reports pings', async function () {
172
+ context('0003-prefetch', function () {
173
+ it('reports prefetched 3rd parties', async function () {
174
+ const { seenTabIds } = await playScenario(chrome, {
175
+ scenarioName: this.test.parent.title,
176
+ scenarioRelease: '2026-04-23',
177
+ });
178
+ await clock.runToLast();
231
179
  const eventPromise = new Promise((resolve) =>
232
180
  communicationEmitter.once('send', resolve),
233
181
  );
234
- await playScenario(chrome, {
235
- scenarioName: this.test.parent.title,
236
- scenarioRelease: '2024-08-02-1',
237
- });
182
+ // force stage all pages
183
+ seenTabIds.forEach((tabId) => chrome.tabs.onRemoved.dispatch(tabId));
184
+ await reporter.pageStore.flush();
238
185
  await clock.runToLast();
239
- // first tp_event from the page that sent ping
240
186
  const event = await eventPromise;
241
187
  expect(event).to.deep.include({
242
188
  action: 'wtm.attrack.tp_events',
243
189
  });
244
- expect(event.payload.data[0].tps).to.have.keys(['ping.localhost']);
190
+ expect(event.payload.data[0].tps).to.have.keys(['subdomain.localhost']);
191
+ });
192
+ });
193
+
194
+ context('0004-ping', function () {
195
+ it('reports pings', async function () {
196
+ // The ping fires from the first document (path "/") during
197
+ // navigation to the second (path "/result"), so correct
198
+ // documentId attribution puts ping.localhost on the source
199
+ // page's tp_events. The `next` page, if it emits at all,
200
+ // must not carry the ping. We collect tp_events across the
201
+ // whole run because the source page is held at nav time and
202
+ // its timer fires inside the first runToLast — earlier than
203
+ // a `.once('send')` listener set up after it would catch.
204
+ const events = [];
205
+ communicationEmitter.on('send', (msg) => {
206
+ if (msg.action === 'wtm.attrack.tp_events') {
207
+ events.push(msg);
208
+ }
209
+ });
210
+ const { seenTabIds } = await playScenario(chrome, {
211
+ scenarioName: this.test.parent.title,
212
+ scenarioRelease: '2026-04-23',
213
+ });
214
+ await clock.runToLast();
215
+ // force stage all pages
216
+ seenTabIds.forEach((tabId) => chrome.tabs.onRemoved.dispatch(tabId));
217
+ await reporter.pageStore.flush();
218
+ await clock.runToLast();
219
+ const sourcePathHash = truncatedHash('/');
220
+ const successorPathHash = truncatedHash('/result');
221
+ const sourceEvent = events.find(
222
+ (e) => e.payload.data[0].path === sourcePathHash,
223
+ );
224
+ const successorEvent = events.find(
225
+ (e) => e.payload.data[0].path === successorPathHash,
226
+ );
227
+ expect(sourceEvent, 'source page tp_events must fire').to.exist;
228
+ expect(Object.keys(sourceEvent.payload.data[0].tps)).to.include(
229
+ 'ping.localhost',
230
+ );
231
+ // The /result page has no third parties of its own; if it
232
+ // emits at all, it must not carry the source's ping.
233
+ if (successorEvent) {
234
+ expect(
235
+ Object.keys(successorEvent.payload.data[0].tps),
236
+ ).to.not.include('ping.localhost');
237
+ }
245
238
  });
246
239
  });
247
240
 
@@ -249,7 +242,7 @@ describe('RequestReporter', function () {
249
242
  it('reports 3rd parties', async function () {
250
243
  const { seenTabIds } = await playScenario(chrome, {
251
244
  scenarioName: this.test.parent.title,
252
- scenarioRelease: '2024-08-02',
245
+ scenarioRelease: '2026-04-23',
253
246
  });
254
247
  await clock.runToLast();
255
248
  const eventPromise = new Promise((resolve) =>
@@ -257,6 +250,7 @@ describe('RequestReporter', function () {
257
250
  );
258
251
  // force stage all pages
259
252
  seenTabIds.forEach((tabId) => chrome.tabs.onRemoved.dispatch(tabId));
253
+ await reporter.pageStore.flush();
260
254
  await clock.runToLast();
261
255
  const event = await eventPromise;
262
256
  expect(event).to.deep.include({
@@ -266,39 +260,124 @@ describe('RequestReporter', function () {
266
260
  });
267
261
  });
268
262
 
263
+ context('0006-preconnect', function () {
264
+ it('does not attribute preconnect hints as 3rd parties', async function () {
265
+ const { seenTabIds } = await playScenario(chrome, {
266
+ scenarioName: this.test.parent.title,
267
+ scenarioRelease: '2026-04-23',
268
+ });
269
+ await clock.runToLast();
270
+ expect(reporter.pageStore.checkIfEmpty()).to.be.false;
271
+ expect(seenTabIds).to.have.property('size', 1);
272
+ const tabId = seenTabIds.values().next().value;
273
+ const tab = reporter.pageStore.findPageForTab(tabId);
274
+ // preconnect opens a socket but fires no webRequest, so no
275
+ // third-party counters should accumulate.
276
+ expect(tab.requestStats).to.be.empty;
277
+ });
278
+ });
279
+
280
+ context('0007-prerender', function () {
281
+ it('keeps prerender stats off the visible page', async function () {
282
+ const { seenTabIds } = await playScenario(chrome, {
283
+ scenarioName: this.test.parent.title,
284
+ scenarioRelease: '2026-04-23',
285
+ });
286
+ await clock.runToLast();
287
+ expect(reporter.pageStore.checkIfEmpty()).to.be.false;
288
+ // The visible localhost:8080 page has no third parties; the
289
+ // prerendered document lives on a separate tab and is not
290
+ // counted against the one the user is looking at.
291
+ const visibleTabId = seenTabIds.values().next().value;
292
+ const tab = reporter.pageStore.findPageForTab(visibleTabId);
293
+ expect(tab.requestStats).to.be.empty;
294
+ });
295
+ });
296
+
269
297
  context('0008-navigation', function () {
270
298
  it('reports 3rd parties', async function () {
271
- const eventPromise1 = new Promise((resolve) =>
272
- communicationEmitter.once('send', resolve),
273
- );
299
+ // Two main-frame navigations on the same tab; each page's
300
+ // trackers should attribute to its own document. With
301
+ // event-driven emission (flush on SW startup / tab close),
302
+ // both pages are emitted together once we flush; we then
303
+ // look them up by their own hostname.
304
+ const events = [];
305
+ communicationEmitter.on('send', (msg) => {
306
+ if (msg.action === 'wtm.attrack.tp_events') {
307
+ events.push(msg);
308
+ }
309
+ });
274
310
  const { seenTabIds } = await playScenario(chrome, {
275
311
  scenarioName: this.test.parent.title,
276
- scenarioRelease: '2024-08-02-2',
312
+ scenarioRelease: '2026-04-23',
277
313
  });
278
314
  await clock.runToLast();
279
- const event1 = await eventPromise1;
280
- expect(event1).to.deep.include({
281
- action: 'wtm.attrack.tp_events',
282
- });
283
- expect(event1.payload.data[0].tps).to.have.keys(['script1.localhost']);
284
- const eventPromise2 = new Promise((resolve) =>
285
- communicationEmitter.once('send', resolve),
286
- );
287
315
  // force stage all pages
288
316
  seenTabIds.forEach((tabId) => chrome.tabs.onRemoved.dispatch(tabId));
317
+ await reporter.pageStore.flush();
289
318
  await clock.runToLast();
290
- const event2 = await eventPromise2;
291
- expect(event2).to.deep.include({
292
- action: 'wtm.attrack.tp_events',
293
- });
294
- expect(event2.payload.data[0].tps).to.have.keys(['script2.localhost']);
319
+ const page1Event = events.find((e) =>
320
+ Object.keys(e.payload.data[0].tps).includes('script1.localhost'),
321
+ );
322
+ const page2Event = events.find((e) =>
323
+ Object.keys(e.payload.data[0].tps).includes('script2.localhost'),
324
+ );
325
+ expect(page1Event, 'page1 tp_events must fire').to.exist;
326
+ expect(page2Event, 'page2 tp_events must fire').to.exist;
295
327
  // reports should belong to different pages
296
- expect(event1.payload.data[0].hostname).to.not.be.equal(
297
- event2.payload.data[0].hostname,
328
+ expect(page1Event.payload.data[0].hostname).to.not.be.equal(
329
+ page2Event.payload.data[0].hostname,
298
330
  );
299
331
  });
300
332
  });
301
333
 
334
+ context('0009-beacon', function () {
335
+ // Passes only with document-centric attribution. User searches
336
+ // on search.localhost, clicks through to landing.localhost, and
337
+ // the search document fires two beacons to beacon.localhost
338
+ // (click handler + pagehide). Each beacon webRequest carries
339
+ // the search document's documentId, so correct attribution
340
+ // keeps beacon.localhost on search's tp_events. On main the
341
+ // tabId+previous-chain logic misattributes the beacons to a
342
+ // staged-and-dead page and silently drops them.
343
+ it('attributes late beacon to the source document', async function () {
344
+ const events = [];
345
+ communicationEmitter.on('send', (msg) => {
346
+ if (msg.action === 'wtm.attrack.tp_events') {
347
+ events.push(msg);
348
+ }
349
+ });
350
+ const { seenTabIds } = await playScenario(chrome, {
351
+ scenarioName: this.test.parent.title,
352
+ scenarioRelease: '2026-04-23',
353
+ });
354
+ await clock.runToLast();
355
+ // Force-stage remaining pages so any held documents flush.
356
+ seenTabIds.forEach((tabId) => chrome.tabs.onRemoved.dispatch(tabId));
357
+ await reporter.pageStore.flush();
358
+ await clock.runToLast();
359
+ const searchHostnameHash = truncatedHash('search.localhost');
360
+ const landingHostnameHash = truncatedHash('landing.localhost');
361
+ const searchEvent = events.find(
362
+ (e) => e.payload.data[0].hostname === searchHostnameHash,
363
+ );
364
+ const landingEvent = events.find(
365
+ (e) => e.payload.data[0].hostname === landingHostnameHash,
366
+ );
367
+ // The beacon originates in the search document; it must land
368
+ // on that document's tp_events, not on the successor.
369
+ expect(searchEvent, 'search page tp_events must fire').to.exist;
370
+ expect(Object.keys(searchEvent.payload.data[0].tps)).to.include(
371
+ 'beacon.localhost',
372
+ );
373
+ if (landingEvent) {
374
+ expect(Object.keys(landingEvent.payload.data[0].tps)).to.not.include(
375
+ 'beacon.localhost',
376
+ );
377
+ }
378
+ });
379
+ });
380
+
302
381
  context('snapshots', function () {
303
382
  this.timeout(10000);
304
383
 
@@ -318,7 +397,7 @@ describe('RequestReporter', function () {
318
397
  }
319
398
  }
320
399
 
321
- for (const snapshotName of ['0001', '0002', '0003', '0004', '0005', '0006']) {
400
+ for (const snapshotName of ['0001', '0003', '0005']) {
322
401
  it(snapshotName, async function () {
323
402
  const messages = [];
324
403
  communicationEmitter.addListener('send', (message) =>
@@ -326,14 +405,19 @@ describe('RequestReporter', function () {
326
405
  );
327
406
  playSnapshotScenario(chrome, snapshotName);
328
407
 
329
- // run twice to allow token telemetry to trigger
408
+ // run twice to allow token telemetry to trigger. The
409
+ // documentIdPrefix makes the replay look like a fresh
410
+ // session so that documentId-keyed tp_events dedupe
411
+ // doesn't suppress its reports.
330
412
  playSnapshotScenario(chrome, snapshotName, {
331
- rewriteUrls: { 'onet.pl': 'wp.pl', 'soundcloud.com': 'google.com', 'nike.com': 'adidas.com' },
413
+ rewriteUrls: {
414
+ 'onet.pl': 'wp.pl',
415
+ 'soundcloud.com': 'google.com',
416
+ 'nike.com': 'adidas.com',
417
+ },
418
+ documentIdPrefix: 'replay2-',
332
419
  });
333
- await processRunloopUntil(
334
- reporter.tokenTelemetry
335
- .NEW_ENTRY_MIN_AGE,
336
- );
420
+ await processRunloopUntil(reporter.tokenTelemetry.NEW_ENTRY_MIN_AGE);
337
421
 
338
422
  /* eslint-disable no-undef */
339
423
  if (