Commit 4b0f889
Fire information detection events in youtube detector (#2439)
* yt events
* update test
* remove extra hostname check
* fix test
* fix: apply prettier formatting to youtube-ad-detection unit tests
Made-with: Cursor
* fix: handle promise rejection in fireEvent callback
Made-with: Cursor
* fix: use async/await instead of .catch() in fireEvent callback
Made-with: Cursor
* add hostname gating unit tests for runYoutubeAdDetection
Tests lock in expected behavior: allows youtube.com and subdomains,
privacy-test-pages.site and subdomains, rejects other domains.
Also adds resetYoutubeAdDetection() for test cleanup and stores
the start retry timeout so stop() can clear it properly.
Made-with: Cursor
* add integration tests and debug logging for YouTube detection events
- Integration test: verifies YouTube detection triggers webEvent E2E
(ad-blocker modal DOM → detector sweep → webEvent notification)
- Integration test: verifies webEvent message structure (context, featureName, no nativeData)
- Integration test: verifies no page errors during detection and event firing
- Unit test: callback invocation when async
- Debug logging: log CallFeatureMethodError in debug mode when webEvents is unavailable
- Allow localhost in hostname check for integration test compatibility
- Add youtube-detection-events config to schema validation allowlist
(fireDetectionEvents not yet in published schema)
Made-with: Cursor
* fix: update callback on existing detector singleton
If the detector singleton already exists and a new fireEvent callback
is provided, update the callback. This handles the case where the
detector is created without a callback and later called with one.
Made-with: Cursor
* Handle async rejection in onEvent callback to prevent unhandled promise rejections
The synchronous try/catch in reportDetection does not catch rejected
promises from async onEvent callbacks. Although the current fireEvent
caller has its own internal try/catch, the detector's contract should
be safe for any async callback.
- Check if onEvent returns a thenable and attach .catch() to absorb rejections
- Widen JSDoc to note the callback may be async
- Add unit test with a rejecting async callback to verify no unhandled rejection
Co-authored-by: Ben Moon <GuiltyDolphin@users.noreply.github.com>
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Ben Moon <GuiltyDolphin@users.noreply.github.com>1 parent 98abb0e commit 4b0f889
File tree
8 files changed
+455
-19
lines changed- injected
- integration-test
- test-pages/web-interference-detection
- config
- pages
- src
- detectors/detections
- features
- unit-test
8 files changed
+455
-19
lines changedLines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 66 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
Lines changed: 51 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | | - | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
| |||
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
| 62 | + | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
| |||
126 | 132 | | |
127 | 133 | | |
128 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
129 | 147 | | |
130 | 148 | | |
131 | 149 | | |
| |||
602 | 620 | | |
603 | 621 | | |
604 | 622 | | |
605 | | - | |
| 623 | + | |
606 | 624 | | |
607 | 625 | | |
608 | 626 | | |
| |||
638 | 656 | | |
639 | 657 | | |
640 | 658 | | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
641 | 663 | | |
642 | 664 | | |
643 | 665 | | |
| |||
721 | 743 | | |
722 | 744 | | |
723 | 745 | | |
| 746 | + | |
724 | 747 | | |
725 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
726 | 757 | | |
727 | 758 | | |
728 | 759 | | |
729 | 760 | | |
730 | 761 | | |
731 | | - | |
| 762 | + | |
732 | 763 | | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
733 | 767 | | |
734 | 768 | | |
735 | 769 | | |
| |||
738 | 772 | | |
739 | 773 | | |
740 | 774 | | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
747 | | - | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
748 | 779 | | |
749 | | - | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
750 | 788 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| |||
0 commit comments