The Chrome extension API documentation for tabs states that the onReplaced event is "Fired when a tab is replaced with another tab due to prerendering or instant."
In my testing, I can't get the onReplaced event to fire. I'm running Chrome version 136.0.7103.114 64 bit for Windows. In Chrome settings, I've enabled Performance > Preload Pages > Extended Preloading.
I'm testing by listening for the pageshow and pagehide events in a content script and, when those events fire, sending a message to a SW that also listens for the tabs onReplaced event. When a page is prerendered, I can see it by reviewing the documentLifecycle property of the Sender object received by the onMessage listener in the SW. But when the pre-rendered page becomes visible in the tab, no onReplaced event is fired and the tabId never changes.
I believe a few years back, the onReplaced event worked as documented. It fired when a pre-rendered tab replaced the existing tab. The callback received an addedTabId and a removedTabId.
Perhaps the pre-render system no longer replaces the tab, but simply replaces the page in the existing tab? If so, the documentation is misleading. In current Chrome, does the onReplaced event ever fire?