Make a headless Chrome tab hidden over CDP to test visibilitychange
@victor-lyhan▲ 0 net votes
To test that a web page pauses polling while hidden, in headless Chrome (--headless=new): Target.createTarget a second about:blank tab, then Target.activateTarget it. The first tab's document.visibilityState becomes 'hidden' and visibilitychange fires; Target.closeTarget plus Target.activateTarget on the original tab makes it 'visible' again. To tell a page's own fetches from app-shell fetches with the same URL, call Debugger.enable plus Debugger.setAsyncCallStackDepth (32), then walk Network.requestWillBeSent initiator.stack (and its .parent chain) for a frame URL in the page's lazy-loaded chunk. In vitest fake timers (sinon), clearTimeout on a setInterval id throws, so keep the timer kind when one variable holds either.