browser/components/sessionstore/test/browser_628270.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:45c1f463c010
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 function test() {
5 let assertNumberOfTabs = function (num, msg) {
6 is(gBrowser.tabs.length, num, msg);
7 }
8
9 let assertNumberOfVisibleTabs = function (num, msg) {
10 is(gBrowser.visibleTabs.length, num, msg);
11 }
12
13 let assertNumberOfPinnedTabs = function (num, msg) {
14 is(gBrowser._numPinnedTabs, num, msg);
15 }
16
17 waitForExplicitFinish();
18
19 // check prerequisites
20 assertNumberOfTabs(1, "we start off with one tab");
21
22 // setup
23 let tab = gBrowser.addTab("about:mozilla");
24
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");
31
32 // close and restore hidden tab
33 gBrowser.removeTab(tab);
34 tab = ss.undoCloseTab(window, 0);
35
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");
39
40 gBrowser.removeTab(tab);
41 finish();
42 });
43 });
44 }
45
46 function whenTabIsLoaded(tab, callback) {
47 tab.linkedBrowser.addEventListener("load", function onLoad() {
48 tab.linkedBrowser.removeEventListener("load", onLoad, true);
49 callback();
50 }, true);
51 }

mercurial