Here's a summary of things that were wrong about this test:
- It was setting urlclassifier.trackingTable only to be overwritten later by addTestTrackers().
- It was using an http event which fires before the classification has been done.
- It didn't disable tailing, which interferes with lowering the priority of XHRs.
- It was not testing that non-annotated or whitelisted resources would not have their priority lowered.
I added more test cases both to ensure that the correct list
(urlclassifier.trackingAnnotationTable) is used but also to ensure that
whitelisted or non-blacklisted URLs preserve the normal priority (point #4 above).
I found that XHRs do not get their priority lowered because of this flag:
https://searchfox.org/mozilla-central/rev/d47c829065767b6f36d29303d650bffb7c4f94a3/netwerk/base/nsChannelClassifier.cpp#221
which gets set here:
https://searchfox.org/mozilla-central/rev/d47c829065767b6f36d29303d650bffb7c4f94a3/dom/xhr/XMLHttpRequestMainThread.cpp#2548
and so I had to disable tailing in the test (point #3 above).
There was also a problem where the test was resetting the prefs too early
because we were not actually waiting for the classification to finish.
We would wait for the following event: http-on-opening-request
https://searchfox.org/mozilla-central/rev/d47c829065767b6f36d29303d650bffb7c4f94a3/netwerk/protocol/http/nsIHttpProtocolHandler.idl#85
whereas maybe a more appropriate one would be http-on-before-connect:
https://searchfox.org/mozilla-central/rev/d47c829065767b6f36d29303d650bffb7c4f94a3/netwerk/protocol/http/nsIHttpProtocolHandler.idl#103
since that is triggerred after annotations (point #2 above):
https://searchfox.org/mozilla-central/rev/d47c829065767b6f36d29303d650bffb7c4f94a3/netwerk/protocol/http/nsHttpChannel.cpp#6614