Open Bug 1543114 Opened 6 years ago Updated 3 years ago

Add tests for StorageAccessGrantedReason

Categories

(Core :: Privacy: Anti-Tracking, task, P3)

task

Tracking

()

People

(Reporter: xeonchen, Unassigned)

References

Details

Attachments

(1 file)

In bug 1539641, the storage access granted reason has been logged into ContentBlockingLog, we should add some tests for it.

Attached patch 0001-WIP.patchSplinter Review

This is my WIP patch, the reason I think this patch as incomplete is it doesn't get eOpenerAfterUserInteraction after await AntiTracking.interactWithTracker(); is called.
The reason is it received eOpener earlier, which I don't know if this is expected, and ContentBlockingLog only keeps the first reason.

Attachment #9056935 - Flags: feedback?(ehsan)
Comment on attachment 9056935 [details] [diff] [review] 0001-WIP.patch Review of attachment 9056935 [details] [diff] [review]: ----------------------------------------------------------------- ::: toolkit/components/antitracking/test/browser/browser_storageAccessWithHeuristics.js @@ +73,5 @@ > ifr.src = obj.page; > }); > }); > > + const StorageAccessGrantedReason_eOpener = 2; This is added inside testWindowOpenHeuristic() which loads TEST_3RD_PARTY_PAGE_WO. That page merely calls window.open() which is why you're seeing this heuristic being triggered. @@ +285,5 @@ > > + > + /** > + * The ContentBlockingLog only preserves the first seen reason, and the > + * expected reason, eOpenerAfterUserInteraction, comes after eOpener. Again, here the test opens a window using `ifr.contentWindow.open(obj.popup)`. Here again the log will record an eOpener heuristic first.
Attachment #9056935 - Flags: feedback?(ehsan) → feedback+

We have two heuristics, one is triggered from https://searchfox.org/mozilla-central/rev/8d78f219702286c873860f39f9ed78bad1a6d062/dom/base/Document.cpp#12030 and one is triggered from https://searchfox.org/mozilla-central/rev/8d78f219702286c873860f39f9ed78bad1a6d062/dom/base/nsGlobalWindowOuter.cpp#7250. If you only see eOpener that's because it's the second heuristic which is being triggered not the first one.

If you think about how these heuristics work, first you need to do a window.open(), and then you would interact with the tracker. I think the only way to get the eOpenerAfterUserInteraction recorded in your log would be if:

  • Your test called window.open() with a non-tracker URL on a tracker third-party iframe.
  • That URL would redirect to a tracker page.
  • Once the load is finished, you'd interact with the loaded tracker page after the redirect (for example with AntiTracking.interactWithTracker().

We don't have an existing test which does this but perhaps you can add a new test case to browser_storageAccessWithHeuristics.js like that?

Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: