From 766537962c0c82f8087607ffbe1e51353bbaafbe Mon Sep 17 00:00:00 2001 From: AlexVallat Date: Tue, 24 Mar 2015 07:56:18 +0000 Subject: [PATCH 1/2] 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 9d7b3dcd2..f790a283a 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 + }); + } + }; /******************************************************************************/ From 019ce258225d508598a306b4361196f50ce9aba9 Mon Sep 17 00:00:00 2001 From: AlexVallat Date: Thu, 26 Mar 2015 15:44:57 +0000 Subject: [PATCH 2/2] Cleanup for DOMTitleChanged listener --- platform/firefox/vapi-background.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index f790a283a..935e18c2b 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -296,7 +296,6 @@ var windowWatcher = { // Fennec tabContainer = tabBrowser.deck; tabContainer.addEventListener('DOMTitleChanged', tabWatcher.onFennecLocationChange); - } else if ( tabBrowser.tabContainer ) { // desktop Firefox tabContainer = tabBrowser.tabContainer; @@ -471,6 +470,7 @@ vAPI.tabs.registerListeners = function() { if ( tabBrowser.deck ) { // Fennec tabContainer = tabBrowser.deck; + tabContainer.removeEventListener('DOMTitleChanged', tabWatcher.onFennecLocationChange); } else if ( tabBrowser.tabContainer ) { tabContainer = tabBrowser.tabContainer; tabBrowser.removeTabsProgressListener(tabWatcher);