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 | function test() { |
michael@0 | 5 | let assertNumberOfTabs = function (num, msg) { |
michael@0 | 6 | is(gBrowser.tabs.length, num, msg); |
michael@0 | 7 | } |
michael@0 | 8 | |
michael@0 | 9 | let assertNumberOfVisibleTabs = function (num, msg) { |
michael@0 | 10 | is(gBrowser.visibleTabs.length, num, msg); |
michael@0 | 11 | } |
michael@0 | 12 | |
michael@0 | 13 | let assertNumberOfPinnedTabs = function (num, msg) { |
michael@0 | 14 | is(gBrowser._numPinnedTabs, num, msg); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | waitForExplicitFinish(); |
michael@0 | 18 | |
michael@0 | 19 | // check prerequisites |
michael@0 | 20 | assertNumberOfTabs(1, "we start off with one tab"); |
michael@0 | 21 | |
michael@0 | 22 | // setup |
michael@0 | 23 | let tab = gBrowser.addTab("about:mozilla"); |
michael@0 | 24 | |
michael@0 | 25 | whenTabIsLoaded(tab, function () { |
michael@0 | 26 | // hide the newly created tab |
michael@0 | 27 | assertNumberOfVisibleTabs(2, "there are two visible tabs"); |
michael@0 | 28 | gBrowser.showOnlyTheseTabs([gBrowser.tabs[0]]); |
michael@0 | 29 | assertNumberOfVisibleTabs(1, "there is one visible tab"); |
michael@0 | 30 | ok(tab.hidden, "newly created tab is now hidden"); |
michael@0 | 31 | |
michael@0 | 32 | // close and restore hidden tab |
michael@0 | 33 | gBrowser.removeTab(tab); |
michael@0 | 34 | tab = ss.undoCloseTab(window, 0); |
michael@0 | 35 | |
michael@0 | 36 | // check that everything was restored correctly, clean up and finish |
michael@0 | 37 | whenTabIsLoaded(tab, function () { |
michael@0 | 38 | is(tab.linkedBrowser.currentURI.spec, "about:mozilla", "restored tab has correct url"); |
michael@0 | 39 | |
michael@0 | 40 | gBrowser.removeTab(tab); |
michael@0 | 41 | finish(); |
michael@0 | 42 | }); |
michael@0 | 43 | }); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function whenTabIsLoaded(tab, callback) { |
michael@0 | 47 | tab.linkedBrowser.addEventListener("load", function onLoad() { |
michael@0 | 48 | tab.linkedBrowser.removeEventListener("load", onLoad, true); |
michael@0 | 49 | callback(); |
michael@0 | 50 | }, true); |
michael@0 | 51 | } |