@whotracksme/reporting 12.1.4 → 12.1.6

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 (58) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/communication/karma.conf.cjs +1 -1
  3. package/communication/package.json +9 -10
  4. package/communication/rollup.common-config.cjs +19 -3
  5. package/communication/src/padding.js +0 -2
  6. package/communication/src/zlib.js +1 -1
  7. package/eslint.config.js +34 -0
  8. package/package.json +15 -13
  9. package/reporting/karma.conf.cjs +1 -1
  10. package/reporting/package.json +21 -22
  11. package/reporting/rollup.common-config.cjs +19 -3
  12. package/reporting/src/alive-message-generator.js +1 -1
  13. package/reporting/src/doublefetch-page-handler.js +2 -2
  14. package/reporting/src/duplicate-detector.js +1 -3
  15. package/reporting/src/hash-detector-v2/index.js +1 -1
  16. package/reporting/src/http.js +2 -3
  17. package/reporting/src/md5.js +0 -1
  18. package/reporting/src/message-sender.js +2 -3
  19. package/reporting/src/nav-tracking-detector.js +2 -2
  20. package/reporting/src/network.js +1 -1
  21. package/reporting/src/page-aggregator.js +1 -1
  22. package/reporting/src/page-quorum-check-handler.js +1 -1
  23. package/reporting/src/page-structure.js +1 -1
  24. package/reporting/src/pagedb.js +1 -1
  25. package/reporting/src/pages.js +2 -2
  26. package/reporting/src/patterns-updater.js +1 -1
  27. package/reporting/src/patterns.js +11 -11
  28. package/reporting/src/popularity-estimator.js +1 -1
  29. package/reporting/src/random.js +0 -2
  30. package/reporting/src/request/index.js +0 -1
  31. package/reporting/src/request/qs-whitelist2.js +4 -5
  32. package/reporting/src/request/utils/bloom-filter-packed.js +2 -2
  33. package/reporting/src/request/utils/chrome-storage-map.js +7 -4
  34. package/reporting/src/request/utils/time.js +5 -22
  35. package/reporting/src/sanitizer.js +1 -1
  36. package/reporting/src/search-extractor.js +2 -5
  37. package/reporting/src/url-cleaner.js +9 -6
  38. package/reporting/src/utils/url.js +2 -2
  39. package/reporting/test/activity-estimator.spec.js +9 -6
  40. package/reporting/test/duplicate-detector.spec.js +0 -1
  41. package/reporting/test/helpers/fast-check-utils.js +11 -0
  42. package/reporting/test/job-scheduler.spec.js +7 -1
  43. package/reporting/test/pagedb.spec.js +3 -1
  44. package/reporting/test/pages.spec.js +1 -1
  45. package/reporting/test/patterns-updater.spec.js +1 -1
  46. package/reporting/test/patterns.spec.js +28 -26
  47. package/reporting/test/persisted-counters.spec.js +2 -3
  48. package/reporting/test/popularity-estimator.spec.js +6 -0
  49. package/reporting/test/request/index.test.js +0 -1
  50. package/reporting/test/sanitizer.spec.js +4 -2
  51. package/reporting/test/search-extractor.spec.js +1 -1
  52. package/reporting/test/seq-executor.spec.js +2 -2
  53. package/reporting/test/url-analyzer.spec.js +3 -1
  54. package/reporting/test/url-cleaner.spec.js +21 -0
  55. package/reporting/test/utils/url.spec.js +0 -1
  56. package/reporting/test/utils.spec.js +1 -1
  57. package/.eslintignore +0 -4
  58. package/.eslintrc +0 -16
