Unfortunately, browsers "solved" this by intentionally adding APIs that enable websites to do this to you. It wasn't possible to abuse users this way until the relevant APIs for detecting focus and occlusion were added. :(
Both could work. The API could be permission based. E.g. without consent the app would always see itself as in focus.
But just use Chrome! Our website only works in Chrome. Everyone should just be using Chrome. What's wrong with a Chrome monoculture?
:)
It's a huge conflict of interest for an ads company to develop a browser, let alone the browser with...(checks notes)...77% market share.