Bug 856107 - Mouse hovering events should be handled seperately from tab select/move code for tab attributes. f=unusualtears r=MattN
authorMike de Boer <mdeboer@mozilla.com>
Wed, 01 May 2013 23:36:33 -0400
changeset 141518 43f7eec8a72ddf818b823ee3be30fd860ed391be
parent 141517 f029154a27b57ad86a68feed228247c7f488ccbb
child 141519 3f705f8db7c14bafe5b529f6353da7d43216ee5f
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs856107
milestone23.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 856107 - Mouse hovering events should be handled seperately from tab select/move code for tab attributes. f=unusualtears r=MattN
browser/base/content/tabbrowser.xml
browser/base/content/test/browser_bug585558.js
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -3040,33 +3040,24 @@
 
           if (!visibleTabs.length)
             return;
 
           let selectedIndex = visibleTabs.indexOf(this.selectedItem);
 
           let lastVisible = visibleTabs.length - 1;
 
-          // selectedItem will not be in visibleTabs briefly when
-          // browser.tabs.closeWindowWithLastTab is disabled and the user closes
-          // the last tab
-          if (!this.selectedItem.closing && selectedIndex != 0) {
-            let beforeSelectedTab = visibleTabs[selectedIndex - 1];
-            beforeSelectedTab.removeAttribute("beforehovered");
-          }
-
           if (this._afterSelectedTab)
             this._afterSelectedTab.removeAttribute("afterselected-visible");
           if (this.selectedItem.closing || selectedIndex == lastVisible) {
             this._afterSelectedTab = null;
           } else {
             this._afterSelectedTab = visibleTabs[selectedIndex + 1];
             this._afterSelectedTab.setAttribute("afterselected-visible",
                                                 "true");
-            this._afterSelectedTab.removeAttribute("afterhovered");
           }
 
           if (this._firstTab)
             this._firstTab.removeAttribute("first-visible-tab");
           this._firstTab = visibleTabs[0];
           this._firstTab.setAttribute("first-visible-tab", "true");
           if (this._lastTab)
             this._lastTab.removeAttribute("last-visible-tab");
@@ -4309,17 +4300,17 @@
 
     <handlers>
       <handler event="mouseover"><![CDATA[
         let anonid = event.originalTarget.getAttribute("anonid");
         if (anonid == "close-button")
           this.mOverCloseButton = true;
 
         let tab = event.target;
-        if (tab.selected || tab.closing)
+        if (tab.closing)
           return;
 
         let tabContainer = this.parentNode;
         let visibleTabs = tabContainer.tabbrowser.visibleTabs;
         let tabIndex = visibleTabs.indexOf(tab);
         if (tabIndex == 0) {
           tabContainer._beforeHoveredTab = null;
         } else {
--- a/browser/base/content/test/browser_bug585558.js
+++ b/browser/base/content/test/browser_bug585558.js
@@ -78,25 +78,55 @@ function test_showFirst() {
 function test_movedLower() {
   testAttrib(gBrowser.tabs[2], "afterselected-visible", true,
              "Third tab marked afterselected-visible!");
   test_hoverOne();
 }
 
 function test_hoverOne() {
   EventUtils.synthesizeMouseAtCenter(gBrowser.tabs[4], { type: "mousemove" });
-  testAttrib(gBrowser.tabs[3], "beforehovered", true,
-             "Fourth tab marked beforehovered");
+  testAttrib(gBrowser.tabs[3], "beforehovered", true,  "Fourth tab marked beforehovered");
   EventUtils.synthesizeMouseAtCenter(gBrowser.tabs[3], { type: "mousemove" });
-  testAttrib(gBrowser.tabs[2], "beforehovered", true,
-             "Third tab marked beforehovered!");
-  testAttrib(gBrowser.tabs[4], "afterhovered", true,
-             "Fifth tab marked afterhovered!");
+  testAttrib(gBrowser.tabs[2], "beforehovered", true,  "Third tab marked beforehovered!");
+  testAttrib(gBrowser.tabs[2], "afterhovered",  false, "Third tab not marked afterhovered!");
+  testAttrib(gBrowser.tabs[4], "afterhovered",  true,  "Fifth tab marked afterhovered!");
+  testAttrib(gBrowser.tabs[4], "beforehovered", false, "Fifth tab not marked beforehovered!");
+  testAttrib(gBrowser.tabs[0], "beforehovered", false, "First tab not marked beforehovered!");
+  testAttrib(gBrowser.tabs[0], "afterhovered",  false, "First tab not marked afterhovered!");
+  testAttrib(gBrowser.tabs[1], "beforehovered", false, "Second tab not marked beforehovered!");
+  testAttrib(gBrowser.tabs[1], "afterhovered",  false, "Second tab not marked afterhovered!");
+  testAttrib(gBrowser.tabs[3], "beforehovered", false, "Fourth tab not marked beforehovered!");
+  testAttrib(gBrowser.tabs[3], "afterhovered",  false, "Fourth tab not marked afterhovered!");
   gBrowser.removeTab(tabs.pop());
-  test_pinning();
+  executeSoon(test_hoverStatePersistence);
+}
+
+function test_hoverStatePersistence() {
+  // Test that the afterhovered and beforehovered attributes are still there when 
+  // a tab is selected and then unselected again. See bug 856107.
+
+  function assertState() {
+    testAttrib(gBrowser.tabs[0], "beforehovered", true,  "First tab still marked beforehovered!");
+    testAttrib(gBrowser.tabs[0], "afterhovered",  false, "First tab not marked afterhovered!");
+    testAttrib(gBrowser.tabs[2], "afterhovered",  true,  "Third tab still marked afterhovered!");
+    testAttrib(gBrowser.tabs[2], "beforehovered", false, "Third tab not marked afterhovered!");
+    testAttrib(gBrowser.tabs[1], "beforehovered", false, "Second tab not marked beforehovered!");
+    testAttrib(gBrowser.tabs[1], "afterhovered",  false, "Second tab not marked afterhovered!");
+    testAttrib(gBrowser.tabs[3], "beforehovered", false, "Fourth tab not marked beforehovered!");
+    testAttrib(gBrowser.tabs[3], "afterhovered",  false, "Fourth tab not marked afterhovered!");
+  }
+
+  gBrowser.selectedTab = gBrowser.tabs[3];
+  EventUtils.synthesizeMouseAtCenter(gBrowser.tabs[1], { type: "mousemove" });
+  assertState();
+  gBrowser.selectedTab = gBrowser.tabs[1];
+  assertState();
+  gBrowser.selectedTab = gBrowser.tabs[3];
+  assertState();
+  executeSoon(test_pinning);
 }
 
 function test_pinning() {
   gBrowser.selectedTab = gBrowser.tabs[3];
   testAttrib(gBrowser.tabs[3], "last-visible-tab", true,
              "Fourth tab marked last-visible-tab!");
   testAttrib(gBrowser.tabs[3], "selected", true, "Fourth tab marked selected!");
   testAttrib(gBrowser.tabs[3], "afterselected-visible", false,