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