2011-02-27 17:36:36 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
2011-01-13 10:22:47 -08:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
newWindowWithTabView(onTabViewWindowLoaded);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onTabViewWindowLoaded(win) {
|
|
|
|
win.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
|
|
|
|
|
|
|
|
ok(win.TabView.isVisible(), "Tab View is visible");
|
|
|
|
|
|
|
|
let contentWindow = win.document.getElementById("tab-view").contentWindow;
|
|
|
|
let [originalTab] = win.gBrowser.visibleTabs;
|
|
|
|
|
|
|
|
let currentGroup = contentWindow.GroupItems.getActiveGroupItem();
|
|
|
|
|
|
|
|
// Create a group and make it active
|
|
|
|
let box = new contentWindow.Rect(100, 100, 370, 370);
|
|
|
|
let group = new contentWindow.GroupItem([], { bounds: box });
|
|
|
|
ok(group.isEmpty(), "This group is empty");
|
2011-04-22 13:05:11 -07:00
|
|
|
contentWindow.UI.setActive(group);
|
2011-01-13 10:22:47 -08:00
|
|
|
is(contentWindow.GroupItems.getActiveGroupItem(), group, "new group is active");
|
|
|
|
|
|
|
|
// Create a bunch of tabs in the group
|
|
|
|
let bg = {inBackground: true};
|
|
|
|
let datatext = win.gBrowser.loadOneTab("data:text/plain,bug610242", bg);
|
2013-05-13 02:03:32 -07:00
|
|
|
let datahtml = win.gBrowser.loadOneTab("data:text/html,<h1>hi!</h1>", bg);
|
2011-01-13 10:22:47 -08:00
|
|
|
let mozilla = win.gBrowser.loadOneTab("about:mozilla", bg);
|
2012-05-21 18:25:49 -07:00
|
|
|
let synclog = win.gBrowser.loadOneTab("about:sync-log", bg);
|
2011-01-13 10:22:47 -08:00
|
|
|
let html = win.gBrowser.loadOneTab("http://example.com", bg);
|
|
|
|
let png = win.gBrowser.loadOneTab("http://mochi.test:8888/browser/browser/base/content/test/moz.png", bg);
|
|
|
|
let svg = win.gBrowser.loadOneTab("http://mochi.test:8888/browser/browser/base/content/test/title_test.svg", bg);
|
|
|
|
|
|
|
|
ok(!group.shouldStack(group._children.length), "Group should not stack.");
|
|
|
|
|
|
|
|
// PREPARE FINISH:
|
2011-07-14 10:54:25 -07:00
|
|
|
group.addSubscriber("close", function onClose() {
|
|
|
|
group.removeSubscriber("close", onClose);
|
2011-01-13 10:22:47 -08:00
|
|
|
|
|
|
|
ok(group.isEmpty(), "The group is empty again");
|
|
|
|
|
2011-04-22 13:05:11 -07:00
|
|
|
contentWindow.UI.setActive(currentGroup);
|
2011-01-13 10:22:47 -08:00
|
|
|
isnot(contentWindow.GroupItems.getActiveGroupItem(), null, "There is an active group");
|
|
|
|
is(win.gBrowser.tabs.length, 1, "There is only one tab left");
|
|
|
|
is(win.gBrowser.visibleTabs.length, 1, "There is also only one visible tab");
|
|
|
|
|
2012-03-14 09:24:03 -07:00
|
|
|
whenTabViewIsHidden(function() {
|
2011-01-13 10:22:47 -08:00
|
|
|
win.close();
|
|
|
|
ok(win.closed, "new window is closed");
|
|
|
|
finish();
|
2012-03-14 09:24:03 -07:00
|
|
|
}, win);
|
2011-01-13 10:22:47 -08:00
|
|
|
win.gBrowser.selectedTab = originalTab;
|
|
|
|
|
|
|
|
win.TabView.hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
function check(tab, label, visible) {
|
2010-11-05 06:32:00 -07:00
|
|
|
let display = contentWindow.getComputedStyle(tab._tabViewTabItem.$fav[0], null).getPropertyValue("display");
|
2011-01-13 10:22:47 -08:00
|
|
|
if (visible) {
|
|
|
|
is(display, "block", label + " has favicon");
|
|
|
|
} else {
|
|
|
|
is(display, "none", label + " has no favicon");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-15 15:28:22 -07:00
|
|
|
afterAllTabsLoaded(function() {
|
2012-04-18 09:19:48 -07:00
|
|
|
let children = group.getChildren();
|
|
|
|
let len = children.length;
|
|
|
|
let iconUpdateCounter = 0;
|
|
|
|
|
|
|
|
children.forEach(function(tabItem) {
|
|
|
|
tabItem.addSubscriber("iconUpdated", function onIconUpdated() {
|
|
|
|
tabItem.removeSubscriber("iconUpdated", onIconUpdated);
|
|
|
|
|
|
|
|
if (++iconUpdateCounter == len) {
|
|
|
|
check(datatext, "datatext", false);
|
|
|
|
check(datahtml, "datahtml", false);
|
|
|
|
check(mozilla, "about:mozilla", false);
|
2012-05-21 18:25:49 -07:00
|
|
|
check(synclog, "about:sync-log", true);
|
2012-04-18 09:19:48 -07:00
|
|
|
check(html, "html", true);
|
|
|
|
check(png, "png", false);
|
|
|
|
check(svg, "svg", true);
|
|
|
|
|
|
|
|
// Get rid of the group and its children
|
|
|
|
// The group close will trigger a finish().
|
|
|
|
closeGroupItem(group);
|
|
|
|
}
|
2012-03-15 15:28:22 -07:00
|
|
|
});
|
2012-04-18 09:19:48 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAllTabItemsUpdated(function () {}, win);
|
2012-03-15 15:28:22 -07:00
|
|
|
}, win);
|
2011-01-13 10:22:47 -08:00
|
|
|
}
|