I'm using the next code in my eventPage.js (backgroundPage replacement by google) and I'm facing some weird inconsistency.
This is the scenario:
First Machine:
Opening new tab ->
onActivated
onUpdated
onUpdated
onUpdated
Entering URL ->
onUpdated
onUpdated
entering another URL ->
onUpdated
onUpdated
Second Machine:
Opening new tab ->
onActivated
Entering URL
onReplaced
onActivated
entering another URL
onReplaced
onActivated
This is my code:
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
{
console.log("onUpdated");
});
chrome.tabs.onActivated.addListener(function(tabId, changeInfo, tab)
{
console.log("onActivated");
});
chrome.tabs.onReplaced.addListener(function(tabId, changeInfo, tab)
{
console.log("onReplaced");
});
After a lot of debugging I've found that the cause of this difference is the option "Predict network actions to improve page load performance" in Google Chrome Settings.
In the first machine the option above is not selected and is working as expected.
Is that expected behavior for the second machine?
From the documentation I can somehow understand the onReplaced status:
Fired when a tab is replaced with another tab due to prerendering or
instant.
Although it is very poorly documented and there's no way knowing that that option is somehow related to the onUpdated onReplaced statuses but I really don't understand the onActivated statuses in the second machine and why there's a difference between the first machine and the second machine.
I couldn't find any documentation about this behavior on the web. On stackoverflow I could hardly find one question that mentions the onReplaced listener but didn't had any info I can use.
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…