Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 function test() {
5 let assertNumberOfTabs = function (num, msg) {
6 is(gBrowser.tabs.length, num, msg);
7 }
9 let assertNumberOfVisibleTabs = function (num, msg) {
10 is(gBrowser.visibleTabs.length, num, msg);
11 }
13 let assertNumberOfPinnedTabs = function (num, msg) {
14 is(gBrowser._numPinnedTabs, num, msg);
15 }
17 waitForExplicitFinish();
19 // check prerequisites
20 assertNumberOfTabs(1, "we start off with one tab");
22 // setup
23 let tab = gBrowser.addTab("about:mozilla");
25 whenTabIsLoaded(tab, function () {
26 // hide the newly created tab
27 assertNumberOfVisibleTabs(2, "there are two visible tabs");
28 gBrowser.showOnlyTheseTabs([gBrowser.tabs[0]]);
29 assertNumberOfVisibleTabs(1, "there is one visible tab");
30 ok(tab.hidden, "newly created tab is now hidden");
32 // close and restore hidden tab
33 gBrowser.removeTab(tab);
34 tab = ss.undoCloseTab(window, 0);
36 // check that everything was restored correctly, clean up and finish
37 whenTabIsLoaded(tab, function () {
38 is(tab.linkedBrowser.currentURI.spec, "about:mozilla", "restored tab has correct url");
40 gBrowser.removeTab(tab);
41 finish();
42 });
43 });
44 }
46 function whenTabIsLoaded(tab, callback) {
47 tab.linkedBrowser.addEventListener("load", function onLoad() {
48 tab.linkedBrowser.removeEventListener("load", onLoad, true);
49 callback();
50 }, true);
51 }