Bug 625424 - Dropping a tab onto the 'undo close group' dialog adds the tab to that group [r=ian, a=beltzner]
authorTim Taubert <tim.taubert@gmx.de>
Sun, 30 Jan 2011 03:29:00 +0100
changeset 61627 336d5906cb0f7be789450241d9813f8412ebe360
parent 61626 aacc3b418049d4547423c13aa0022f630161b537
child 61628 e058817c0ab0ce6d70d6ad7d6982fcb02768a899
push id18412
push userjwatt@jwatt.org
push dateSun, 30 Jan 2011 08:06:30 +0000
treeherdermozilla-central@336d5906cb0f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersian, beltzner
bugs625424
milestone2.0b11pre
first release with
nightly linux32
336d5906cb0f / 4.0b11pre / 20110130030342 / files
nightly linux64
336d5906cb0f / 4.0b11pre / 20110130030342 / files
nightly mac
336d5906cb0f / 4.0b11pre / 20110130030342 / files
nightly win32
336d5906cb0f / 4.0b11pre / 20110130030342 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 625424 - Dropping a tab onto the 'undo close group' dialog adds the tab to that group [r=ian, a=beltzner]
browser/base/content/tabview/groupitems.js
browser/base/content/test/tabview/Makefile.in
browser/base/content/test/tabview/browser_tabview_bug625424.js
--- a/browser/base/content/tabview/groupitems.js
+++ b/browser/base/content/tabview/groupitems.js
@@ -571,16 +571,17 @@ GroupItem.prototype = Utils.extend(new I
          "-moz-transform": "scale(.3)",
       }, {
         duration: 170,
         complete: function() {
           iQ(this).hide();
         }
       });
 
+      this.droppable(false);
       this._createUndoButton();
     } else
       this.close();
     
     this._makeClosestTabActive();
   },
   
   // ----------
@@ -627,16 +628,17 @@ GroupItem.prototype = Utils.extend(new I
   // Shows the hidden group.
   _unhide: function GroupItem__unhide() {
     let self = this;
 
     this._cancelFadeAwayUndoButtonTimer();
     this.hidden = false;
     this.$undoContainer.remove();
     this.$undoContainer = null;
+    this.droppable(true);
 
     iQ(this.container).show().animate({
       "-moz-transform": "scale(1)",
       "opacity": 1
     }, {
       duration: 170,
       complete: function() {
         self._children.forEach(function(child) {
--- a/browser/base/content/test/tabview/Makefile.in
+++ b/browser/base/content/test/tabview/Makefile.in
@@ -87,16 +87,17 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug618828.js \
                  browser_tabview_bug619937.js \
                  browser_tabview_bug622835.js \
                  browser_tabview_bug622872.js \
                  browser_tabview_bug624265.js \
                  browser_tabview_bug624727.js \
                  browser_tabview_bug624953.js \
                  browser_tabview_bug625269.js \
+                 browser_tabview_bug625424.js \
                  browser_tabview_bug626368.js \
                  browser_tabview_bug627288.js \
                  browser_tabview_bug627736.js \
                  browser_tabview_bug628165.js \
                  browser_tabview_dragdrop.js \
                  browser_tabview_exit_button.js \
                  browser_tabview_expander.js \
                  browser_tabview_group.js \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug625424.js
@@ -0,0 +1,89 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  let win;
+  let cw;
+
+  let getGroupItem = function (index) {
+    return cw.GroupItems.groupItems[index];
+  }
+
+  let createOrphan = function (callback) {
+    let tab = win.gBrowser.loadOneTab('about:blank', {inBackground: true});
+    afterAllTabsLoaded(function () {
+      let tabItem = tab._tabViewTabItem;
+      tabItem.parent.remove(tabItem);
+      callback(tabItem);
+    });
+  }
+
+  let hideGroupItem = function (groupItem, callback) {
+    groupItem.addSubscriber(groupItem, 'groupHidden', function () {
+      groupItem.removeSubscriber(groupItem, 'groupHidden');
+      callback();
+    });
+    groupItem.closeAll();
+  }
+
+  let newWindow = function (test) {
+    newWindowWithTabView(function (tvwin) {
+      registerCleanupFunction(function () {
+        if (!tvwin.closed)
+          tvwin.close();
+      });
+
+      win = tvwin;
+      cw = win.TabView.getContentWindow();
+      test();
+    });
+  }
+
+  let assertNumberOfTabsInGroupItem = function (groupItem, numTabs) {
+    is(groupItem.getChildren().length, numTabs,
+        'there are ' + numTabs + ' tabs in this groupItem');
+  }
+
+  let testDragOnHiddenGroup = function () {
+    createOrphan(function (orphan) {
+      let groupItem = getGroupItem(0);
+      hideGroupItem(groupItem, function () {
+        let drag = orphan.container;
+        let drop = groupItem.$undoContainer[0];
+
+        assertNumberOfTabsInGroupItem(groupItem, 1);
+
+        EventUtils.synthesizeMouseAtCenter(drag, {type: 'mousedown'}, cw);
+        EventUtils.synthesizeMouseAtCenter(drop, {type: 'mousemove'}, cw);
+        EventUtils.synthesizeMouseAtCenter(drop, {type: 'mouseup'}, cw);
+
+        assertNumberOfTabsInGroupItem(groupItem, 1);
+
+        win.close();
+        newWindow(testDragOnVisibleGroup);
+      });
+    });
+  }
+
+  let testDragOnVisibleGroup = function () {
+    createOrphan(function (orphan) {
+      let groupItem = getGroupItem(0);
+      let drag = orphan.container;
+      let drop = groupItem.container;
+
+      assertNumberOfTabsInGroupItem(groupItem, 1);
+
+      EventUtils.synthesizeMouseAtCenter(drag, {type: 'mousedown'}, cw);
+      EventUtils.synthesizeMouseAtCenter(drop, {type: 'mousemove'}, cw);
+      EventUtils.synthesizeMouseAtCenter(drop, {type: 'mouseup'}, cw);
+
+      assertNumberOfTabsInGroupItem(groupItem, 2);
+
+      win.close();
+      finish();
+    });
+  }
+
+  waitForExplicitFinish();
+  newWindow(testDragOnHiddenGroup);
+}