Bug 1481700 - Release clear-selection lock when 'mouseup' event is fired for tabs. r?jaws draft multi_select_fix_broken_shift_key2
authorAbdoulaye O. Ly <ablayelyfondou@gmail.com>
Wed, 08 Aug 2018 03:00:29 +0000
branchmulti_select_fix_broken_shift_key2
changeset 827409 577d3ccdf9aae18a5d5a6459adf95f74c5b22c99
parent 827379 d9e6ce390607ad8c227adc2ad2ff3cac89a814bc
push id118530
push userbmo:ablayelyfondou@gmail.com
push dateWed, 08 Aug 2018 03:01:50 +0000
reviewersjaws
bugs1481700
milestone63.0a1
Bug 1481700 - Release clear-selection lock when 'mouseup' event is fired for tabs. r?jaws MozReview-Commit-ID: FslyILLXMrj
browser/base/content/tabbrowser.js
browser/base/content/tabbrowser.xml
browser/base/content/test/tabs/browser_multiselect_tabs_using_Shift.js
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -3750,16 +3750,21 @@ window._gBrowser = {
     }
   },
 
   lockClearMultiSelectionOnce() {
     this._clearMultiSelectionLockedOnce = true;
     this._clearMultiSelectionLocked = true;
   },
 
+  unlockClearMultiSelection() {
+    this._clearMultiSelectionLockedOnce = false;
+    this._clearMultiSelectionLocked = false;
+  },
+
   /**
    * Remove a tab from the multiselection if it's the only one left there.
    *
    * In fact, some scenario may lead to only one single tab multi-selected,
    * this is something to avoid (Chrome does the same)
    * Consider 4 tabs A,B,C,D with A having the focus
    * 1. select C with Ctrl
    * 2. Right-click on B and "Close Tabs to The Right"
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2056,16 +2056,20 @@
         }
 
         if (event.button == 1) {
           gBrowser.warmupTab(gBrowser._findTabToBlurTo(this));
         }
       ]]>
       </handler>
       <handler event="mouseup">
+        // Make sure that clear-selection is released.
+        // Otherwise Selection using Shift key is broken (bug 1481700).
+        gBrowser.unlockClearMultiSelection();
+
         this.style.MozUserFocus = "";
       </handler>
 
       <handler event="click" button="0"><![CDATA[
         if (Services.prefs.getBoolPref("browser.tabs.multiselect")) {
           let shiftKey = event.shiftKey;
           let accelKey = event.getModifierState("Accel");
           if (shiftKey) {
--- a/browser/base/content/test/tabs/browser_multiselect_tabs_using_Shift.js
+++ b/browser/base/content/test/tabs/browser_multiselect_tabs_using_Shift.js
@@ -93,16 +93,27 @@ add_task(async function itemsInTheCollec
     is(gBrowser.selectedTab, tab3, "Tab3 has focus");
     ok(!tab1.multiselected && !gBrowser._multiSelectedTabsSet.has(tab1), "Tab1 is not multi-selected");
     ok(!tab2.multiselected && !gBrowser._multiSelectedTabsSet.has(tab2), "Tab2 is not multi-selected ");
     ok(tab3.multiselected && gBrowser._multiSelectedTabsSet.has(tab3), "Tab3 is multi-selected");
     ok(tab4.multiselected && gBrowser._multiSelectedTabsSet.has(tab4), "Tab4 is multi-selected");
     ok(tab5.multiselected && gBrowser._multiSelectedTabsSet.has(tab5), "Tab5 is multi-selected");
     is(gBrowser.multiSelectedTabsCount, 3, "Three tabs are multi-selected");
 
+    info("Click on tab4 while holding Shift key");
+    await triggerClickOn(tab4, { shiftKey: true });
+
+    is(gBrowser.selectedTab, tab3, "Tab3 has focus");
+    ok(!tab1.multiselected && !gBrowser._multiSelectedTabsSet.has(tab1), "Tab1 is not multi-selected");
+    ok(!tab2.multiselected && !gBrowser._multiSelectedTabsSet.has(tab2), "Tab2 is not multi-selected ");
+    ok(tab3.multiselected && gBrowser._multiSelectedTabsSet.has(tab3), "Tab3 is multi-selected");
+    ok(tab4.multiselected && gBrowser._multiSelectedTabsSet.has(tab4), "Tab4 is multi-selected");
+    ok(!tab5.multiselected && !gBrowser._multiSelectedTabsSet.has(tab5), "Tab5 is not multi-selected");
+    is(gBrowser.multiSelectedTabsCount, 2, "Two tabs are multi-selected");
+
     info("Click on tab1 while holding Shift key");
     await triggerClickOn(tab1, { shiftKey: true });
 
     is(gBrowser.selectedTab, tab3, "Tab3 has focus");
     ok(tab1.multiselected && gBrowser._multiSelectedTabsSet.has(tab1), "Tab1 is multi-selected");
     ok(tab2.multiselected && gBrowser._multiSelectedTabsSet.has(tab2), "Tab2 is multi-selected ");
     ok(tab3.multiselected && gBrowser._multiSelectedTabsSet.has(tab3), "Tab3 is multi-selected");
     ok(!tab4.multiselected && !gBrowser._multiSelectedTabsSet.has(tab4), "Tab4 is not multi-selected");