michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let contentWindow; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: registerCleanupFunction(function() { michael@0: while (gBrowser.tabs[1]) michael@0: gBrowser.removeTab(gBrowser.tabs[1]); michael@0: hideTabView(); michael@0: }); michael@0: michael@0: gBrowser.addTab("about:mozilla"); michael@0: showTabView(setup); michael@0: } michael@0: michael@0: michael@0: function setup() { michael@0: let prefix = "setup: "; michael@0: michael@0: registerCleanupFunction(function() { michael@0: let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId); michael@0: if (groupItem) michael@0: closeGroupItem(groupItem); michael@0: }); michael@0: michael@0: contentWindow = TabView.getContentWindow(); michael@0: let groupItemOne = contentWindow.GroupItems.groupItems[0]; michael@0: michael@0: contentWindow = TabView.getContentWindow(); michael@0: is(contentWindow.GroupItems.groupItems.length, 1, michael@0: prefix + "There is only one group"); michael@0: michael@0: is(groupItemOne.getChildren().length, 2, michael@0: prefix + "The number of tabs in group one is 2"); michael@0: michael@0: // Create a second group with a dummy page. michael@0: let groupItemTwo = createGroupItemWithTabs( michael@0: window, 300, 300, 310, ["about:blank"]); michael@0: let groupItemTwoId = groupItemTwo.id; michael@0: michael@0: // Add a new tab to the second group, from where we will execute the switch michael@0: // to tab. michael@0: groupItemTwo.newTab("about:blank"); michael@0: michael@0: is(contentWindow.GroupItems.getActiveGroupItem(), groupItemTwo, michael@0: prefix + "The group two is the active group"); michael@0: michael@0: is(contentWindow.UI.getActiveTab(), groupItemTwo.getChild(1), michael@0: prefix + "The second tab item in group two is active"); michael@0: michael@0: hideTabView(function () { switchToURL(groupItemOne, groupItemTwo) } ); michael@0: } michael@0: michael@0: michael@0: function switchToURL(groupItemOne, groupItemTwo) { michael@0: let prefix = "after switching: "; michael@0: michael@0: /** michael@0: * At this point, focus is on group one. Let's switch to a tab with an URL michael@0: * contained in group two and then open a new tab in group two after the michael@0: * switch. The tab should be opened in group two and not in group one. michael@0: */ michael@0: // Set the urlbar to include the moz-action. michael@0: gURLBar.value = "moz-action:switchtab,about:mozilla"; michael@0: // Focus the urlbar so we can press enter. michael@0: gURLBar.focus(); michael@0: // Press enter. michael@0: EventUtils.synthesizeKey("VK_RETURN", {}); michael@0: michael@0: // Open a new tab and make sure the tab is opened in the group one. michael@0: EventUtils.synthesizeKey("t", { accelKey: true }); michael@0: michael@0: // Check group two is active after a "switch to tab" action was executed and michael@0: // a new tab has been open. michael@0: is(contentWindow.GroupItems.getActiveGroupItem(), groupItemOne, michael@0: prefix + "The group one is the active group"); michael@0: michael@0: // Make sure the new tab is open in group one after the "switch to tab" action. michael@0: is(groupItemOne.getChildren().length, 3, michael@0: prefix + "The number of children in group one is 3"); michael@0: michael@0: // Verify there's only one tab in group two after the "switch to tab" action. michael@0: is(groupItemTwo.getChildren().length, 1, michael@0: prefix + "The number of children in group two is 1"); michael@0: michael@0: finish(); michael@0: }