browser/components/tabview/test/browser_tabview_bug631662.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:6b3a24cefc5e
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 function test() {
5 let cw;
6 let prefix;
7 let timestamp;
8
9 let storeTimestamp = function () {
10 timestamp = cw.TabItems._lastUpdateTime;
11 }
12
13 let checkTimestamp = function () {
14 is(timestamp, cw.TabItems._lastUpdateTime, prefix +
15 ": tabs were not updated");
16 }
17
18 let actionAddTab = function () {
19 storeTimestamp();
20 gBrowser.addTab("about:mozilla");
21
22 afterAllTabsLoaded(function () {
23 checkTimestamp();
24 next();
25 });
26 }
27
28 let actionMoveTab = function () {
29 storeTimestamp();
30 gBrowser.moveTabTo(gBrowser.tabs[0], 1);
31 gBrowser.moveTabTo(gBrowser.tabs[1], 0);
32 checkTimestamp();
33 next();
34 }
35
36 let actionSelectTab = function () {
37 storeTimestamp();
38 gBrowser.selectedTab = gBrowser.tabs[1]
39 gBrowser.selectedTab = gBrowser.tabs[0]
40 checkTimestamp();
41 next();
42 }
43
44 let actionRemoveTab = function () {
45 storeTimestamp();
46 gBrowser.removeTab(gBrowser.tabs[1]);
47 checkTimestamp();
48 next();
49 }
50
51 let actions = [
52 {name: "add", func: actionAddTab},
53 {name: "move", func: actionMoveTab},
54 {name: "select", func: actionSelectTab},
55 {name: "remove", func: actionRemoveTab}
56 ];
57
58 let next = function () {
59 let action = actions.shift();
60
61 if (action) {
62 prefix = action.name;
63 action.func();
64 } else {
65 finish();
66 }
67 }
68
69 waitForExplicitFinish();
70
71 showTabView(function () {
72 cw = TabView.getContentWindow();
73 hideTabView(next);
74 });
75 }

mercurial