Firefox/Fennec fixes

pull/2/head
Deathamns 10 years ago committed by gorhill
parent dc5761164b
commit e965b1eef7

@ -269,7 +269,14 @@ var windowWatcher = {
return;
}
if ( tabBrowser.tabContainer ) {
if ( tabBrowser.deck ) {
// Fennec
tabContainer = tabBrowser.deck;
tabContainer.addEventListener(
'DOMTitleChanged',
tabWatcher.onFennecLocationChange
);
} else if ( tabBrowser.tabContainer ) {
// desktop Firefox
tabContainer = tabBrowser.tabContainer;
tabBrowser.addTabsProgressListener(tabWatcher);
@ -346,6 +353,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: getOwnerWindow(win).getTabForWindow(win).id,
url: Services.io.newURI(win.location.href, null, null).asciiSpec
});
}
};
/******************************************************************************/
@ -417,7 +441,14 @@ vAPI.tabs.registerListeners = function() {
continue;
}
if ( tabBrowser.tabContainer ) {
if ( tabBrowser.deck ) {
// Fennec
tabContainer = tabBrowser.deck;
tabContainer.removeEventListener(
'DOMTitleChanged',
tabWatcher.onFennecLocationChange
);
} else if ( tabBrowser.tabContainer ) {
tabContainer = tabBrowser.tabContainer;
tabBrowser.removeTabsProgressListener(tabWatcher);
}
@ -451,7 +482,7 @@ vAPI.tabs.getTabId = function(target) {
for ( var win of this.getWindows() ) {
var tab = win.BrowserApp.getTabForBrowser(target);
if ( tab && tab.id !== undefined ) {
if ( tab && tab.id ) {
return tab.id;
}
}
@ -562,9 +593,6 @@ vAPI.tabs.get = function(tabId, callback) {
var tabIndex = vAPI.fennec
? tabBrowser.tabs.indexOf(tab)
: tabBrowser.browsers.indexOf(browser);
var tabTitle = vAPI.fennec
? browser.contentTitle
: tab.label;
callback({
id: tabId,
@ -572,7 +600,7 @@ vAPI.tabs.get = function(tabId, callback) {
windowId: windows.indexOf(win),
active: tab === tabBrowser.selectedTab,
url: browser.currentURI.asciiSpec,
title: tabTitle
title: tab.label
});
};
@ -1140,9 +1168,6 @@ var httpObserver = {
if ( !(channel instanceof Ci.nsIHttpChannel) ) {
return;
}
var reqDataKey = location.host + 'reqdata';
var URI = channel.URI;
var channelData, result;
@ -1160,7 +1185,7 @@ var httpObserver = {
frameId,
parentFrameId
]*/
channelData = channel.getProperty(reqDataKey);
channelData = channel.getProperty(location.host + 'reqdata');
} catch (ex) {
return;
}
@ -1242,14 +1267,6 @@ var httpObserver = {
return;
}
}
if ( lastRequest.type === this.MAIN_FRAME && lastRequest.frameId === 0 ) {
vAPI.tabs.onNavigation({
frameId: 0,
tabId: lastRequest.tabId,
url: URI.asciiSpec
});
}
if ( this.handleRequest(channel, URI, lastRequest) ) {
return;
@ -1258,7 +1275,7 @@ var httpObserver = {
// If request is not handled we may use the data in on-modify-request
if ( channel instanceof Ci.nsIWritablePropertyBag ) {
channel.setProperty(
reqDataKey,
location.host + 'reqdata',
[
lastRequest.type,
lastRequest.tabId,

Loading…
Cancel
Save