1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug610242.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,96 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function test() { 1.8 + waitForExplicitFinish(); 1.9 + 1.10 + newWindowWithTabView(onTabViewWindowLoaded); 1.11 +} 1.12 + 1.13 +function onTabViewWindowLoaded(win) { 1.14 + win.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); 1.15 + 1.16 + ok(win.TabView.isVisible(), "Tab View is visible"); 1.17 + 1.18 + let contentWindow = win.document.getElementById("tab-view").contentWindow; 1.19 + let [originalTab] = win.gBrowser.visibleTabs; 1.20 + 1.21 + let currentGroup = contentWindow.GroupItems.getActiveGroupItem(); 1.22 + 1.23 + // Create a group and make it active 1.24 + let box = new contentWindow.Rect(100, 100, 370, 370); 1.25 + let group = new contentWindow.GroupItem([], { bounds: box }); 1.26 + ok(group.isEmpty(), "This group is empty"); 1.27 + contentWindow.UI.setActive(group); 1.28 + is(contentWindow.GroupItems.getActiveGroupItem(), group, "new group is active"); 1.29 + 1.30 + // Create a bunch of tabs in the group 1.31 + let bg = {inBackground: true}; 1.32 + let datatext = win.gBrowser.loadOneTab("data:text/plain,bug610242", bg); 1.33 + let datahtml = win.gBrowser.loadOneTab("data:text/html,<h1>hi!</h1>", bg); 1.34 + let mozilla = win.gBrowser.loadOneTab("about:mozilla", bg); 1.35 + let synclog = win.gBrowser.loadOneTab("about:sync-log", bg); 1.36 + let html = win.gBrowser.loadOneTab("http://example.com", bg); 1.37 + let png = win.gBrowser.loadOneTab("http://mochi.test:8888/browser/browser/base/content/test/general/moz.png", bg); 1.38 + let svg = win.gBrowser.loadOneTab("http://mochi.test:8888/browser/browser/base/content/test/general/title_test.svg", bg); 1.39 + 1.40 + ok(!group.shouldStack(group._children.length), "Group should not stack."); 1.41 + 1.42 + // PREPARE FINISH: 1.43 + group.addSubscriber("close", function onClose() { 1.44 + group.removeSubscriber("close", onClose); 1.45 + 1.46 + ok(group.isEmpty(), "The group is empty again"); 1.47 + 1.48 + contentWindow.UI.setActive(currentGroup); 1.49 + isnot(contentWindow.GroupItems.getActiveGroupItem(), null, "There is an active group"); 1.50 + is(win.gBrowser.tabs.length, 1, "There is only one tab left"); 1.51 + is(win.gBrowser.visibleTabs.length, 1, "There is also only one visible tab"); 1.52 + 1.53 + whenTabViewIsHidden(function() { 1.54 + win.close(); 1.55 + ok(win.closed, "new window is closed"); 1.56 + finish(); 1.57 + }, win); 1.58 + win.gBrowser.selectedTab = originalTab; 1.59 + 1.60 + win.TabView.hide(); 1.61 + }); 1.62 + 1.63 + function check(tab, label, visible) { 1.64 + let display = contentWindow.getComputedStyle(tab._tabViewTabItem.$fav[0], null).getPropertyValue("display"); 1.65 + if (visible) { 1.66 + is(display, "block", label + " has favicon"); 1.67 + } else { 1.68 + is(display, "none", label + " has no favicon"); 1.69 + } 1.70 + } 1.71 + 1.72 + afterAllTabsLoaded(function() { 1.73 + let children = group.getChildren(); 1.74 + let len = children.length; 1.75 + let iconUpdateCounter = 0; 1.76 + 1.77 + children.forEach(function(tabItem) { 1.78 + tabItem.addSubscriber("iconUpdated", function onIconUpdated() { 1.79 + tabItem.removeSubscriber("iconUpdated", onIconUpdated); 1.80 + 1.81 + if (++iconUpdateCounter == len) { 1.82 + check(datatext, "datatext", false); 1.83 + check(datahtml, "datahtml", false); 1.84 + check(mozilla, "about:mozilla", false); 1.85 + check(synclog, "about:sync-log", true); 1.86 + check(html, "html", true); 1.87 + check(png, "png", false); 1.88 + check(svg, "svg", true); 1.89 + 1.90 + // Get rid of the group and its children 1.91 + // The group close will trigger a finish(). 1.92 + closeGroupItem(group); 1.93 + } 1.94 + }); 1.95 + }); 1.96 + 1.97 + afterAllTabItemsUpdated(function () {}, win); 1.98 + }, win); 1.99 +}