@@ -41,16 +41,15 @@ export default class QSWhitelist2 {
41
41
 
42
42
  async init() {
43
43
  try {
44
- const { version, localSafeKey } = await this.storage.get(
45
- STORAGE_CONFIG_KEY,
46
- );
44
+ const { version, localSafeKey } =
45
+ await this.storage.get(STORAGE_CONFIG_KEY);
47
46
 
48
47
  const buffer = await this.storage.get(STORAGE_BLOOM_FILTER_KEY);
49
48
  this.bloomFilter = new PackedBloomFilter(buffer);
50
49
  this.version = version;
51
50
  this.localSafeKey = localSafeKey || {};
52
51
  logger.debug(`[QSWhitelist2] Bloom filter loaded version ${version}`);
53
- } catch (e) {
52
+ } catch {
54
53
  logger.info('[QSWhitelist2] Failed loading filter from local');
55
54
  }
56
55
 
@@ -67,7 +66,7 @@ export default class QSWhitelist2 {
67
66
  this.networkFetchEnabled = false;
68
67
  try {
69
68
  await this._fullUpdate((await this._fetchUpdateURL()).version);
70
- } catch (e2) {
69
+ } catch {
71
70
  logger.info('[QSWhitelist2] failed to load bloom filter');
72
71
  // local fetch also failed
73
72
  // create empty bloom filter
@@ -59,7 +59,7 @@ export default class PackedBloomFilter {
59
59
  const l = this.locations(a, b);
60
60
  for (let i = 0; i < this.k; i += 1) {
61
61
  const bk = l[i];
62
- if ((this.getBucket(Math.floor(bk / 32)) & (1 << bk % 32)) === 0) {
62
+ if ((this.getBucket(Math.floor(bk / 32)) & (1 << (bk % 32))) === 0) {
63
63
  return false;
64
64
  }
65
65
  }
@@ -78,7 +78,7 @@ export default class PackedBloomFilter {
78
78
  for (let i = 0; i < this.k; i += 1) {
79
79
  const bk = Math.floor(l[i] / 32);
80
80
  const offset = 5 + bk * 4;
81
- const newValue = this.data.getUint32(offset, false) | (1 << l[i] % 32);
81
+ const newValue = this.data.getUint32(offset, false) | (1 << (l[i] % 32));
82
82
  this.data.setUint32(offset, newValue, false);
83
83
  }
84
84
  }
@@ -250,10 +250,13 @@ export default class ChromeStorageMap {
250
250
  this._flush();
251
251
  this._scheduledFlush = null;
252
252
  } else {
253
- this._scheduledFlush = setTimeout(() => {
254
- this._flush();
255
- this._scheduledFlush = null;
256
- }, Math.min(this.softFlushIntervalInMs, nextForcedFlush - now));
253
+ this._scheduledFlush = setTimeout(
254
+ () => {
255
+ this._flush();
256
+ this._scheduledFlush = null;
257
+ },
258
+ Math.min(this.softFlushIntervalInMs, nextForcedFlush - now),
259
+ );
257
260
  }
258
261
  }
259
262
 
@@ -9,32 +9,15 @@
9
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0
10
10
  */
11
11
 
12
- /* eslint prefer-template: 'off' */
13
-
14
- // this is the sanitised timestamp retrieved from humanweb.
15
- let hwTs = null;
16
-
17
12
  /** Get datetime string of the current hour in the format YYYYMMDDHH
18
13
  */
19
14
  export function getTime() {
20
15
  const date = new Date();
21
- const ts = hwTs;
22
- let _ts;
23
- let h = null;
24
- if (!ts) {
25
- let d = null;
26
- let m = null;
27
- let y = null;
28
- d = (date.getDate() < 10 ? '0' : '') + date.getDate();
29
- m = (date.getMonth() < 9 ? '0' : '') + parseInt(date.getMonth() + 1, 10);
30
- h = (date.getUTCHours() < 10 ? '0' : '') + date.getUTCHours();
31
- y = date.getFullYear();
32
- _ts = y + '' + m + '' + d + '' + h;
33
- } else {
34
- h = (date.getUTCHours() < 10 ? '0' : '') + date.getUTCHours();
35
- _ts = ts + '' + h;
36
- }
37
- return _ts;
16
+ const d = (date.getDate() < 10 ? '0' : '') + date.getDate();
17
+ const m = (date.getMonth() < 9 ? '0' : '') + (date.getMonth() + 1);
18
+ const y = date.getFullYear();
19
+ const h = (date.getUTCHours() < 10 ? '0' : '') + date.getUTCHours();
20
+ return `${y}${m}${d}${h}`;
38
21
  }
39
22
 
40
23
  export function newUTCDate() {
@@ -215,7 +215,7 @@ export function checkSuspiciousQuery(query) {
215
215
  function tryParseUrl(url) {
216
216
  try {
217
217
  return new URL(url);
218
- } catch (e) {
218
+ } catch {
219
219
  return null;
220
220
  }
221
221
  }
@@ -9,8 +9,6 @@
9
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0
10
10
  */
11
11
 
12
- /* eslint-disable no-continue */
13
-
14
12
  import logger from './logger';
15
13
  import parseHtml from './html-parser';
16
14
  import { fastHash } from './utils';
@@ -259,7 +257,6 @@ export default class SearchExtractor {
259
257
  // "requiredKeys" property. If not specified, all keys of the array entry need
260
258
  // to be present; otherwise, the entry will be skipped.
261
259
  const messages = [];
262
- // eslint-disable-line no-labels, no-restricted-syntax
263
260
  nextaction: for (const [action, schema] of Object.entries(output)) {
264
261
  const payload = {};
265
262
  for (const {
@@ -277,7 +274,7 @@ export default class SearchExtractor {
277
274
  if (input[source].first) {
278
275
  // case 1: single extracted value
279
276
  if (!optional && !isPresent(found[source][key])) {
280
- continue nextaction; // eslint-disable-line no-labels
277
+ continue nextaction;
281
278
  }
282
279
  payload[key] = found[source][key] ?? null;
283
280
  } else if (input[source].all) {
@@ -298,7 +295,7 @@ export default class SearchExtractor {
298
295
  required.every((x) => isPresent(entry[x]));
299
296
  const cleanedResults = results.filter(allFieldsPresent);
300
297
  if (cleanedResults.length === 0 && !optional) {
301
- continue nextaction; // eslint-disable-line no-labels
298
+ continue nextaction;
302
299
  }
303
300
  payload[key] = { ...cleanedResults };
304
301
  } else {
@@ -25,11 +25,14 @@ export function removeQueryParams(url, queryParams) {
25
25
  if (searchStart === -1) {
26
26
  return url;
27
27
  }
28
- const searchEnd = url.indexOf('#', searchStart + 1);
29
- const search =
30
- searchEnd === -1
31
- ? url.slice(searchStart + 1)
32
- : url.slice(searchStart + 1, searchEnd);
28
+
29
+ const hashStart = url.indexOf('#');
30
+ const searchEnd = hashStart === -1 ? url.length : hashStart;
31
+ if (searchStart > searchEnd) {
32
+ return url;
33
+ }
34
+
35
+ const search = url.slice(searchStart + 1, searchEnd);
33
36
  if (!search) {
34
37
  return url;
35
38
  }
@@ -38,7 +41,7 @@ export function removeQueryParams(url, queryParams) {
38
41
  .filter((x) => !queryParams.includes(split0(x, '=')));
39
42
  const beforeSearch = url.slice(0, searchStart);
40
43
 
41
- const hash = searchEnd === -1 ? '' : url.slice(searchEnd);
44
+ const hash = url.slice(searchEnd);
42
45
  if (parts.length === 0) {
43
46
  return beforeSearch + hash;
44
47
  } else {
@@ -28,7 +28,7 @@ export function parse(url) {
28
28
  try {
29
29
  const parsed = new ImmutableURL(url);
30
30
  return parsed;
31
- } catch (e) {
31
+ } catch {
32
32
  return null;
33
33
  }
34
34
  }
@@ -51,7 +51,7 @@ function tryDecode(fn) {
51
51
 
52
52
  try {
53
53
  return fn(url);
54
- } catch (e) {
54
+ } catch {
55
55
  return url;
56
56
  }
57
57
  };
@@ -255,12 +255,15 @@ describe('#ActivityEstimator', function () {
255
255
  ],
256
256
  } = {}) {
257
257
  return fc.array(
258
- fc.record({
259
- url: fc.option(...urls.map((url) => fc.constant(url))),
260
- isDynamicLoad: fc.boolean(),
261
- delay: fc.nat(1 * WEEK),
262
- jump: fc.nat(1 * WEEK),
263
- }),
258
+ fc.record(
259
+ {
260
+ url: fc.option(...urls.map((url) => fc.constant(url))),
261
+ isDynamicLoad: fc.boolean(),
262
+ delay: fc.nat(1 * WEEK),
263
+ jump: fc.nat(1 * WEEK),
264
+ },
265
+ { noNullPrototype: true },
266
+ ),
264
267
  );
265
268
  }
266
269
 
@@ -22,7 +22,6 @@ function getUniqueId() {
22
22
  return getUniqueId.uniqueId;
23
23
  }
24
24
 
25
- /* eslint-disable no-param-reassign */
26
25
  function mkMessage({ action = 'test-action', payload, deduplicateBy } = {}) {
27
26
  payload = payload || {
28
27
  testFieldWithSeq: `test-field-${getUniqueId()}`,
@@ -22,6 +22,17 @@ export const arbitraryUrlWithDomain = fc
22
22
  .webUrl()
23
23
  .filter((url) => tldts.getDomain(url) !== null);
24
24
 
25
+ /**
26
+ * Simulates the removed fc.fullUnicodeString() with binary string.
27
+ */
28
+ export const fullUnicodeString = () => fc.string({ unit: 'binary' });
29
+
30
+ /**
31
+ * Simulates the removed fc.hexaString() with hex characters.
32
+ */
33
+ export const hexaString = () =>
34
+ fc.string({ unit: fc.constantFrom(...'0123456789abcdef') });
35
+
25
36
  /**
26
37
  * fast-check will find edge cases for keys like "__proto__".
27
38
  * Yet in most use cases, the keys will be simple enough to work
@@ -1002,6 +1002,7 @@ describe('#JobScheduler', function () {
1002
1002
  },
1003
1003
  {
1004
1004
  requiredKeys: ['min'],
1005
+ noNullPrototype: true,
1005
1006
  },
1006
1007
  ),
1007
1008
  expireIn: fc.record(
@@ -1011,6 +1012,7 @@ describe('#JobScheduler', function () {
1011
1012
  },
1012
1013
  {
1013
1014
  requiredKeys: ['min'],
1015
+ noNullPrototype: true,
1014
1016
  },
1015
1017
  ),
1016
1018
  });
@@ -1019,7 +1021,10 @@ describe('#JobScheduler', function () {
1019
1021
  const arbitraryJobType = () => fc.nat(maxJobTypes - 1).map(numToJobType);
1020
1022
  const arbitraryJobArgs = () => fc.array(fc.nat());
1021
1023
  const arbitraryJobConfig = () =>
1022
- fc.record(commonJobConfigFields(), { requiredKeys: [] });
1024
+ fc.record(commonJobConfigFields(), {
1025
+ requiredKeys: [],
1026
+ noNullPrototype: true,
1027
+ });
1023
1028
  const arbitraryJob = () => {
1024
1029
  return fc
1025
1030
  .tuple(
@@ -1033,6 +1038,7 @@ describe('#JobScheduler', function () {
1033
1038
  },
1034
1039
  {
1035
1040
  requiredKeys: [],
1041
+ noNullPrototype: true,
1036
1042
  },
1037
1043
  ),
1038
1044
  ),
@@ -13,6 +13,8 @@ import { expect } from 'chai';
13
13
  import sinon from 'sinon';
14
14
  import * as fc from 'fast-check';
15
15
 
16
+ import { fullUnicodeString } from './helpers/fast-check-utils.js';
17
+
16
18
  import PageDB, { toPersistedKey, parsePersistedKey } from '../src/pagedb.js';
17
19
  import InMemoryDatabase from './helpers/in-memory-database.js';
18
20
  import { InMemoryNewPageApprover } from './helpers/pagedb-mocks.js';
@@ -26,7 +28,7 @@ const YEAR = 365 * DAY;
26
28
  describe('#toPersistedKey and #parsePersistedKey', function () {
27
29
  it('should be invertable', function () {
28
30
  fc.assert(
29
- fc.property(fc.fullUnicodeString(), fc.integer(), (url, createdAt) => {
31
+ fc.property(fullUnicodeString(), fc.integer(), (url, createdAt) => {
30
32
  const result = parsePersistedKey(toPersistedKey(url, createdAt));
31
33
  expect(result.url).to.eql(url);
32
34
  expect(result.createdAt).to.eql(createdAt);
@@ -424,7 +424,7 @@ describe('#Pages', function () {
424
424
  try {
425
425
  expect(actual).to.eql(expectedPageEvent);
426
426
  return true;
427
- } catch (e) {
427
+ } catch {
428
428
  return false;
429
429
  }
430
430
  };
@@ -360,7 +360,7 @@ describe('#PatternsUpdater', function () {
360
360
  let detected = false;
361
361
  try {
362
362
  await uut.update({ now: ts, ignoreErrors: false });
363
- } catch (e) {
363
+ } catch {
364
364
  detected = true;
365
365
  }
366
366
  expect(detected).to.equal(true);
@@ -12,6 +12,8 @@
12
12
  import { expect } from 'chai';
13
13
  import fc from 'fast-check';
14
14
 
15
+ import { fullUnicodeString, hexaString } from './helpers/fast-check-utils.js';
16
+
15
17
  import Patterns, { lookupBuiltinTransform } from '../src/patterns.js';
16
18
  import { isSubSequence } from '../src/utils.js';
17
19
 
@@ -54,7 +56,7 @@ describe('Test builtin primitives', function () {
54
56
 
55
57
  it('should not fail on well-formed but arbitrary text', function () {
56
58
  fc.assert(
57
- fc.property(fc.fullUnicodeString(), (untrustedText) => {
59
+ fc.property(fullUnicodeString(), (untrustedText) => {
58
60
  // should not throw
59
61
  queryParam(untrustedText, 'someTrustedParam');
60
62
  }),
@@ -201,8 +203,8 @@ describe('Test builtin primitives', function () {
201
203
  fc.assert(
202
204
  fc.property(
203
205
  fc.webUrl({ withQueryParameters: true, withFragments: true }),
204
- fc.array(fc.tuple(fc.hexaString(), fc.hexaString())),
205
- fc.array(fc.hexaString()),
206
+ fc.array(fc.tuple(hexaString(), hexaString())),
207
+ fc.array(hexaString()),
206
208
  (url, paramsToAdd, paramsToRemove) => {
207
209
  const tmp1 = new URL(url);
208
210
  tmp1.search = new URLSearchParams(paramsToAdd);
@@ -288,7 +290,7 @@ describe('Test builtin primitives', function () {
288
290
 
289
291
  it('should not fail on well-formed but arbitrary text', function () {
290
292
  fc.assert(
291
- fc.property(fc.fullUnicodeString(), (untrustedText) => {
293
+ fc.property(fullUnicodeString(), (untrustedText) => {
292
294
  const result = removeParams(untrustedText, ['someTrustedParam']);
293
295
  if (result !== null) {
294
296
  expect(result).to.be.a('string');
@@ -344,7 +346,7 @@ describe('Test builtin primitives', function () {
344
346
 
345
347
  it('should not fail on well-formed but arbitrary text', function () {
346
348
  fc.assert(
347
- fc.property(fc.fullUnicodeString(), (untrustedText) => {
349
+ fc.property(fullUnicodeString(), (untrustedText) => {
348
350
  const result = requireURL(untrustedText);
349
351
  if (result !== null) {
350
352
  expect(result).to.eql(untrustedText);
@@ -401,7 +403,7 @@ describe('Test builtin primitives', function () {
401
403
 
402
404
  it('should drop all non-matching untrustedTexts', function () {
403
405
  fc.assert(
404
- fc.property(fc.fullUnicodeString(), (untrustedText) => {
406
+ fc.property(fullUnicodeString(), (untrustedText) => {
405
407
  expect(filterExact(untrustedText, [])).to.eql(null);
406
408
  expect(
407
409
  filterExact(untrustedText, [untrustedText + 'force_mismatch']),
@@ -429,7 +431,7 @@ describe('Test builtin primitives', function () {
429
431
  it('should not fail on well-formed but arbitrary text', function () {
430
432
  fc.assert(
431
433
  fc.property(
432
- fc.fullUnicodeString(),
434
+ fullUnicodeString(),
433
435
  fc.array(fc.string()),
434
436
  (untrustedText, allowedValues) => {
435
437
  expect(filterExact(untrustedText, allowedValues)).to.be.oneOf([
@@ -470,7 +472,7 @@ describe('Test builtin primitives', function () {
470
472
 
471
473
  it('should not fail on well-formed but arbitrary text', function () {
472
474
  fc.assert(
473
- fc.property(fc.fullUnicodeString(), (untrustedText) => {
475
+ fc.property(fullUnicodeString(), (untrustedText) => {
474
476
  // should not throw
475
477
  maskU(untrustedText);
476
478
  }),
@@ -535,7 +537,7 @@ describe('Test builtin primitives', function () {
535
537
  it('should not fail on well-formed but arbitrary text', function () {
536
538
  fc.assert(
537
539
  fc.property(
538
- fc.fullUnicodeString(),
540
+ fullUnicodeString(),
539
541
  fc.string(),
540
542
  (untrustedText, splitOn) => {
541
543
  fc.pre(splitOn.length > 0);
@@ -600,7 +602,7 @@ describe('Test builtin primitives', function () {
600
602
  it('should not fail on well-formed but arbitrary text', function () {
601
603
  fc.assert(
602
604
  fc.property(
603
- fc.fullUnicodeString(),
605
+ fullUnicodeString(),
604
606
  fc.string(),
605
607
  (untrustedText, trySplitOn) => {
606
608
  fc.pre(trySplitOn.length > 0);
@@ -648,7 +650,7 @@ describe('Test builtin primitives', function () {
648
650
 
649
651
  it('should behave like decodeURIComponent for any properly encodeded string', function () {
650
652
  fc.assert(
651
- fc.property(fc.fullUnicodeString(), (text) => {
653
+ fc.property(fullUnicodeString(), (text) => {
652
654
  const input = encodeURIComponent(text);
653
655
  expect(uut(input)).to.eql(text);
654
656
  }),
@@ -672,7 +674,7 @@ describe('Test builtin primitives', function () {
672
674
 
673
675
  it('should not fail on well-formed but arbitrary text', function () {
674
676
  fc.assert(
675
- fc.property(fc.fullUnicodeString(), (untrustedText) => {
677
+ fc.property(fullUnicodeString(), (untrustedText) => {
676
678
  const result = uut(untrustedText);
677
679
  if (result !== null) {
678
680
  expect(result).to.be.a('string');
@@ -713,7 +715,7 @@ describe('Test builtin primitives', function () {
713
715
 
714
716
  it('should behave like decodeURIComponent for any properly encodeded string', function () {
715
717
  fc.assert(
716
- fc.property(fc.fullUnicodeString(), (text) => {
718
+ fc.property(fullUnicodeString(), (text) => {
717
719
  const input = encodeURIComponent(text);
718
720
  expect(uut(input)).to.eql(text);
719
721
  }),
@@ -737,7 +739,7 @@ describe('Test builtin primitives', function () {
737
739
 
738
740
  it('should not fail on well-formed but arbitrary text', function () {
739
741
  fc.assert(
740
- fc.property(fc.fullUnicodeString(), (untrustedText) => {
742
+ fc.property(fullUnicodeString(), (untrustedText) => {
741
743
  expect(uut(untrustedText)).to.be.a('string');
742
744
  }),
743
745
  );
@@ -860,7 +862,7 @@ describe('Test builtin primitives', function () {
860
862
  it('should not fail on well-formed but arbitrary text', function () {
861
863
  fc.assert(
862
864
  fc.property(
863
- fc.fullUnicodeString(),
865
+ fullUnicodeString(),
864
866
  fc.string(),
865
867
  fc.boolean(),
866
868
  (untrustedText, path, extractObjects) => {
@@ -908,7 +910,7 @@ describe('Test builtin primitives', function () {
908
910
 
909
911
  it('should work on arbitrary strings and behave like String.trim', function () {
910
912
  fc.assert(
911
- fc.property(fc.fullUnicodeString(), (untrustedText) => {
913
+ fc.property(fullUnicodeString(), (untrustedText) => {
912
914
  const result = trim(untrustedText);
913
915
  expect(result).to.be.a('string').and.to.eql(untrustedText.trim());
914
916
  }),
@@ -943,7 +945,7 @@ describe('Test builtin primitives', function () {
943
945
 
944
946
  it('should not fail on arbitrary text and patterns', function () {
945
947
  fc.assert(
946
- fc.property(fc.fullUnicodeString(), fc.string(), (text, pattern) => {
948
+ fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
947
949
  expect(uut(text, pattern)).to.be.a('string');
948
950
  }),
949
951
  );
@@ -951,7 +953,7 @@ describe('Test builtin primitives', function () {
951
953
 
952
954
  it('should only remove characters from the text (the result never grows)', function () {
953
955
  fc.assert(
954
- fc.property(fc.fullUnicodeString(), fc.string(), (text, pattern) => {
956
+ fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
955
957
  const subsequence = uut(text, pattern);
956
958
  expect(isSubSequence({ sequence: text, subsequence })).to.be.true;
957
959
  }),
@@ -986,7 +988,7 @@ describe('Test builtin primitives', function () {
986
988
 
987
989
  it('should not fail on arbitrary text and patterns', function () {
988
990
  fc.assert(
989
- fc.property(fc.fullUnicodeString(), fc.string(), (text, pattern) => {
991
+ fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
990
992
  expect(uut(text, pattern)).to.be.a('string');
991
993
  }),
992
994
  );
@@ -994,7 +996,7 @@ describe('Test builtin primitives', function () {
994
996
 
995
997
  it('should only remove characters from the text (the result never grows)', function () {
996
998
  fc.assert(
997
- fc.property(fc.fullUnicodeString(), fc.string(), (text, pattern) => {
999
+ fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
998
1000
  const subsequence = uut(text, pattern);
999
1001
  expect(isSubSequence({ sequence: text, subsequence })).to.be.true;
1000
1002
  }),
@@ -1029,7 +1031,7 @@ describe('Test builtin primitives', function () {
1029
1031
 
1030
1032
  it('should not fail on arbitrary text and patterns', function () {
1031
1033
  fc.assert(
1032
- fc.property(fc.fullUnicodeString(), fc.string(), (text, pattern) => {
1034
+ fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
1033
1035
  expect(uut(text, pattern)).to.be.a('string');
1034
1036
  }),
1035
1037
  );
@@ -1037,7 +1039,7 @@ describe('Test builtin primitives', function () {
1037
1039
 
1038
1040
  it('should only remove characters from the text (the result never grows)', function () {
1039
1041
  fc.assert(
1040
- fc.property(fc.fullUnicodeString(), fc.string(), (text, pattern) => {
1042
+ fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
1041
1043
  const subsequence = uut(text, pattern);
1042
1044
  expect(isSubSequence({ sequence: text, subsequence })).to.be.true;
1043
1045
  }),
@@ -1068,11 +1070,11 @@ describe('Test builtin primitives', function () {
1068
1070
 
1069
1071
  it('should behave like a naive match(...).join("") implementation', function () {
1070
1072
  fc.assert(
1071
- fc.property(fc.fullUnicodeString(), fc.string(), (text, pattern) => {
1073
+ fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
1072
1074
  let expected = '';
1073
1075
  try {
1074
1076
  expected = (text.match(new RegExp(pattern, 'g')) || []).join('');
1075
- } catch (e) {
1077
+ } catch {
1076
1078
  // invalid regular expression: expect the value to be cleared
1077
1079
  }
1078
1080
  expect(uut(text, pattern)).to.eql(expected);
@@ -1090,7 +1092,7 @@ describe('Test builtin primitives', function () {
1090
1092
 
1091
1093
  it('should not fail on arbitrary text and patterns', function () {
1092
1094
  fc.assert(
1093
- fc.property(fc.fullUnicodeString(), fc.string(), (text, pattern) => {
1095
+ fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
1094
1096
  expect(uut(text, pattern)).to.be.a('string');
1095
1097
  }),
1096
1098
  );
@@ -1098,7 +1100,7 @@ describe('Test builtin primitives', function () {
1098
1100
 
1099
1101
  it('should only remove characters from the text (the result never grows)', function () {
1100
1102
  fc.assert(
1101
- fc.property(fc.fullUnicodeString(), fc.string(), (text, pattern) => {
1103
+ fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
1102
1104
  const subsequence = uut(text, pattern);
1103
1105
  expect(isSubSequence({ sequence: text, subsequence })).to.be.true;
1104
1106
  }),
@@ -81,9 +81,8 @@ describe('#PersistedCounters', function () {
81
81
  fc.nat(100),
82
82
  async (keys, numSamples) => {
83
83
  keys.forEach((key) => uut.count(key));
84
- const { samples, populationSize } = await uut.sample(
85
- numSamples,
86
- );
84
+ const { samples, populationSize } =
85
+ await uut.sample(numSamples);
87
86
  expect(populationSize).to.eql(keys.length);
88
87
 
89
88
  if (keys.length === 0) {
@@ -91,6 +91,12 @@ describe('#PopularityEstimator', function () {
91
91
  const _jobsRegistered = jobsRegistered;
92
92
 
93
93
  jobScheduler = createInMemoryJobScheduler();
94
+
95
+ // Guarantees that we see "jobRegistered" events.
96
+ // (We are not clearing the queues by processing the jobs; so once the
97
+ // global job limit is reached, new jobs would be rejected.)
98
+ jobScheduler.globalJobLimit = Infinity;
99
+
94
100
  jobScheduler.addObserver('jobRegistered', (job) => {
95
101
  // Nasty pitfall: it would be nice to run assertions here, but they
96
102
  // will not be visible in the console when the user runs them.
@@ -388,7 +388,6 @@ describe('RequestReporter', function () {
388
388
 
389
389
  async function processRunloopUntil(timeout) {
390
390
  const start = Date.now();
391
- // eslint-disable-next-line no-constant-condition
392
391
  while (true) {
393
392
  const now = await clock.runToLast();
394
393
  if (now - start > timeout) {
@@ -12,6 +12,8 @@
12
12
  import { expect } from 'chai';
13
13
  import fc from 'fast-check';
14
14
 
15
+ import { fullUnicodeString } from './helpers/fast-check-utils.js';
16
+
15
17
  import {
16
18
  sanitizeUrl,
17
19
  checkSuspiciousQuery,
@@ -1031,7 +1033,7 @@ describe('#isValidEAN13', function () {
1031
1033
 
1032
1034
  it('with unicode input', function () {
1033
1035
  fc.assert(
1034
- fc.property(fc.fullUnicodeString(), (text) => {
1036
+ fc.property(fullUnicodeString(), (text) => {
1035
1037
  expect(isValidEAN13(text)).to.be.oneOf([true, false]);
1036
1038
  }),
1037
1039
  );
@@ -1094,7 +1096,7 @@ describe('#isValidISSN', function () {
1094
1096
 
1095
1097
  it('with unicode input', function () {
1096
1098
  fc.assert(
1097
- fc.property(fc.fullUnicodeString(), (text) => {
1099
+ fc.property(fullUnicodeString(), (text) => {
1098
1100
  expect(isValidISSN(text)).to.be.oneOf([true, false]);
1099
1101
  }),
1100
1102
  );
@@ -121,7 +121,7 @@ describe('#SearchExtractor', function () {
121
121
  } finally {
122
122
  try {
123
123
  mockWindow?.close();
124
- } catch (e) {
124
+ } catch {
125
125
  // ignore
126
126
  }
127
127
  }
@@ -52,7 +52,7 @@ describe('#SeqExecutor', function () {
52
52
  await uut.run(() => {
53
53
  throw new Error(2);
54
54
  });
55
- } catch (e) {
55
+ } catch {
56
56
  gotError2 = true;
57
57
  }
58
58
  if (!gotError2) {
@@ -66,7 +66,7 @@ describe('#SeqExecutor', function () {
66
66
  await uut.run(async () => {
67
67
  throw new Error(4);
68
68
  });
69
- } catch (e) {
69
+ } catch {
70
70
  gotError4 = true;
71
71
  }
72
72
  if (!gotError4) {
@@ -12,6 +12,8 @@
12
12
  import { expect } from 'chai';
13
13
  import fc from 'fast-check';
14
14
 
15
+ import { fullUnicodeString } from './helpers/fast-check-utils.js';
16
+
15
17
  import UrlAnalyzer from '../src/url-analyzer.js';
16
18
 
17
19
  describe('#UrlAnalyzer', function () {
@@ -475,7 +477,7 @@ describe('#UrlAnalyzer', function () {
475
477
 
476
478
  it('should support special characters (unicode)', function () {
477
479
  fc.assert(
478
- fc.property(fc.fullUnicodeString(), (text) => {
480
+ fc.property(fullUnicodeString(), (text) => {
479
481
  fc.pre(text.length > 0 && text === text.trim());
480
482
  const encodedText = encodeURIComponent(text);
481
483
  const url = `https://www.google.com/search?q=${encodedText}`;