@whotracksme/reporting 5.1.25 → 5.1.27

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.
Files changed (51) hide show
  1. package/.github/workflows/tests.yml +3 -1
  2. package/CHANGELOG.md +34 -0
  3. package/package.json +3 -2
  4. package/reporting/example/index.js +14 -3
  5. package/reporting/example/manifests/chromium.json +1 -2
  6. package/reporting/karma.conf.cjs +2 -0
  7. package/reporting/package.json +2 -1
  8. package/reporting/src/bloom-filters.js +4 -4
  9. package/reporting/src/fixed-size-cache.js +1 -1
  10. package/reporting/src/logger.js +0 -1
  11. package/reporting/src/md5.js +1 -1
  12. package/reporting/src/network.js +1 -1
  13. package/reporting/src/pages.js +84 -21
  14. package/reporting/src/persisted-bitarray.js +2 -2
  15. package/reporting/src/request/config.js +2 -2
  16. package/reporting/src/request/hash.js +2 -2
  17. package/reporting/src/request/index.js +31 -70
  18. package/reporting/src/request/page-telemetry.js +4 -4
  19. package/reporting/src/request/qs-whitelist2.js +3 -3
  20. package/reporting/src/request/steps/cookie-context.js +6 -6
  21. package/reporting/src/request/steps/oauth-detector.js +3 -3
  22. package/reporting/src/request/steps/page-logger.js +3 -7
  23. package/reporting/src/request/steps/redirect-tagger.js +1 -25
  24. package/reporting/src/request/steps/token-checker/index.js +3 -3
  25. package/reporting/src/request/steps/token-checker/token-domain.js +3 -3
  26. package/reporting/src/request/steps/token-examiner.js +5 -5
  27. package/reporting/src/request/steps/token-telemetry/cached-entry-pipeline.js +3 -3
  28. package/reporting/src/request/steps/token-telemetry/index.js +4 -4
  29. package/reporting/src/request/steps/token-telemetry/key-pipeline.js +1 -1
  30. package/reporting/src/request/steps/token-telemetry/token-pipeline.js +1 -1
  31. package/reporting/src/request/utils/bloom-filter-packed.js +1 -1
  32. package/reporting/src/request/utils/chrome-storage-map.js +6 -0
  33. package/reporting/src/request/utils/subject.js +1 -1
  34. package/reporting/src/request/utils/temp-set.js +1 -1
  35. package/reporting/src/request-reporter.js +3 -3
  36. package/reporting/src/sanitizer.js +11 -3
  37. package/reporting/src/utils/pacemaker.js +1 -1
  38. package/reporting/src/utils/url.js +0 -29
  39. package/reporting/src/webrequest-pipeline/page-store.js +219 -150
  40. package/reporting/src/webrequest-pipeline/webrequest-context.js +1 -33
  41. package/reporting/test/helpers/fetch-mock.js +2 -2
  42. package/reporting/test/helpers/scenarios.js +104 -0
  43. package/reporting/test/pages.spec.js +52 -4
  44. package/reporting/test/request/index.spec.js +2 -9
  45. package/reporting/test/request-reporter.test.js +255 -0
  46. package/reporting/test/sanitizer.spec.js +16 -0
  47. package/reporting/test/utils/url.spec.js +1 -26
  48. package/reporting/test/webrequest-pipeline/index.test.js +101 -3
  49. package/reporting/test/webrequest-pipeline/page-store.test.js +36 -17
  50. package/reporting/src/request/dnt.js +0 -24
  51. package/reporting/src/webrequest-pipeline/page.js +0 -117
