From 10740a28ff5c7c5966d8a633c3d361227d9985a6 Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 1 Jun 2015 08:11:25 -0400 Subject: [PATCH] this fixes console warning when view-source: --- platform/firefox/vapi-background.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index b8d5bf711..b99854886 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -415,15 +415,22 @@ vAPI.tabs.registerListeners = function() { // currentURI // ownerDocument (XULDocument) // defaultView (ChromeWindow) -// gBrowser (tabbrowser) +// gBrowser (tabbrowser OR browser) // browsers (browser) // selectedBrowser // selectedTab // tabs (tab.tabbrowser-tab) // -// Fennec: +// Fennec: (what I figured so far) // -// ??? +// tab --> browser windows --> window --> BrowserApp --> tabs --+ +// ^ window | +// | | +// +---------------------------------------------------------------+ +// +// tab +// browser +// [manual search to go back to tab from list of windows] vAPI.tabs.get = function(tabId, callback) { var win, browser; @@ -691,6 +698,12 @@ var tabWatcher = (function() { if ( !tabbrowser ) { return -1; } + // This can happen, for example, the `view-source:` window, there is + // no tabbrowser object, the browser object sits directly in the + // window. + if ( tabbrowser === browser ) { + return 0; + } return vAPI.fennec ? tabbrowser.tabs.indexOf(browser) : tabbrowser.browsers.indexOf(browser); @@ -2058,7 +2071,7 @@ vAPI.contextMenu.create = function(details, callback) { if ( gContextMenu.inFrame ) { details.tagName = 'iframe'; // Probably won't work with e10s - details.frameUrl = gContextMenu.focusedWindow.location.href; + details.frameUrl = gContextMenu.focusedWindow && gContextMenu.focusedWindow.location.href || ''; } else if ( gContextMenu.onImage ) { details.tagName = 'img'; details.srcUrl = gContextMenu.mediaURL;