From ed43097de841b50e83bb946a64c99a6ae00fbe10 Mon Sep 17 00:00:00 2001 From: AlexVallat Date: Tue, 24 Mar 2015 07:56:18 +0000 Subject: [PATCH] Fix for #1072: Listen to DOMTitleChanged as additional navigation event for Fennec --- platform/firefox/vapi-background.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 0584e70..f76d6e5 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -295,6 +295,8 @@ var windowWatcher = { if ( tabBrowser.deck ) { // Fennec tabContainer = tabBrowser.deck; + tabContainer.addEventListener('DOMTitleChanged', tabWatcher.onFennecLocationChange); + } else if ( tabBrowser.tabContainer ) { // desktop Firefox tabContainer = tabBrowser.tabContainer; @@ -375,6 +377,23 @@ var tabWatcher = { 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 + }); + } + }; /******************************************************************************/