@@ -112,8 +112,56 @@ class ChromeApiMock {
112
112
  if (initialState.openTabs) {
113
113
  uut.openTabs = new Map(initialState.openTabs);
114
114
  }
115
- for (const { api, event, args } of recordedEvents) {
115
+
116
+ // eslint-disable-next-line no-undef
117
+ const verbose = __karma__.config.VERBOSE_REPLAY;
118
+ // eslint-disable-next-line no-undef
119
+ const runSelfChecks = __karma__.config.ENABLE_SELF_CHECKS;
120
+
121
+ const history = [];
122
+ for (let step = 0; step < recordedEvents.length; step += 1) {
123
+ const { startedAt, api, event, args } = recordedEvents[step];
124
+
125
+ // (optional) build a log of the intermediate states
126
+ const stateBeforeAction = verbose
127
+ ? uut.describe(startedAt)
128
+ : '<unavailable: set VERBOSE_REPLAY to enable>';
129
+ history.push({
130
+ stateBeforeAction,
131
+ step,
132
+ ...recordedEvents[step],
133
+ });
134
+ if (history.length > 100) {
135
+ history.shift();
136
+ }
137
+ if (verbose) {
138
+ console.log(`--- Executing step: ${step} ---`);
139
+ console.log(JSON.stringify(history.at(-1), null, 2));
140
+ }
141
+
142
+ // execute the next step (modifies the state)
116
143
  this[api][event].dispatch(...args);
144
+
145
+ // (optional) run self-checks
146
+ // Warning: this is async, so it may change the observation!
147
+ if (runSelfChecks) {
148
+ const check = await uut.selfChecks();
149
+ const { status, overview, log } = check.report();
150
+
151
+ if (status === 'FAILED') {
152
+ const ppOverview = JSON.stringify(overview, null, 2);
153
+ console.error(
154
+ `*** self checks failed after step=${step}:\n`,
155
+ ppOverview,
156
+ '\n--- begin details ---:\n',
157
+ JSON.stringify(log, null, 2),
158
+ '\n--- end details ---',
159
+ );
160
+ throw new Error(
161
+ `self checks failed after step=${step} (for details, see logs)`,
162
+ );
163
+ }
164
+ }
117
165
  }
118
166
  }
119
167
  }
