In chrome APIs there are two functions that theoretically points to the same evet.
chrome.webNavigation.onCompleted and chrome.tabs.onUpdated.addListener with changeinfo=complete.
What is the difference between these two and which one guarantee that everthing in the page have loaded. I have found that chrome.tabs.onUpdated.addListener sometimes fire even when few http requests are remaining.
The chrome.webNavigation.onCompleted is invoked even when the navigation occurs in a subframe whereas the chrome.tabs.onUpdated.addListener is only triggered when a tab is updated due to change in a tab's property like status or url. Observe the changeInfo object that is passed to the callback function here.
Also, the chrome.webNavigation.onCompleted supports filtered events, thus you can specify the filter so that the event is triggered only when the filter is passed. Observe here how to apply filters to an event.
So, if you use both the event listeners, you will observer that the chrome.webNavigation.onCompleted is fired many a times for a single tab whereas the chrome.tabs.onUpdated.addListener might fire only once or twice (due to status change from loading to complete).
I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With