I searched C++ files for "visibilitychange" and found that
dom/power/WakeLock.cpp implements a visibilitychange listener. Maybe
start there and ping me if it's unclear?
>> We're currently pretty bad at sending memory-pressure notifications
>> when we're actually low on memory. So you may want to expire the
>> context after the tab is in the background for some amount of time.
>
> I planned to do this as a separate, orthogonal thing, yes. Any pointer
> on how to implement this?
There's similar logic in image/src/DiscardTracker.cpp, although I kind
of wish we would generalize it into a "discard list" data structure.
-Justin