@@ -173,7 +221,7 @@ describe('#Pages', function () {
173
221
  let chromeApiMock;
174
222
  let urlAnalyzer;
175
223
 
176
- function runScenario(name, { notes, expectations, events }) {
224
+ async function runScenario(name, { notes, expectations, events }) {
177
225
  const { initialState, recorded } = events || {};
178
226
  try {
179
227
  expect(notes, '<notes>').to.be.a('string');
@@ -186,7 +234,7 @@ describe('#Pages', function () {
186
234
  throw e;
187
235
  }
188
236
 
189
- chromeApiMock.replay(uut, initialState, recorded);
237
+ await chromeApiMock.replay(uut, initialState, recorded);
190
238
  const state = uut.describe();
191
239
  try {
192
240
  const { expectedTabs, activeTab } = expectations;
@@ -499,7 +547,7 @@ describe('#Pages', function () {
499
547
  'Broken test setup: expected a "scenario" field',
500
548
  );
501
549
  }
502
- runScenario(name, fixture.scenario);
550
+ await runScenario(name, fixture.scenario);
503
551
  testsPassed.push(name);
504
552
  console.log(`test ${name}: PASSED`);
505
553
  } catch (e) {
@@ -11,6 +11,7 @@
11
11
 
12
12
  import * as chai from 'chai';
13
13
  import sinon from 'sinon';
14
+
14
15
  // import FakeSessionApi from '../helpers/fake-session-storage.js'; // TODO: see comments below
15
16
 
16
17
  import testPages from './test-pages.js';
@@ -82,7 +83,6 @@ describe('request/index', function () {
82
83
  afterEach(() => {
83
84
  pipeline?.unload();
84
85
  pipeline = null;
85
-
86
86
  if (monkeyPatchedChromeStorage) {
87
87
  chrome.storage.session = oldChromeStorageSession;
88
88
  chrome.storage = oldChromeStorage;
@@ -139,9 +139,7 @@ describe('request/index', function () {
139
139
  });
140
140
 
141
141
  function simulatePageLoad(pageSpec) {
142
- pipeline.pageStore.onTabCreated({
143
- ...pageSpec.tab,
144
- });
142
+ chrome.tabs.onCreated.dispatch(pageSpec.tab);
145
143
  return {
146
144
  onBeforeRequest: pageSpec.onBeforeRequest.map(function (reqData) {
147
145
  const response = pipeline.onBeforeRequest(reqData);
@@ -296,7 +294,6 @@ describe('request/index', function () {
296
294
  type: 'main_frame',
297
295
  url: 'http://cliqztest.com/',
298
296
  requestHeaders: mockRequestHeaders,
299
- frameAncestors: [],
300
297
  });
301
298
  chai.expect(mainDoc).to.not.have.property('cancel');
302
299
  chai.expect(mainDoc).to.not.have.property('redirectUrl');
@@ -313,7 +310,6 @@ describe('request/index', function () {
313
310
  requestHeaders: mockRequestHeaders,
314
311
  initiator: 'http://cliqztest.com',
315
312
  isPrivate: false,
316
- frameAncestors: [],
317
313
  });
318
314
  chai.expect(response).to.have.property('redirectUrl');
319
315
  chai.expect(response.redirectUrl).to.not.contain(uid);
@@ -331,7 +327,6 @@ describe('request/index', function () {
331
327
  requestHeaders: mockRequestHeaders,
332
328
  originUrl: '',
333
329
  tabUrl: '',
334
- frameAncestors: [],
335
330
  });
336
331
  chai.expect(mainDoc).to.not.have.property('cancel');
337
332
  chai.expect(mainDoc).to.not.have.property('redirectUrl');
@@ -349,7 +344,6 @@ describe('request/index', function () {
349
344
  originUrl: 'http://cliqztest.com',
350
345
  tabUrl: 'http://cliqztest.com',
351
346
  isPrivate: false,
352
- frameAncestors: [],
353
347
  });
354
348
  chai.expect(response).to.have.property('redirectUrl');
355
349
  chai.expect(response.redirectUrl).to.not.contain(uid);
@@ -368,7 +362,6 @@ describe('request/index', function () {
368
362
  originUrl: 'http://cliqztest.com',
369
363
  tabUrl: 'http://cliqztest.com',
370
364
  isPrivate: false,
371
- frameAncestors: [],
372
365
  });
373
366
  chai.expect(response).to.have.property('redirectUrl');
374
367
  chai.expect(response.redirectUrl).to.not.contain(uid);
@@ -0,0 +1,255 @@
1
+ /* eslint-disable prettier/prettier */
2
+ /**
3
+ * WhoTracks.Me
4
+ * https://ghostery.com/whotracksme
5
+ *
6
+ * Copyright 2017-present Ghostery GmbH. All rights reserved.
7
+ *
8
+ * This Source Code Form is subject to the terms of the Mozilla Public
9
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
10
+ * file, You can obtain one at http://mozilla.org/MPL/2.0
11
+ */
12
+
13
+ import 'fake-indexeddb/auto';
14
+ import { IDBFactory } from 'fake-indexeddb';
15
+ import chrome from 'sinon-chrome';
16
+ import sinon from 'sinon';
17
+ import { expect } from 'chai';
18
+ import EventEmitter from 'node:events';
19
+
20
+ import { playScenario } from './helpers/scenarios.js';
21
+ import { base64ToArrayBuffer } from './helpers/fetch-mock.js';
22
+
23
+ import { setLogLevel } from '../src/logger.js';
24
+ import RequestReporter from '../src/request-reporter.js';
25
+ import WebRequestPipeline from '../src/webrequest-pipeline/index.js';
26
+
27
+ const config = {
28
+ configUrl: 'config',
29
+ remoteWhitelistUrl: 'whitelist',
30
+ localWhitelistUrl: 'local',
31
+ };
32
+
33
+ describe('RequestReporter', function () {
34
+ before(function () {
35
+ setLogLevel('error');
36
+ chrome.storage.session = chrome.storage.local;
37
+ globalThis.chrome = chrome;
38
+ const oldFetch = globalThis.fetch;
39
+ sinon.stub(globalThis, 'fetch').callsFake((...args) => {
40
+ const url = args[0];
41
+ if (url.startsWith(config.configUrl)) {
42
+ return Promise.resolve({
43
+ ok: true,
44
+ async json() {
45
+ return {};
46
+ },
47
+ });
48
+ }
49
+
50
+ if (url.startsWith(config.remoteWhitelistUrl)) {
51
+ return Promise.resolve({
52
+ ok: true,
53
+ async json() {
54
+ return {
55
+ version: '2018-10-11',
56
+ useDiff: false,
57
+ };
58
+ },
59
+ async arrayBuffer() {
60
+ // empty bloom filter
61
+ return base64ToArrayBuffer('AAAAAgrdwUcnN1113w==');
62
+ }
63
+ });
64
+ }
65
+
66
+ return oldFetch(...args);
67
+ });
68
+ });
69
+
70
+ beforeEach(function () {
71
+ chrome.flush();
72
+ chrome.storage.session.get.yields({});
73
+ });
74
+
75
+ after(function () {
76
+ chrome.flush();
77
+ delete globalThis.chrome;
78
+ globalThis.fetch.restore();
79
+ setLogLevel('info');
80
+ });
81
+
82
+ context('with pre-recorded events', function () {
83
+ let reporter;
84
+ let clock;
85
+ const communicationEmiter = new EventEmitter();
86
+
87
+ beforeEach(async function () {
88
+ globalThis.indexedDB = new IDBFactory();
89
+ clock = sinon.useFakeTimers({ shouldAdvanceTime: true });
90
+ const trustedClock = {
91
+ getTimeAsYYYYMMDD() {
92
+ return '';
93
+ },
94
+ getTimeAsYYYYMMDDHH() {
95
+ return '';
96
+ },
97
+ };
98
+ communicationEmiter.removeAllListeners();
99
+ const communication = {
100
+ send(msg) {
101
+ communicationEmiter.emit('send', msg)
102
+ },
103
+ sendInstant(msg) {
104
+ communicationEmiter.emit('sendInstant', msg)
105
+ },
106
+ trustedClock,
107
+ };
108
+ const webRequestPipeline = new WebRequestPipeline();
109
+ await webRequestPipeline.init();
110
+ reporter = new RequestReporter(config, {
111
+ communication,
112
+ webRequestPipeline,
113
+ trustedClock,
114
+ getBrowserInfo: () => ({ name: 'xx' }),
115
+ countryProvider: { getSafeCountryCode: () => 'en' },
116
+ });
117
+ await reporter.init();
118
+ await reporter.requestMonitor.qs_whitelist.initPromise;
119
+ });
120
+
121
+ afterEach(function () {
122
+ reporter.unload();
123
+ reporter.webRequestPipeline.unload();
124
+ reporter = undefined;
125
+ clock.restore();
126
+ delete globalThis.indexedDB;
127
+ });
128
+
129
+ context('0001-empty-page', function () {
130
+ it('detects no 3rd parties', async function () {
131
+ const { seenTabIds } = await playScenario(chrome, {
132
+ scenarioName: this.test.parent.title,
133
+ scenarioRelease: '2024-08-02',
134
+ });
135
+ await clock.runToLast();
136
+ expect(
137
+ reporter.webRequestPipeline.pageStore.checkIfEmpty(),
138
+ ).to.be.false;
139
+ expect(seenTabIds).to.have.property('size', 1);
140
+ const tabId = seenTabIds.values().next().value;
141
+ const tab = reporter.webRequestPipeline.pageStore.getPageForRequest({ tabId, frameId: 0 });
142
+ expect(tab.requestStats).to.be.empty;
143
+ });
144
+ });
145
+
146
+ context('0002-3rd-party', function () {
147
+ it('detects 3rd parties', async function () {
148
+ const { seenTabIds } = await playScenario(chrome, {
149
+ scenarioName: this.test.parent.title,
150
+ scenarioRelease: '2024-08-02',
151
+ });
152
+ await clock.runToLast();
153
+ expect(
154
+ reporter.webRequestPipeline.pageStore.checkIfEmpty(),
155
+ ).to.be.false;
156
+ expect(seenTabIds).to.have.property('size', 1);
157
+ const tabId = seenTabIds.values().next().value;
158
+ const tab = reporter.webRequestPipeline.pageStore.getPageForRequest({ tabId, frameId: 0 });
159
+ expect(tab.requestStats).to.have.keys([
160
+ 'script.localhost',
161
+ ]);
162
+ });
163
+
164
+ it('reports 3rd parties', async function () {
165
+ const { seenTabIds } = await playScenario(chrome, {
166
+ scenarioName: this.test.parent.title,
167
+ scenarioRelease: '2024-08-02',
168
+ });
169
+ await clock.runToLast();
170
+ const eventPromise = new Promise((resolve) => communicationEmiter.once('send', resolve));
171
+ // force stage all pages
172
+ seenTabIds.forEach(tabId => chrome.tabs.onRemoved.dispatch(tabId));
173
+ await clock.runToLast();
174
+ const event = await eventPromise;
175
+ expect(event).to.deep.include({
176
+ action: 'wtm.attrack.tp_events',
177
+ });
178
+ expect(event.payload.data[0].tps).to.have.keys([
179
+ 'script.localhost',
180
+ ])
181
+ });
182
+ });
183
+
184
+ context('0004-ping', function () {
185
+ it('reports pings', async function () {
186
+ const eventPromise = new Promise((resolve) => communicationEmiter.once('send', resolve));
187
+ await playScenario(chrome, {
188
+ scenarioName: this.test.parent.title,
189
+ scenarioRelease: '2024-08-02-1',
190
+ });
191
+ await clock.runToLast();
192
+ // first tp_event from the page that sent ping
193
+ const event = await eventPromise;
194
+ expect(event).to.deep.include({
195
+ action: 'wtm.attrack.tp_events',
196
+ });
197
+ expect(event.payload.data[0].tps).to.have.keys([
198
+ 'ping.localhost',
199
+ ])
200
+ });
201
+ });
202
+
203
+ context('0005-preload', function () {
204
+ it('reports 3rd parties', async function () {
205
+ const { seenTabIds } = await playScenario(chrome, {
206
+ scenarioName: this.test.parent.title,
207
+ scenarioRelease: '2024-08-02',
208
+ });
209
+ await clock.runToLast();
210
+ const eventPromise = new Promise((resolve) => communicationEmiter.once('send', resolve));
211
+ // force stage all pages
212
+ seenTabIds.forEach(tabId => chrome.tabs.onRemoved.dispatch(tabId));
213
+ await clock.runToLast();
214
+ const event = await eventPromise;
215
+ expect(event).to.deep.include({
216
+ action: 'wtm.attrack.tp_events',
217
+ });
218
+ expect(event.payload.data[0].tps).to.have.keys([
219
+ 'preload.localhost',
220
+ ]);
221
+ });
222
+ });
223
+
224
+ context('0008-navigation', function () {
225
+ it('reports 3rd parties', async function () {
226
+ const eventPromise1 = new Promise((resolve) => communicationEmiter.once('send', resolve));
227
+ const { seenTabIds } = await playScenario(chrome, {
228
+ scenarioName: this.test.parent.title,
229
+ scenarioRelease: '2024-08-02-2',
230
+ });
231
+ await clock.runToLast();
232
+ const event1 = await eventPromise1;
233
+ expect(event1).to.deep.include({
234
+ action: 'wtm.attrack.tp_events',
235
+ });
236
+ expect(event1.payload.data[0].tps).to.have.keys([
237
+ 'script1.localhost',
238
+ ]);
239
+ const eventPromise2 = new Promise((resolve) => communicationEmiter.once('send', resolve));
240
+ // force stage all pages
241
+ seenTabIds.forEach(tabId => chrome.tabs.onRemoved.dispatch(tabId));
242
+ await clock.runToLast();
243
+ const event2 = await eventPromise2;
244
+ expect(event2).to.deep.include({
245
+ action: 'wtm.attrack.tp_events',
246
+ });
247
+ expect(event2.payload.data[0].tps).to.have.keys([
248
+ 'script2.localhost',
249
+ ]);
250
+ // reports should belong to different pages
251
+ expect(event1.payload.data[0].hostname).to.not.be.equal(event2.payload.data[0].hostname);
252
+ });
253
+ });
254
+ });
255
+ });
@@ -383,6 +383,22 @@ describe('#sanitizeUrl', function () {
383
383
  });
384
384
  });
385
385
 
386
+ describe('should drop URls where IP addresses are used as hostnames', function () {
387
+ [
388
+ 'http://182.180.189.84/',
389
+ 'http://192.168.0.119/',
390
+ 'http://85.11.187.84/saff/index.php?topic=3221141.0',
391
+ 'http://10.234.0.1/',
392
+ 'https://10.234.0.1/',
393
+ 'http://0.0.0.0/',
394
+ 'http://1.1.1.1/',
395
+ ].forEach((url) => {
396
+ it(`should drop URL: ${url}`, function () {
397
+ shouldBeDropped(url);
398
+ });
399
+ });
400
+ });
401
+
386
402
  describe('should drop URLs with non-standard HTTP ports', function () {
387
403
  ['http://myserver.test:1234/', 'https://www.myserver.test:5678/'].forEach(
388
404
  (url) => {
@@ -11,7 +11,7 @@
11
11
 
12
12
  import * as chai from 'chai';
13
13
 
14
- import { isPrivateIP, getName, parse } from '../../src/utils/url';
14
+ import { getName, parse } from '../../src/utils/url';
15
15
 
16
16
  const plainUrls = [
17
17
  {
@@ -521,31 +521,6 @@ function fillInSpec(spec) {
521
521
  }
522
522
 
523
523
  describe('utils/url', function () {
524
- describe('#isPrivateIP', function () {
525
- it('should detect private ipv4 subnets', function () {
526
- chai.expect(isPrivateIP('127.0.0.1')).to.be.true;
527
- chai.expect(isPrivateIP('192.168.2.107')).to.be.true;
528
- chai.expect(isPrivateIP('192.168.1.41')).to.be.true;
529
- chai.expect(isPrivateIP('10.0.5.250')).to.be.true;
530
- });
531
-
532
- it('should detect public ipv4 subnets', function () {
533
- chai.expect(isPrivateIP('93.184.216.34')).to.be.false;
534
- });
535
-
536
- // once we add support for ipv6, this test is expected to pass
537
- it('should detect private ipv6 subnets', function () {
538
- chai.expect(isPrivateIP('::1')).to.be.true;
539
- chai.expect(isPrivateIP('0:0:0:0:0:0:0:1')).to.be.true;
540
- chai.expect(isPrivateIP('fd12:3456:789a:1::1')).to.be.true;
541
- });
542
-
543
- it('should detect public ipv6 address', function () {
544
- chai.expect(isPrivateIP('2001:0db8:85a3:0000:0000:8a2e:0370:7334')).to.be
545
- .false;
546
- });
547
- });
548
-
549
524
  describe('#getName', () => {
550
525
  it('return "null" for invalid URL', () => {
551
526
  chai.expect(getName(parse('foo'))).to.equal(null);
@@ -12,6 +12,8 @@
12
12
  import chrome from 'sinon-chrome';
13
13
  import { expect } from 'chai';
14
14
 
15
+ import { playScenario } from '../helpers/scenarios.js';
16
+
15
17
  import WebRequestPipeline from '../../src/webrequest-pipeline/index.js';
16
18
 
17
19
  describe('WebRequestPipeline', function () {
@@ -34,7 +36,7 @@ describe('WebRequestPipeline', function () {
34
36
  it('starts empty', function () {
35
37
  const pipeline = new WebRequestPipeline();
36
38
  pipeline.init();
37
- expect(pipeline.pageStore.tabs.countNonExpiredKeys()).to.be.equal(0);
39
+ expect(pipeline.pageStore.checkIfEmpty()).to.be.true;
38
40
  });
39
41
 
40
42
  context('on webRequest.onBeforeRequest', function () {
@@ -48,15 +50,111 @@ describe('WebRequestPipeline', function () {
48
50
  });
49
51
  const details = {
50
52
  tabId: 1,
53
+ frameId: 0,
51
54
  url: 'https://example.com',
52
55
  type: 'main_frame',
53
56
  };
54
57
  chrome.webRequest.onBeforeRequest.dispatch(details);
55
- expect(pipeline.pageStore.tabs.has(details.tabId)).to.be.true;
56
- expect(pipeline.pageStore.tabs.get(details.tabId)).to.deep.include({
58
+ const tab = pipeline.pageStore.getPageForRequest(details);
59
+ expect(tab).to.deep.include({
57
60
  url: details.url,
58
61
  });
59
62
  });
60
63
  });
64
+
65
+ context('with pre-recorded events', function () {
66
+ let pipeline;
67
+
68
+ beforeEach(function () {
69
+ pipeline = new WebRequestPipeline();
70
+ pipeline.init();
71
+ [
72
+ 'onBeforeRequest',
73
+ 'onBeforeSendHeaders',
74
+ 'onHeadersReceived',
75
+ 'onAuthRequired',
76
+ 'onBeforeRedirect',
77
+ 'onCompleted',
78
+ 'onErrorOccurred',
79
+ ].forEach((step) => {
80
+ pipeline.addPipelineStep(step, {
81
+ name: 'test',
82
+ spec: 'annotate',
83
+ fn: () => {},
84
+ });
85
+ });
86
+ });
87
+
88
+ afterEach(function () {
89
+ pipeline.unload();
90
+ pipeline = undefined;
91
+ });
92
+
93
+ context('0001-quick-close', function () {
94
+ it('runs without a crash', async function () {
95
+ const { seenTabIds } = await playScenario(chrome, {
96
+ scenarioName: '0001-quick-close',
97
+ scenarioRelease: '2024-09-27',
98
+ });
99
+ expect(pipeline.pageStore.checkIfEmpty()).to.be.false;
100
+ expect(seenTabIds).to.have.property('size', 1);
101
+ const tabId = seenTabIds.values().next().value;
102
+ const tab = pipeline.pageStore.getPageForRequest({
103
+ tabId,
104
+ frameId: 0,
105
+ });
106
+ expect(tab).to.deep.include({
107
+ url: 'https://ghosterysearch.com/',
108
+ });
109
+ expect(tab.previous).to.deep.include({
110
+ url: 'about:blank',
111
+ });
112
+ });
113
+ });
114
+
115
+ context('0002-quick-navigation', function () {
116
+ it('runs without a crash', async function () {
117
+ const { seenTabIds } = await playScenario(chrome, {
118
+ scenarioName: '0002-quick-navigation',
119
+ scenarioRelease: '2024-09-27',
120
+ });
121
+ expect(pipeline.pageStore.checkIfEmpty()).to.be.false;
122
+ expect(seenTabIds).to.have.property('size', 1);
123
+ const tabId = seenTabIds.values().next().value;
124
+ const tab = pipeline.pageStore.getPageForRequest({
125
+ tabId,
126
+ frameId: 0,
127
+ });
128
+ expect(tab).to.deep.include({
129
+ url: 'https://www.facebook.com/login/?next=https%3A%2F%2Fwww.facebook.com%2F',
130
+ });
131
+ expect(tab.previous).to.deep.include({
132
+ url: 'https://ghosterysearch.com/',
133
+ });
134
+ });
135
+ });
136
+
137
+ context('0003-prefetch', function () {
138
+ it('runs without a crash', async function () {
139
+ const { seenTabIds } = await playScenario(chrome, {
140
+ scenarioName: '0003-prefetch',
141
+ scenarioRelease: '2024-09-27',
142
+ });
143
+ expect(pipeline.pageStore.checkIfEmpty()).to.be.false;
144
+ expect(seenTabIds).to.have.property('size', 1);
145
+ const tabId = seenTabIds.values().next().value;
146
+ const tab = pipeline.pageStore.getPageForRequest({
147
+ tabId,
148
+ frameId: 0,
149
+ });
150
+ expect(tab).to.deep.include({
151
+ url: 'http://localhost:8080/',
152
+ });
153
+ expect(tab.previous).to.deep.include({
154
+ url: 'about:blank',
155
+ });
156
+ });
157
+ });
158
+ });
61
159
  });
62
160
  });