Bug 619937 - Clicking on empty area of Panorama makes empty group [r=ian, a=blocking2.0-betaN+]
authorMichael Yoshitaka Erlewine <mitcho@mitcho.com>
Mon, 10 Jan 2011 17:49:29 -0500
changeset 60308 00893dfbaedb0462a7f1e251bf64bbb0bb042b61
parent 60307 fc1817a3d7a4cba01542acb0f949af292cbc0617
child 60309 62e195a65ff3763a889f33d9d7bca43bb07bc020
push idunknown
push userunknown
push dateunknown
reviewersian, blocking2
bugs619937
milestone2.0b10pre
Bug 619937 - Clicking on empty area of Panorama makes empty group [r=ian, a=blocking2.0-betaN+]
browser/base/content/tabview/ui.js
browser/base/content/test/tabview/Makefile.in
browser/base/content/test/tabview/browser_tabview_bug619937.js
--- a/browser/base/content/tabview/ui.js
+++ b/browser/base/content/tabview/ui.js
@@ -1093,34 +1093,36 @@ let UI = {
       });
       GroupItems.setActiveGroupItem(lastActiveGroupItem);
     }
 
     function finalize(e) {
       iQ(window).unbind("mousemove", updateSize);
       item.container.removeClass("dragRegion");
       dragOutInfo.stop();
-      if (phantom.css("opacity") != 1)
-        collapse();
-      else {
+      box = item.getBounds();
+      if (box.width > minMinSize && box.height > minMinSize &&
+         (box.width > minSize || box.height > minSize)) {
         var bounds = item.getBounds();
 
         // Add all of the orphaned tabs that are contained inside the new groupItem
         // to that groupItem.
         var tabs = GroupItems.getOrphanedTabs();
         var insideTabs = [];
         for each(tab in tabs) {
           if (bounds.contains(tab.bounds))
             insideTabs.push(tab);
         }
 
         var groupItem = new GroupItem(insideTabs,{bounds:bounds});
         GroupItems.setActiveGroupItem(groupItem);
         phantom.remove();
         dragOutInfo = null;
+      } else {
+        collapse();
       }
     }
 
     iQ(window).mousemove(updateSize)
     iQ(gWindow).one("mouseup", finalize);
     e.preventDefault();
     return false;
   },
--- a/browser/base/content/test/tabview/Makefile.in
+++ b/browser/base/content/test/tabview/Makefile.in
@@ -67,16 +67,17 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug597360.js \
                  browser_tabview_bug597399.js \
                  browser_tabview_bug598600.js \
                  browser_tabview_bug599626.js \
                  browser_tabview_bug600645.js \
                  browser_tabview_bug606905.js \
                  browser_tabview_bug608037.js \
                  browser_tabview_bug608158.js \
+                 browser_tabview_bug619937.js \
                  browser_tabview_dragdrop.js \
                  browser_tabview_exit_button.js \
                  browser_tabview_group.js \
                  browser_tabview_launch.js \
                  browser_tabview_multiwindow_search.js \
                  browser_tabview_orphaned_tabs.js \
                  browser_tabview_privatebrowsing.js \
                  browser_tabview_rtl.js \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug619937.js
@@ -0,0 +1,73 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Panorama bug 619937 (clicking the background) test.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+function test() {
+  waitForExplicitFinish();
+
+  window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
+  TabView.toggle();
+}
+
+function endGame() {
+  window.removeEventListener("tabviewhidden", endGame, false);
+  ok(!TabView.isVisible(), "Tab View is hidden");
+
+  finish();
+};
+
+function onTabViewWindowLoaded() {
+  window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
+  ok(TabView.isVisible(), "Tab View is visible");
+
+  let contentWindow = document.getElementById("tab-view").contentWindow;
+
+  // establish initial state
+  is(contentWindow.GroupItems.groupItems.length, 1,
+      "we start with one group (the default)");
+  is(gBrowser.tabs.length, 1, "we start with one tab");
+  let originalTab = gBrowser.tabs[0];
+
+  let bg = contentWindow.document.getElementById("bg");
+
+  EventUtils.sendMouseEvent({ type: "click" }, bg, contentWindow);
+
+  is(contentWindow.GroupItems.groupItems.length, 1,
+      "we should still only have one group");
+
+  window.addEventListener("tabviewhidden", endGame, false);
+  TabView.toggle();
+}