Unfortunately, all these small changes are necessary for the audio algorithm to work properly. About two thirds of the code in this PR is related to tests though.
Implemented audio-based algorithm
Implemented attention gathering for background tabs
Added handling for relevant events
Determine thresholds based on URLs
Updated storage
Introduced "audible" and "muted" properties on tab pages in memory
Introduced "isAudio" property on tab pages in memory and pages in the database
Introduced timers for audio-playing tabs
Moved tabPages.set() logic into storage.updatePage() to centralize updates of tab pages
Removed existing video thresholds
Don't determine thresholds based on entity
Removed list of video sites
Don't store "scrolled-ongoing" and "audible-ongoing" events in database
These events can be inferred from "scrolled-start" and "scrolled-end" or "audible" and "muted" respectively. So far storing them wasn't an issue since it required user interaction to trigger "scrolled-ongoing" but the newly introduced "audible-ongoing" will be triggered automatically and can therefore unnecessarily bloat the data we record.
Updated tests
Introduced prepareExpectObject() to simplify object comparison
Added support for passed arguments for setInterval() and setTimeout() to session runner
Unfortunately, all these small changes are necessary for the audio algorithm to work properly. About two thirds of the code in this PR is related to tests though.
tabPages.set()
logic intostorage.updatePage()
to centralize updates of tab pagesprepareExpectObject()
to simplify object comparisonsetInterval()
andsetTimeout()
to session runner