Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between chrome.webNavigation.onCompleted and chrome.tabs.onUpdated.addListener with 'complete'

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.

like image 952
muhammad haris Avatar asked Jan 27 '16 07:01

muhammad haris


1 Answers

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.

like image 194
Nikhil Sharma Avatar answered Oct 17 '22 15:10

Nikhil Sharma