1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-03 01:29:39 +02:00

Merge pull request #1084 from AlexVallat/master

Fix for #1072: Listen to DOMTitleChanged
This commit is contained in:
Deathamns 2015-03-26 16:56:36 +01:00
commit bb1bb84682

View File

@ -295,6 +295,7 @@ var windowWatcher = {
if ( tabBrowser.deck ) { if ( tabBrowser.deck ) {
// Fennec // Fennec
tabContainer = tabBrowser.deck; tabContainer = tabBrowser.deck;
tabContainer.addEventListener('DOMTitleChanged', tabWatcher.onFennecLocationChange);
} else if ( tabBrowser.tabContainer ) { } else if ( tabBrowser.tabContainer ) {
// desktop Firefox // desktop Firefox
tabContainer = tabBrowser.tabContainer; tabContainer = tabBrowser.tabContainer;
@ -375,6 +376,23 @@ var tabWatcher = {
url: location.asciiSpec url: location.asciiSpec
}); });
}, },
onFennecLocationChange: function({target: doc}) {
// Fennec "equivalent" to onLocationChange
// note that DOMTitleChanged is selected as it fires very early
// (before DOMContentLoaded), and it does fire even if there is no title
var win = doc.defaultView;
if ( win !== win.top ) {
return;
}
vAPI.tabs.onNavigation({
frameId: 0,
tabId: vAPI.tabs.getTabId(getOwnerWindow(win).BrowserApp.getTabForWindow(win)),
url: Services.io.newURI(win.location.href, null, null).asciiSpec
});
}
}; };
/******************************************************************************/ /******************************************************************************/
@ -452,6 +470,7 @@ vAPI.tabs.registerListeners = function() {
if ( tabBrowser.deck ) { if ( tabBrowser.deck ) {
// Fennec // Fennec
tabContainer = tabBrowser.deck; tabContainer = tabBrowser.deck;
tabContainer.removeEventListener('DOMTitleChanged', tabWatcher.onFennecLocationChange);
} else if ( tabBrowser.tabContainer ) { } else if ( tabBrowser.tabContainer ) {
tabContainer = tabBrowser.tabContainer; tabContainer = tabBrowser.tabContainer;
tabBrowser.removeTabsProgressListener(tabWatcher); tabBrowser.removeTabsProgressListener(tabWatcher);