Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | let contentWindow; |
michael@0 | 5 | |
michael@0 | 6 | function test() { |
michael@0 | 7 | requestLongerTimeout(2); |
michael@0 | 8 | waitForExplicitFinish(); |
michael@0 | 9 | |
michael@0 | 10 | showTabView(test1); |
michael@0 | 11 | } |
michael@0 | 12 | |
michael@0 | 13 | function test1() { |
michael@0 | 14 | ok(TabView.isVisible(), "Tab View is visible"); |
michael@0 | 15 | |
michael@0 | 16 | contentWindow = document.getElementById("tab-view").contentWindow; |
michael@0 | 17 | whenTabViewIsHidden(function() { |
michael@0 | 18 | ok(!TabView.isVisible(), "Tab View is not visible"); |
michael@0 | 19 | showTabView(test2); |
michael@0 | 20 | }); |
michael@0 | 21 | EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, contentWindow); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | function test2() { |
michael@0 | 25 | ok(TabView.isVisible(), "Tab View is visible"); |
michael@0 | 26 | |
michael@0 | 27 | whenSearchIsEnabled(function() { |
michael@0 | 28 | ok(contentWindow.Search.isEnabled(), "The search is enabled") |
michael@0 | 29 | |
michael@0 | 30 | whenSearchIsDisabled(test3); |
michael@0 | 31 | hideSearch(); |
michael@0 | 32 | }); |
michael@0 | 33 | EventUtils.synthesizeKey("f", { accelKey: true }, contentWindow); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function test3() { |
michael@0 | 37 | ok(!contentWindow.Search.isEnabled(), "The search is disabled") |
michael@0 | 38 | |
michael@0 | 39 | is(gBrowser.tabs.length, 1, "There is one tab before cmd/ctrl + t is pressed"); |
michael@0 | 40 | |
michael@0 | 41 | whenTabViewIsHidden(function() { |
michael@0 | 42 | is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + t is pressed"); |
michael@0 | 43 | |
michael@0 | 44 | gBrowser.tabs[0].linkedBrowser.loadURI("about:mozilla"); |
michael@0 | 45 | gBrowser.tabs[1].linkedBrowser.loadURI("http://example.com/"); |
michael@0 | 46 | |
michael@0 | 47 | afterAllTabsLoaded(function () { |
michael@0 | 48 | showTabView(test4); |
michael@0 | 49 | }); |
michael@0 | 50 | }); |
michael@0 | 51 | EventUtils.synthesizeKey("t", { accelKey: true }, contentWindow); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | function test4() { |
michael@0 | 55 | is(gBrowser.tabs.length, 2, "There are two tabs"); |
michael@0 | 56 | |
michael@0 | 57 | let onTabClose = function() { |
michael@0 | 58 | gBrowser.tabContainer.removeEventListener("TabClose", onTabClose, true); |
michael@0 | 59 | executeSoon(function() { |
michael@0 | 60 | is(gBrowser.tabs.length, 1, "There is one tab after removing one"); |
michael@0 | 61 | |
michael@0 | 62 | EventUtils.synthesizeKey("t", { accelKey: true, shiftKey: true }, contentWindow); |
michael@0 | 63 | is(gBrowser.tabs.length, 2, "There are two tabs after restoring one"); |
michael@0 | 64 | |
michael@0 | 65 | gBrowser.tabs[0].linkedBrowser.loadURI("about:blank"); |
michael@0 | 66 | gBrowser.selectedTab = gBrowser.tabs[0]; |
michael@0 | 67 | test8(); |
michael@0 | 68 | }); |
michael@0 | 69 | }; |
michael@0 | 70 | gBrowser.tabContainer.addEventListener("TabClose", onTabClose, true); |
michael@0 | 71 | gBrowser.removeTab(gBrowser.tabs[1]); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | // below key combination shouldn't trigger actions in tabview UI |
michael@0 | 75 | function test8() { |
michael@0 | 76 | showTabView(function() { |
michael@0 | 77 | is(gBrowser.tabs.length, 2, "There are two tabs before cmd/ctrl + w is pressed"); |
michael@0 | 78 | EventUtils.synthesizeKey("w", { accelKey: true }, contentWindow); |
michael@0 | 79 | is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + w is pressed"); |
michael@0 | 80 | |
michael@0 | 81 | gBrowser.removeTab(gBrowser.tabs[1]); |
michael@0 | 82 | test9(); |
michael@0 | 83 | }); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | function test9() { |
michael@0 | 87 | let zoomLevel = ZoomManager.zoom; |
michael@0 | 88 | EventUtils.synthesizeKey("+", { accelKey: true }, contentWindow); |
michael@0 | 89 | is(ZoomManager.zoom, zoomLevel, "The zoom level remains unchanged after cmd/ctrl + + is pressed"); |
michael@0 | 90 | |
michael@0 | 91 | EventUtils.synthesizeKey("-", { accelKey: true }, contentWindow); |
michael@0 | 92 | is(ZoomManager.zoom, zoomLevel, "The zoom level remains unchanged after cmd/ctrl + - is pressed"); |
michael@0 | 93 | |
michael@0 | 94 | test10(); |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | function test10() { |
michael@0 | 98 | is(gBrowser.tabs.length, 1, "There is one tab before cmd/ctrl + shift + a is pressed"); |
michael@0 | 99 | // it would open about:addons on a new tab if it passes through the white list. |
michael@0 | 100 | EventUtils.synthesizeKey("a", { accelKey: true, shiftKey: true }, contentWindow); |
michael@0 | 101 | |
michael@0 | 102 | executeSoon(function() { |
michael@0 | 103 | is(gBrowser.tabs.length, 1, "There is still one tab after cmd/ctrl + shift + a is pressed"); |
michael@0 | 104 | hideTabView(finish); |
michael@0 | 105 | }) |
michael@0 | 106 | } |