Is Tabs.onReplaced event still fired when tab replaced due to prerendering?

86 views
Skip to first unread message

David Roland

unread,
May 23, 2025, 6:11:17 PMMay 23
to Chromium Extensions
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?

woxxom

unread,
May 24, 2025, 7:26:15 AMMay 24
to Chromium Extensions, David Roland
Judging by the usage of TabStripModelChange::kReplaced in the source code, AFACT, the only case it may happen is when a tab is discarded:

David Roland

unread,
May 26, 2025, 5:06:00 PMMay 26
to Chromium Extensions, woxxom, David Roland
Thanks woxxom. 
Reply all
Reply to author
Forward
0 new messages