@whotracksme/reporting 5.1.31 → 5.1.32

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.
@@ -30,7 +30,6 @@ import random from '../random.js';
30
30
  import BlockRules from './steps/block-rules.js';
31
31
  import CookieContext from './steps/cookie-context.js';
32
32
  import PageLogger from './steps/page-logger.js';
33
- import RedirectTagger from './steps/redirect-tagger.js';
34
33
  import TokenChecker from './steps/token-checker/index.js';
35
34
  import TokenExaminer from './steps/token-examiner.js';
36
35
  import TokenTelemetry from './steps/token-telemetry/index.js';
@@ -211,9 +210,8 @@ export default class RequestReporter {
211
210
 
212
211
  this.userAgent = (await this.getBrowserInfo()).name;
213
212
 
214
- this.pageLogger = new PageLogger(this.config);
213
+ this.pageLogger = new PageLogger(this.config.placeHolder);
215
214
  this.blockRules = new BlockRules(this.config);
216
- this.redirectTagger = new RedirectTagger();
217
215
  this.cookieContext = new CookieContext(this.config, this.qs_whitelist);
218
216
  await this.cookieContext.init();
219
217
 
@@ -280,11 +278,18 @@ export default class RequestReporter {
280
278
  }
281
279
 
282
280
  unload() {
283
- // Check is active usage, was sent
284
- this.qs_whitelist.destroy();
285
- this.cookieContext.unload();
286
- this.tokenExaminer.unload();
287
- this.tokenChecker.unload();
281
+ if (this.qs_whitelist) {
282
+ this.qs_whitelist.destroy();
283
+ }
284
+ if (this.cookieContext) {
285
+ this.cookieContext.unload();
286
+ }
287
+ if (this.tokenExaminer) {
288
+ this.tokenExaminer.unload();
289
+ }
290
+ if (this.tokenChecker) {
291
+ this.tokenChecker.unload();
292
+ }
288
293
 
289
294
  chrome.webRequest.onBeforeRequest.removeListener(this.onBeforeRequest);
290
295
  chrome.webRequest.onBeforeSendHeaders.removeListener(
@@ -294,7 +299,9 @@ export default class RequestReporter {
294
299
  chrome.webRequest.onCompleted.removeListener(this.onCompleted);
295
300
  chrome.webRequest.onErrorOccurred.removeListener(this.onErrorOccurred);
296
301
 
297
- this.db.unload();
302
+ if (this.db) {
303
+ this.db.unload();
304
+ }
298
305
  clearInterval(this.dayChangedInterval);
299
306
  this.dayChangedInterval = null;
300
307
  }
@@ -322,10 +329,9 @@ export default class RequestReporter {
322
329
  if (this.cancelRecentlyModified(state, response) === false) {
323
330
  return response.toWebRequestResponse();
324
331
  }
325
- // pageLogger.onBeforeRequest
326
- if (this.pageLogger.onBeforeRequest(state) === false) {
327
- return response.toWebRequestResponse();
328
- }
332
+
333
+ this.pageLogger.onBeforeRequest(state);
334
+
329
335
  // logIsTracker
330
336
  if (
331
337
  this.qs_whitelist.isTrackerDomain(
@@ -404,18 +410,9 @@ export default class RequestReporter {
404
410
  if (checkSameGeneralDomain(state) === false) {
405
411
  return response.toWebRequestResponse();
406
412
  }
407
- // pageLogger.onBeforeSendHeaders
408
- if (this.pageLogger.onBeforeSendHeaders(state) === false) {
409
- return response.toWebRequestResponse();
410
- }
411
- // catchMissedOpenListener
412
- if (
413
- (state.reqLog && state.reqLog.c === 0) ||
414
- this.redirectTagger.isFromRedirect(state.url)
415
- ) {
416
- // take output from 'open' pipeline and copy into our response object
417
- this.onBeforeRequest(state, response);
418
- }
413
+
414
+ this.pageLogger.onBeforeSendHeaders(state);
415
+
419
416
  // overrideUserAgent
420
417
  if (this.config.overrideUserAgent === true) {
421
418
  const domainHash = truncatedHash(state.urlParts.generalDomain);
@@ -495,14 +492,10 @@ export default class RequestReporter {
495
492
  if (checkSameGeneralDomain(state) === false) {
496
493
  return response.toWebRequestResponse();
497
494
  }
498
- // redirectTagger.checkRedirectStatus
499
- if (this.redirectTagger.checkRedirectStatus(state) === false) {
500
- return response.toWebRequestResponse();
501
- }
495
+
502
496
  // pageLogger.onHeadersReceived
503
- if (this.pageLogger.onHeadersReceived(state) === false) {
504
- return response.toWebRequestResponse();
505
- }
497
+ this.pageLogger.onHeadersReceived(state);
498
+
506
499
  // checkSetCookie
507
500
  if ((state.hasSetCookie === true) === false) {
508
501
  return response.toWebRequestResponse();
@@ -548,6 +541,7 @@ export default class RequestReporter {
548
541
  };
549
542
 
550
543
  onCompleted = (details) => {
544
+ this.whitelistedRequestCache.delete(details.requestId);
551
545
  const state = WebRequestContext.fromDetails(details, this.pageStore);
552
546
  // checkState
553
547
  if (checkValidContext(state) === false) {
@@ -558,32 +552,11 @@ export default class RequestReporter {
558
552
  if (isLocalIP(state.ip)) {
559
553
  state.page.isPrivateServer = true;
560
554
  }
561
- return false;
562
- }
563
- // pageLogger.reattachStatCounter
564
- if (this.pageLogger.reattachStatCounter(state) === false) {
565
- return false;
566
555
  }
567
- // logIsCached
568
- this.whitelistedRequestCache.delete(state.requestId);
569
- state.incrementStat(state.fromCache ? 'cached' : 'not_cached');
570
556
  };
571
557
 
572
558
  onErrorOccurred = (details) => {
573
- const state = WebRequestContext.fromDetails(details, this.pageStore);
574
- // checkState
575
- if (checkValidContext(state) === false) {
576
- return false;
577
- }
578
- // pageLogger.reattachStatCounte
579
- if (this.pageLogger.reattachStatCounter(state) === false) {
580
- return false;
581
- }
582
- // logError
583
- this.whitelistedRequestCache.delete(state.requestId);
584
- if (state.error && state.error.indexOf('ABORT')) {
585
- state.incrementStat('error_abort');
586
- }
559
+ this.whitelistedRequestCache.delete(details.requestId);
587
560
  };
588
561
 
589
562
  async dayChanged() {
@@ -11,8 +11,6 @@
11
11
 
12
12
  /* eslint no-param-reassign: 'off' */
13
13
 
14
- import { truncateDomain } from '../utils/utils.js';
15
-
16
14
  // maps string (web-ext) to int (FF cpt). Anti-tracking still uses these legacy types.
17
15
  const TYPE_LOOKUP = {
18
16
  other: 1,
@@ -38,76 +36,40 @@ const TYPE_LOOKUP = {
38
36
  };
39
37
 
40
38
  export default class PageLogger {
41
- constructor(config) {
42
- this.config = config;
43
- // maintain the request metadabase between pipeline steps
44
- this._requestCounters = new Map();
45
- }
46
-
47
- _attachCounters(state) {
48
- const domain = truncateDomain(state.urlParts.domainInfo, 2);
49
- const stats = (state.page.requestStats[domain] ||= {});
50
- state.reqLog = stats;
51
- const incrementStat = (statName, c) => {
52
- stats[statName] = (stats[statName] || 0) + (c || 1);
53
- };
54
- const setStat = (statName, value) => {
55
- stats[statName] = value;
56
- };
57
- state.incrementStat = incrementStat;
58
- state.setStat = setStat;
59
-
60
- if (state.requestId) {
61
- this._requestCounters.set(state.requestId, {
62
- incrementStat,
63
- setStat,
64
- });
65
- }
66
- }
67
-
68
- _loadStatCounters(state) {
69
- const meta = this._requestCounters.get(state.requestId);
70
- Object.keys(meta).forEach((k) => {
71
- state[k] = meta[k];
72
- });
39
+ constructor(placeHolder) {
40
+ this.placeHolder = placeHolder;
73
41
  }
74
42
 
75
43
  onBeforeRequest(state) {
76
- this._attachCounters(state);
77
- const { incrementStat, urlParts } = state;
78
-
79
- incrementStat('c');
80
- if (urlParts.search.length > 0) {
81
- incrementStat('has_qs');
44
+ state.incrementStat('c');
45
+ if (state.urlParts.search.length > 0) {
46
+ state.incrementStat('has_qs');
82
47
  }
83
- if (urlParts.hasParameterString() > 0) {
84
- incrementStat('has_ps');
48
+ if (state.urlParts.hasParameterString() > 0) {
49
+ state.incrementStat('has_ps');
85
50
  }
86
- if (urlParts.hash.length > 0) {
87
- incrementStat('has_fragment');
51
+ if (state.urlParts.hash.length > 0) {
52
+ state.incrementStat('has_fragment');
88
53
  }
89
54
  if (state.method === 'POST') {
90
- incrementStat('has_post');
55
+ state.incrementStat('has_post');
91
56
  }
92
57
 
93
- incrementStat(`type_${TYPE_LOOKUP[state.type] || 'unknown'}`);
58
+ state.incrementStat(`type_${TYPE_LOOKUP[state.type] || 'unknown'}`);
94
59
 
95
60
  // log protocol (secure or not)
96
61
  const isHTTP = (protocol) => protocol === 'http:' || protocol === 'https:';
97
- const scheme = isHTTP(urlParts.protocol) ? urlParts.scheme : 'other';
98
- incrementStat(`scheme_${scheme}`);
62
+ const scheme = isHTTP(state.urlParts.protocol)
63
+ ? state.urlParts.scheme
64
+ : 'other';
65
+ state.incrementStat(`scheme_${scheme}`);
99
66
 
100
- if (state.url.indexOf(this.config.placeHolder) > -1) {
101
- incrementStat('hasPlaceHolder');
67
+ if (state.url.indexOf(this.placeHolder) > -1) {
68
+ state.incrementStat('hasPlaceHolder');
102
69
  }
103
70
  }
104
71
 
105
72
  onBeforeSendHeaders(state) {
106
- if (state.requestId && this._requestCounters.has(state.requestId)) {
107
- this._loadStatCounters(state);
108
- } else {
109
- this._attachCounters(state);
110
- }
111
73
  // referer stats
112
74
  const referrer = state.getReferrer();
113
75
  if (referrer && referrer.indexOf(state.tabUrl) > -1) {
@@ -132,15 +94,9 @@ export default class PageLogger {
132
94
  state.incrementStat('cookie_set');
133
95
  }
134
96
  state.hasCookie = hasCookie;
135
- return true;
136
97
  }
137
98
 
138
99
  onHeadersReceived(state) {
139
- if (state.requestId && this._requestCounters.has(state.requestId)) {
140
- this._loadStatCounters(state);
141
- } else {
142
- this._attachCounters(state);
143
- }
144
100
  state.incrementStat('resp_ob');
145
101
  state.incrementStat(
146
102
  'content_length',
@@ -158,17 +114,5 @@ export default class PageLogger {
158
114
  }
159
115
  }
160
116
  state.hasSetCookie = hasSetCookie;
161
-
162
- return true;
163
- }
164
-
165
- reattachStatCounter(state) {
166
- const { requestId } = state;
167
- if (requestId && this._requestCounters.has(requestId)) {
168
- this._loadStatCounters(state);
169
- this._requestCounters.delete(requestId);
170
- return true;
171
- }
172
- return false;
173
117
  }
174
118
  }
@@ -10,6 +10,7 @@
10
10
  */
11
11
 
12
12
  import { parse } from '../../utils/url.js';
13
+ import { truncateDomain } from './utils.js';
13
14
 
14
15
  const VALID_RESPONSE_PROPERTIES = {
15
16
  onBeforeRequest: ['cancel', 'redirectUrl'],
@@ -156,6 +157,12 @@ export class WebRequestContext {
156
157
 
157
158
  this.urlParts = parse(this.url);
158
159
  this.tabUrlParts = parse(this.tabUrl);
160
+ this.truncatedDomain = truncateDomain(this.urlParts.domainInfo, 2);
161
+ }
162
+
163
+ incrementStat(statName, c) {
164
+ const stats = (this.page.requestStats[this.truncatedDomain] ||= {});
165
+ stats[statName] = (stats[statName] || 0) + (c || 1);
159
166
  }
160
167
 
161
168
  /**
@@ -13,7 +13,7 @@
13
13
  import chrome from 'sinon-chrome';
14
14
  import sinon from 'sinon';
15
15
  import { expect } from 'chai';
16
- import EventEmitter from 'node:events';
16
+ import EventEmitter, { once } from 'node:events';
17
17
  import { IDBFactory } from 'fake-indexeddb';
18
18
 
19
19
  import {
@@ -126,6 +126,54 @@ describe('RequestReporter', function () {
126
126
  delete globalThis.indexedDB;
127
127
  });
128
128
 
129
+ context('synthetic events', function () {
130
+ it('records stats from redirects', async function () {
131
+ const events = once(communicationEmiter, 'send');
132
+
133
+ const tab = { id: 1, url: 'https://www.onet.pl/' };
134
+ // creates a page
135
+ chrome.tabs.onCreated.dispatch(tab)
136
+ // changes state to 'completed'
137
+ chrome.webNavigation.onCompleted.dispatch({ tabId: tab.id, frameId: 0, });
138
+
139
+ // prepare iframe
140
+ chrome.webNavigation.onCommitted.dispatch({ tabId: tab.id, parentFrameId: 0, frameId:15032385542, url: "https://pulsembed.eu/p2em/3VgyZUiWT/"});
141
+ 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"});
142
+
143
+ // Fragment of 0002 snapshot
144
+ 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});
145
+ 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});
146
+ 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});
147
+ 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});
148
+ 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});
149
+ 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});
150
+ 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});
151
+ 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});
152
+ 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});
153
+ 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});
154
+ 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});
155
+
156
+ // stages the page for sendout
157
+ chrome.tabs.onRemoved.dispatch(tab.id);
158
+ await clock.runToLast();
159
+
160
+ const [event] = await events;
161
+ expect(event).to.include({ action: 'wtm.attrack.tp_events' });
162
+ expect(
163
+ event.payload.data[0].tps['googleads.g.doubleclick.net'],
164
+ ).to.deep.equal({
165
+ c: 2,
166
+ type_11: 2,
167
+ scheme_https: 2,
168
+ resp_ob: 2,
169
+ content_length: 121,
170
+ status_302: 1,
171
+ has_qs: 1,
172
+ status_200: 1,
173
+ });
174
+ });
175
+ });
176
+
129
177
  context('0001-empty-page', function () {
130
178
  it('detects no 3rd parties', async function () {
131
179
  const { seenTabIds } = await playScenario(chrome, {
@@ -1,51 +0,0 @@
1
- /**
2
- * WhoTracks.Me
3
- * https://whotracks.me/
4
- *
5
- * Copyright 2017-present Ghostery GmbH. All rights reserved.
6
- *
7
- * This Source Code Form is subject to the terms of the Mozilla Public
8
- * License, v. 2.0. If a copy of the MPL was not distributed with this
9
- * file, You can obtain one at http://mozilla.org/MPL/2.0
10
- */
11
-
12
- import TempSet from '../utils/temp-set.js';
13
-
14
- const CACHE_TIMEOUT = 10 * 1000;
15
-
16
- /**
17
- * Caches 302 redirects so that we can ensure that the resulting request is properly
18
- * passed through the token logic.
19
- */
20
- export default class RedirectTagger {
21
- constructor() {
22
- this.redirectCache = new TempSet();
23
- }
24
-
25
- isFromRedirect(url) {
26
- return this.redirectCache.has(url);
27
- }
28
-
29
- checkRedirectStatus(state) {
30
- if (state.statusCode === 302) {
31
- const location = state.getResponseHeader('Location');
32
- if (!location) {
33
- // 302 without "Location" in header?
34
- console.log(state, '302 without "Location" in header?');
35
- return true;
36
- }
37
- if (location.startsWith('/')) {
38
- // relative redirect
39
- const redirectUrl = `${state.urlParts.protocol}://${state.urlParts.hostname}${location}`;
40
- this.redirectCache.add(redirectUrl, CACHE_TIMEOUT);
41
- } else if (
42
- location.startsWith('http://') ||
43
- location.startsWith('https://')
44
- ) {
45
- // absolute redirect
46
- this.redirectCache.add(location, CACHE_TIMEOUT);
47
- }
48
- }
49
- return true;
50
- }
51
- }