|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 let prefsBranch = Cc["@mozilla.org/preferences-service;1"]. |
|
5 getService(Ci.nsIPrefService). |
|
6 getBranch("browser.panorama."); |
|
7 let originalPrefState; |
|
8 |
|
9 function test() { |
|
10 waitForExplicitFinish(); |
|
11 |
|
12 ok(!TabView.isVisible(), "Main window TabView is hidden"); |
|
13 |
|
14 originalPrefState = experienced(); |
|
15 |
|
16 prefsBranch.setBoolPref("experienced_first_run", false); |
|
17 ok(!experienced(), "set to not experienced"); |
|
18 |
|
19 newWindowWithTabView(checkFirstRun, function() { |
|
20 // open tabview doesn't count as first use experience so setting it manually |
|
21 prefsBranch.setBoolPref("experienced_first_run", true); |
|
22 ok(experienced(), "we're now experienced"); |
|
23 |
|
24 newWindowWithTabView(checkNotFirstRun, endGame); |
|
25 }); |
|
26 } |
|
27 |
|
28 function experienced() { |
|
29 return prefsBranch.prefHasUserValue("experienced_first_run") && |
|
30 prefsBranch.getBoolPref("experienced_first_run"); |
|
31 } |
|
32 |
|
33 function checkFirstRun(win) { |
|
34 let contentWindow = win.document.getElementById("tab-view").contentWindow; |
|
35 |
|
36 // Welcome tab disabled by bug 626754. To be fixed via bug 626926. |
|
37 is(win.gBrowser.tabs.length, 1, "There should be one tab"); |
|
38 |
|
39 let groupItems = contentWindow.GroupItems.groupItems; |
|
40 is(groupItems.length, 1, "There should be one group"); |
|
41 is(groupItems[0].getChildren().length, 1, "...with one child"); |
|
42 |
|
43 ok(!experienced(), "we're not experienced"); |
|
44 } |
|
45 |
|
46 function checkNotFirstRun(win) { |
|
47 let contentWindow = win.document.getElementById("tab-view").contentWindow; |
|
48 |
|
49 is(win.gBrowser.tabs.length, 1, "There should be one tab"); |
|
50 |
|
51 let groupItems = contentWindow.GroupItems.groupItems; |
|
52 is(groupItems.length, 1, "There should be one group"); |
|
53 is(groupItems[0].getChildren().length, 1, "...with one child"); |
|
54 } |
|
55 |
|
56 function endGame() { |
|
57 ok(!TabView.isVisible(), "Main window TabView is still hidden"); |
|
58 ok(experienced(), "should finish as experienced"); |
|
59 |
|
60 prefsBranch.setBoolPref("experienced_first_run", originalPrefState); |
|
61 |
|
62 finish(); |
|
63 } |
|
64 |
|
65 function newWindowWithTabView(callback, completeCallback) { |
|
66 let charsetArg = "charset=" + window.content.document.characterSet; |
|
67 let win = window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no,height=800,width=800", |
|
68 "about:blank", charsetArg, null, null, true); |
|
69 let onLoad = function() { |
|
70 win.removeEventListener("load", onLoad, false); |
|
71 let onShown = function() { |
|
72 win.removeEventListener("tabviewshown", onShown, false); |
|
73 callback(win); |
|
74 win.close(); |
|
75 if (typeof completeCallback == "function") |
|
76 completeCallback(); |
|
77 }; |
|
78 win.addEventListener("tabviewshown", onShown, false); |
|
79 win.TabView.toggle(); |
|
80 } |
|
81 win.addEventListener("load", onLoad, false); |
|
82 } |