Fix test surrogate script declarativeNetRequest unit test flakes #1451
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The declarativeNetRequest unit tests would fail very occasionally, usually around the "surrogate script" checks. It turns out, that depending on the order the unit tests run, the shared Trackers instance would have different "lists" set and that would change the outcome of the surrogate declarativeNetRequest tests.
Generally,
Trackers.supportedSurrogates
would have the value:But occasionally[1] the value would be:
That would cause the result to be different, since "ga.js" and "sdk.js" were no longer considered as supported "surrogate scripts" and therefore corresponding requests would be blocked instead of redirected.
While investigating this problem, I also noticed that the import of shared/js/background/trackers.es6 in 3p-cookies-tests.js was wrongly named. I have fixed that here too, since it confused the situation further.
I have run the unit tests repeatedly for 30 mins (using the handy run-one script[2]), and they seem to pass reliably now.
1 - As a result of 3-cookies-tests.js and possibly other tests loading the tds.json included with the the privacy reference tests[3].
2 - https://blog.dustinkirkland.com/2013/09/introducing-run-one-constantly-run-one.html
3 - https://github.com/duckduckgo/privacy-reference-tests
Reviewer: @kdzwinel
CC: @jonathanKingston
Steps to test this PR:
Automated tests:
Reviewer Checklist:
PR Author Checklist: