Skip to content

Fix #414 - Update test events to avoid using session storage

Justin Wernick requested to merge 414-flaky-allowlisting-test into master

For our test extension, we subscribe to all of the events which any test is interested in statically. This is because in MV3, we need to add those listeners in the first turn of the event loop. If we try to do it dynamically, then the listeners get lost when the service worker restarts.

Our previous solution to keep the events themselves when the service worker restarted was to put them in session storage. Unfortunately, this appears to have not been reliable in our use case either, probably because session storage has limited capacity (10MB) and it filled up with all of the events we recently added. This could have also caused test flakiness in other areas of the code which rely on session storage.

The new approach in this MR is to rather use messages to send the events to the mocha extension page and have the page keep track of it. This is the same way we send console logs from the background to our test harness.

An unfortunate consequence of this change is that all tests which listen for events need to include a retry mechanism like wait in case the event happened but the message hasn't arrived yet. I think there is still room to improve the ergonomics around this.

Edited by Justin Wernick

Merge request reports