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: requestLongerTimeout(2); michael@0: waitForExplicitFinish(); michael@0: michael@0: showTabView(test1); michael@0: } michael@0: michael@0: function test1() { michael@0: ok(TabView.isVisible(), "Tab View is visible"); michael@0: michael@0: contentWindow = document.getElementById("tab-view").contentWindow; michael@0: whenTabViewIsHidden(function() { michael@0: ok(!TabView.isVisible(), "Tab View is not visible"); michael@0: showTabView(test2); michael@0: }); michael@0: EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, contentWindow); michael@0: } michael@0: michael@0: function test2() { michael@0: ok(TabView.isVisible(), "Tab View is visible"); michael@0: michael@0: whenSearchIsEnabled(function() { michael@0: ok(contentWindow.Search.isEnabled(), "The search is enabled") michael@0: michael@0: whenSearchIsDisabled(test3); michael@0: hideSearch(); michael@0: }); michael@0: EventUtils.synthesizeKey("f", { accelKey: true }, contentWindow); michael@0: } michael@0: michael@0: function test3() { michael@0: ok(!contentWindow.Search.isEnabled(), "The search is disabled") michael@0: michael@0: is(gBrowser.tabs.length, 1, "There is one tab before cmd/ctrl + t is pressed"); michael@0: michael@0: whenTabViewIsHidden(function() { michael@0: is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + t is pressed"); michael@0: michael@0: gBrowser.tabs[0].linkedBrowser.loadURI("about:mozilla"); michael@0: gBrowser.tabs[1].linkedBrowser.loadURI("http://example.com/"); michael@0: michael@0: afterAllTabsLoaded(function () { michael@0: showTabView(test4); michael@0: }); michael@0: }); michael@0: EventUtils.synthesizeKey("t", { accelKey: true }, contentWindow); michael@0: } michael@0: michael@0: function test4() { michael@0: is(gBrowser.tabs.length, 2, "There are two tabs"); michael@0: michael@0: let onTabClose = function() { michael@0: gBrowser.tabContainer.removeEventListener("TabClose", onTabClose, true); michael@0: executeSoon(function() { michael@0: is(gBrowser.tabs.length, 1, "There is one tab after removing one"); michael@0: michael@0: EventUtils.synthesizeKey("t", { accelKey: true, shiftKey: true }, contentWindow); michael@0: is(gBrowser.tabs.length, 2, "There are two tabs after restoring one"); michael@0: michael@0: gBrowser.tabs[0].linkedBrowser.loadURI("about:blank"); michael@0: gBrowser.selectedTab = gBrowser.tabs[0]; michael@0: test8(); michael@0: }); michael@0: }; michael@0: gBrowser.tabContainer.addEventListener("TabClose", onTabClose, true); michael@0: gBrowser.removeTab(gBrowser.tabs[1]); michael@0: } michael@0: michael@0: // below key combination shouldn't trigger actions in tabview UI michael@0: function test8() { michael@0: showTabView(function() { michael@0: is(gBrowser.tabs.length, 2, "There are two tabs before cmd/ctrl + w is pressed"); michael@0: EventUtils.synthesizeKey("w", { accelKey: true }, contentWindow); michael@0: is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + w is pressed"); michael@0: michael@0: gBrowser.removeTab(gBrowser.tabs[1]); michael@0: test9(); michael@0: }); michael@0: } michael@0: michael@0: function test9() { michael@0: let zoomLevel = ZoomManager.zoom; michael@0: EventUtils.synthesizeKey("+", { accelKey: true }, contentWindow); michael@0: is(ZoomManager.zoom, zoomLevel, "The zoom level remains unchanged after cmd/ctrl + + is pressed"); michael@0: michael@0: EventUtils.synthesizeKey("-", { accelKey: true }, contentWindow); michael@0: is(ZoomManager.zoom, zoomLevel, "The zoom level remains unchanged after cmd/ctrl + - is pressed"); michael@0: michael@0: test10(); michael@0: } michael@0: michael@0: function test10() { michael@0: is(gBrowser.tabs.length, 1, "There is one tab before cmd/ctrl + shift + a is pressed"); michael@0: // it would open about:addons on a new tab if it passes through the white list. michael@0: EventUtils.synthesizeKey("a", { accelKey: true, shiftKey: true }, contentWindow); michael@0: michael@0: executeSoon(function() { michael@0: is(gBrowser.tabs.length, 1, "There is still one tab after cmd/ctrl + shift + a is pressed"); michael@0: hideTabView(finish); michael@0: }) michael@0: }