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.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 let prefsBranch = Cc["@mozilla.org/preferences-service;1"].
5 getService(Ci.nsIPrefService).
6 getBranch("browser.panorama.");
7 let originalPrefState;
9 function test() {
10 waitForExplicitFinish();
12 ok(!TabView.isVisible(), "Main window TabView is hidden");
14 originalPrefState = experienced();
16 prefsBranch.setBoolPref("experienced_first_run", false);
17 ok(!experienced(), "set to not experienced");
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");
24 newWindowWithTabView(checkNotFirstRun, endGame);
25 });
26 }
28 function experienced() {
29 return prefsBranch.prefHasUserValue("experienced_first_run") &&
30 prefsBranch.getBoolPref("experienced_first_run");
31 }
33 function checkFirstRun(win) {
34 let contentWindow = win.document.getElementById("tab-view").contentWindow;
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");
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");
43 ok(!experienced(), "we're not experienced");
44 }
46 function checkNotFirstRun(win) {
47 let contentWindow = win.document.getElementById("tab-view").contentWindow;
49 is(win.gBrowser.tabs.length, 1, "There should be one tab");
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 }
56 function endGame() {
57 ok(!TabView.isVisible(), "Main window TabView is still hidden");
58 ok(experienced(), "should finish as experienced");
60 prefsBranch.setBoolPref("experienced_first_run", originalPrefState);
62 finish();
63 }
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 }