Bug 1563380 - Fix tabs.duplicate() having a different behavior than duplicate in UI r=mixedpuppy
authorMélanie Chauvel (ariasuni) <perso@hack-libre.org>
Tue, 05 Nov 2019 23:41:56 +0000
changeset 562576 76069952bbb9295b6544275df036bbd875d30ca6
parent 562575 bd4d1c8dc980524ac35c9550a59f67c4185ef9d2
child 562577 71b00388948f9cb015bf36023a513497ed897be8
push id12351
push userffxbld-merge
push dateMon, 02 Dec 2019 11:32:26 +0000
treeherdermozilla-beta@dba4410526a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1563380
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1563380 - Fix tabs.duplicate() having a different behavior than duplicate in UI r=mixedpuppy Differential Revision: https://phabricator.services.mozilla.com/D48471
browser/components/extensions/parent/ext-tabs.js
browser/components/extensions/test/browser/browser_ext_tabs_duplicate.js
--- a/browser/components/extensions/parent/ext-tabs.js
+++ b/browser/components/extensions/parent/ext-tabs.js
@@ -1091,30 +1091,20 @@ this.tabs = class extends ExtensionAPI {
 
           let gBrowser = nativeTab.ownerGlobal.gBrowser;
           let newTab = gBrowser.duplicateTab(nativeTab);
 
           tabListener.blockTabUntilRestored(newTab);
 
           return new Promise(resolve => {
             // We need to use SSTabRestoring because any attributes set before
-            // are ignored. SSTabRestored is too late and results in a jump in
-            // the UI. See http://bit.ly/session-store-api for more information.
+            // are ignored.
             newTab.addEventListener(
               "SSTabRestoring",
               function() {
-                // As the tab is restoring, move it to the correct position.
-
-                // Pinned tabs that are duplicated are inserted
-                // after the existing pinned tab and pinned.
-                if (nativeTab.pinned) {
-                  gBrowser.pinTab(newTab);
-                }
-                gBrowser.moveTabTo(newTab, nativeTab._tPos + 1);
-
                 gBrowser.selectedTab = newTab;
                 resolve(tabManager.convert(newTab));
               },
               { once: true }
             );
           });
         },
 
--- a/browser/components/extensions/test/browser/browser_ext_tabs_duplicate.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_duplicate.js
@@ -150,20 +150,20 @@ add_task(async function testDuplicatePin
       browser.tabs.query(
         {
           lastFocusedWindow: true,
         },
         function(tabs) {
           // Duplicate the pinned tab, example.net.
           browser.tabs.duplicate(tabs[0].id, tab => {
             browser.test.assertEq("http://example.net/", tab.url);
-            // Should be the second tab, next to the one duplicated.
+            // Should be the second tab, next to the original.
             browser.test.assertEq(1, tab.index);
-            // Should be pinned.
-            browser.test.assertTrue(tab.pinned);
+            // Duplicated tab is not pinned, even if the original tab is.
+            browser.test.assertFalse(tab.pinned);
 
             browser.tabs.remove([tabs[0].id, tab.id]);
             browser.test.notifyPass("tabs.duplicate.pinned");
           });
         }
       );
     },
   });