From 7985a986209f783341800e8d532eacd5421519b5 Mon Sep 17 00:00:00 2001 From: Piro / YUKI Hiroshi Date: Wed, 6 Mar 2013 00:58:51 +0900 Subject: [PATCH] Move all tabs in the dragged tree to a newly opened window correctly on Firefox 19 and later (#472) --- content/treestyletab/windowHelper.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/content/treestyletab/windowHelper.js b/content/treestyletab/windowHelper.js index df4af963..3f120555 100644 --- a/content/treestyletab/windowHelper.js +++ b/content/treestyletab/windowHelper.js @@ -9,14 +9,28 @@ var TreeStyleTabWindowHelper = { { var source; var target; - if ('gBrowserInit' in window && 'onLoad' in gBrowserInit) { // Firefox 16 and later (after https://bugzilla.mozilla.org/show_bug.cgi?id=731926 ) - source = gBrowserInit.onLoad.toSource(); - target = 'gBrowserInit.onLoad'; + if ('gBrowserInit' in window) { + if ( + '_delayedStartup' in gBrowserInit && + (source = gBrowserInit._delayedStartup.toSource()) && + source.indexOf('swapBrowsersAndCloseOther') > -1 + ) { + target = 'gBrowserInit._delayedStartup'; + } + else if ( // legacy code for Firefox 18 and olders + 'onLoad' in gBrowserInit && + (source = gBrowserInit.onLoad.toSource()) && + source.indexOf('swapBrowsersAndCloseOther') > -1 + ) { + target = 'gBrowserInit.onLoad'; + } } - else if ('BrowserStartup' in window) { // legacy code for Firefox 15 and older + else if ('BrowserStartup' in window) { // legacy code for Firefox 15 and olders source = window.BrowserStartup.toSource(); target = 'BrowserStartup'; } + if (!target) + dump('Tree Style Tab: failed to initialize startup function!'); if (source.indexOf('!MultipleTabService.tearOffSelectedTabsFromRemote()') > -1) { eval(target+' = '+source.replace( '!MultipleTabService.tearOffSelectedTabsFromRemote()',