michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: newWindowWithTabView(onTabViewWindowLoaded); michael@0: } michael@0: michael@0: function onTabViewWindowLoaded(win) { michael@0: win.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); michael@0: michael@0: ok(win.TabView.isVisible(), "Tab View is visible"); michael@0: michael@0: let contentWindow = win.document.getElementById("tab-view").contentWindow; michael@0: let [originalTab] = win.gBrowser.visibleTabs; michael@0: michael@0: let currentGroup = contentWindow.GroupItems.getActiveGroupItem(); michael@0: michael@0: // Create a group and make it active michael@0: let box = new contentWindow.Rect(100, 100, 370, 370); michael@0: let group = new contentWindow.GroupItem([], { bounds: box }); michael@0: ok(group.isEmpty(), "This group is empty"); michael@0: contentWindow.UI.setActive(group); michael@0: is(contentWindow.GroupItems.getActiveGroupItem(), group, "new group is active"); michael@0: michael@0: // Create a bunch of tabs in the group michael@0: let bg = {inBackground: true}; michael@0: let datatext = win.gBrowser.loadOneTab("data:text/plain,bug610242", bg); michael@0: let datahtml = win.gBrowser.loadOneTab("data:text/html,

hi!

", bg); michael@0: let mozilla = win.gBrowser.loadOneTab("about:mozilla", bg); michael@0: let synclog = win.gBrowser.loadOneTab("about:sync-log", bg); michael@0: let html = win.gBrowser.loadOneTab("http://example.com", bg); michael@0: let png = win.gBrowser.loadOneTab("http://mochi.test:8888/browser/browser/base/content/test/general/moz.png", bg); michael@0: let svg = win.gBrowser.loadOneTab("http://mochi.test:8888/browser/browser/base/content/test/general/title_test.svg", bg); michael@0: michael@0: ok(!group.shouldStack(group._children.length), "Group should not stack."); michael@0: michael@0: // PREPARE FINISH: michael@0: group.addSubscriber("close", function onClose() { michael@0: group.removeSubscriber("close", onClose); michael@0: michael@0: ok(group.isEmpty(), "The group is empty again"); michael@0: michael@0: contentWindow.UI.setActive(currentGroup); michael@0: isnot(contentWindow.GroupItems.getActiveGroupItem(), null, "There is an active group"); michael@0: is(win.gBrowser.tabs.length, 1, "There is only one tab left"); michael@0: is(win.gBrowser.visibleTabs.length, 1, "There is also only one visible tab"); michael@0: michael@0: whenTabViewIsHidden(function() { michael@0: win.close(); michael@0: ok(win.closed, "new window is closed"); michael@0: finish(); michael@0: }, win); michael@0: win.gBrowser.selectedTab = originalTab; michael@0: michael@0: win.TabView.hide(); michael@0: }); michael@0: michael@0: function check(tab, label, visible) { michael@0: let display = contentWindow.getComputedStyle(tab._tabViewTabItem.$fav[0], null).getPropertyValue("display"); michael@0: if (visible) { michael@0: is(display, "block", label + " has favicon"); michael@0: } else { michael@0: is(display, "none", label + " has no favicon"); michael@0: } michael@0: } michael@0: michael@0: afterAllTabsLoaded(function() { michael@0: let children = group.getChildren(); michael@0: let len = children.length; michael@0: let iconUpdateCounter = 0; michael@0: michael@0: children.forEach(function(tabItem) { michael@0: tabItem.addSubscriber("iconUpdated", function onIconUpdated() { michael@0: tabItem.removeSubscriber("iconUpdated", onIconUpdated); michael@0: michael@0: if (++iconUpdateCounter == len) { michael@0: check(datatext, "datatext", false); michael@0: check(datahtml, "datahtml", false); michael@0: check(mozilla, "about:mozilla", false); michael@0: check(synclog, "about:sync-log", true); michael@0: check(html, "html", true); michael@0: check(png, "png", false); michael@0: check(svg, "svg", true); michael@0: michael@0: // Get rid of the group and its children michael@0: // The group close will trigger a finish(). michael@0: closeGroupItem(group); michael@0: } michael@0: }); michael@0: }); michael@0: michael@0: afterAllTabItemsUpdated(function () {}, win); michael@0: }, win); michael@0: }