diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 20152cfa..583f1c27 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -1778,19 +1778,14 @@ catch(e) { cleanUpTabsArray : function(aTabs) { - var b = this.getTabBrowserFromChild(aTabs[0]); - - aTabs = aTabs.map(function(aTab) { - return aTab.getAttribute(this.kID); - }, this); - aTabs.sort(); - aTabs = aTabs.join('|').replace(/([^\|]+)(\|\1)+/g, '$1').split('|'); - - for (var i = 0, maxi = aTabs.length; i < maxi; i++) - { - aTabs[i] = b.treeStyleTab.getTabById(aTabs[i]); - } - return aTabs; + var newTabs = []; + aTabs.forEach(function(aTab) { + if (newTabs.indexOf(aTab) < 0) newTabs.push(aTab); + }); + newTabs.sort(function(aA, aB) { + return aA._tPos - aB._tPos; + }); + return newTabs; }, bookmarkTabSubTree : function(aTabOrTabs) diff --git a/tests/unit/treestyletab_tabUtils.test.js b/tests/unit/treestyletab_tabUtils.test.js index 5d8cf88f..d327b3a3 100644 --- a/tests/unit/treestyletab_tabUtils.test.js +++ b/tests/unit/treestyletab_tabUtils.test.js @@ -226,12 +226,17 @@ function test_setAndGetTabValue() assertSetAndGetTabValue(tabs[2], 'tab2'); } +function test_cleanUpTabsArray() +{ + var array = [0, 1, 2, 1, 3, 0] + .map(function(aIndex) { + return tabs[aIndex] + }); + assert.equals(tabs, Array.slice(sv.cleanUpTabsArray(array))); +} + /* - -sv.cleanUpTabsArray(tabs) - - sv.registerAttachTabPostProcess(func) sv.registerTabFocusAllowance(func)