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(part1); michael@0: } michael@0: michael@0: function part1(win) { michael@0: registerCleanupFunction(function() win.close()); michael@0: michael@0: let contentWindow = win.TabView.getContentWindow(); michael@0: is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group"); michael@0: michael@0: let originalTab = win.gBrowser.selectedTab; michael@0: let originalGroup = contentWindow.GroupItems.groupItems[0]; michael@0: let newTab = win.gBrowser.loadOneTab("about:blank", {inBackground: true}); michael@0: michael@0: is(originalGroup.getChildren().length, 2, "The original group now has two tabs"); michael@0: michael@0: // create group two with the new tab michael@0: let box = new contentWindow.Rect(300,300,150,150); michael@0: let newGroup = new contentWindow.GroupItem([], {bounds: box, immediately: true}); michael@0: newGroup.add(newTab._tabViewTabItem, {immediately: true}); michael@0: michael@0: // ensure active group item and tab michael@0: contentWindow.UI.setActive(originalGroup); michael@0: is(contentWindow.GroupItems.getActiveGroupItem(), originalGroup, michael@0: "The original group is active"); michael@0: is(contentWindow.UI.getActiveTab(), originalTab._tabViewTabItem, michael@0: "The original tab is active"); michael@0: michael@0: function checkActive(callback, time) { michael@0: is(contentWindow.GroupItems.getActiveGroupItem(), newGroup, michael@0: "The new group is active"); michael@0: is(contentWindow.UI.getActiveTab(), newTab._tabViewTabItem, michael@0: "The new tab is active"); michael@0: if (time) michael@0: setTimeout(callback, time); michael@0: else michael@0: callback(); michael@0: } michael@0: michael@0: // click on the new tab, and check that the new tab and group are active michael@0: // at two times: 10 ms after (still during the animation) and michael@0: // 500 ms after (after the animation, hopefully). Either way, the new michael@0: // tab and group should be active. michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: newTab._tabViewTabItem.container, contentWindow); michael@0: EventUtils.sendMouseEvent({ type: "mouseup" }, michael@0: newTab._tabViewTabItem.container, contentWindow); michael@0: setTimeout(function() { michael@0: checkActive(function() { michael@0: checkActive(function() { michael@0: win.close(); michael@0: newWindowWithTabView(part2); michael@0: }); michael@0: }, 490); michael@0: }, 10) michael@0: } michael@0: michael@0: function part2(win) { michael@0: registerCleanupFunction(function() win.close()); michael@0: michael@0: let newTab = win.gBrowser.loadOneTab("about:blank", {inBackground: true}); michael@0: hideTabView(function() { michael@0: let selectedTab = win.gBrowser.selectedTab; michael@0: isnot(selectedTab, newTab, "They are different tabs"); michael@0: michael@0: // switch the selected tab to new tab michael@0: win.gBrowser.selectedTab = newTab; michael@0: michael@0: showTabView(function () { michael@0: hideTabView(function () { michael@0: is(win.gBrowser.selectedTab, newTab, michael@0: "The selected tab should be the same as before (new tab)"); michael@0: waitForFocus(finish); michael@0: }, win); michael@0: }, win); michael@0: }, win); michael@0: }