Bug 637232 - Update browser_tabview_firstrun_pref.js to test the existing behavior [r=ian,a=test]

This commit is contained in:
Raymond Lee 2011-03-08 03:45:34 +08:00
parent cc1c88b8ef
commit fe2ad435e8
2 changed files with 17 additions and 10 deletions

View File

@ -123,6 +123,7 @@ _BROWSER_FILES = \
browser_tabview_dragdrop.js \
browser_tabview_exit_button.js \
browser_tabview_expander.js \
browser_tabview_firstrun_pref.js \
browser_tabview_group.js \
browser_tabview_launch.js \
browser_tabview_multiwindow_search.js \

View File

@ -1,21 +1,28 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
var prefsBranch = Cc["@mozilla.org/preferences-service;1"].
let prefsBranch = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService).
getBranch("browser.panorama.");
let originalPrefState;
function test() {
waitForExplicitFinish();
ok(!TabView.isVisible(), "Main window TabView is hidden");
ok(experienced(), "should start as experienced");
originalPrefState = experienced();
prefsBranch.setBoolPref("experienced_first_run", false);
ok(!experienced(), "set to not experienced");
newWindowWithTabView(checkFirstRun, part2);
newWindowWithTabView(checkFirstRun, function() {
// open tabview doesn't count as first use experience so setting it manually
prefsBranch.setBoolPref("experienced_first_run", true);
ok(experienced(), "we're now experienced");
newWindowWithTabView(checkNotFirstRun, endGame);
});
}
function experienced() {
@ -27,7 +34,7 @@ function checkFirstRun(win) {
let contentWindow = win.document.getElementById("tab-view").contentWindow;
// Welcome tab disabled by bug 626754. To be fixed via bug 626926.
todo_is(win.gBrowser.tabs.length, 2, "There should be two tabs");
is(win.gBrowser.tabs.length, 1, "There should be one tab");
let groupItems = contentWindow.GroupItems.groupItems;
is(groupItems.length, 1, "There should be one group");
@ -35,13 +42,9 @@ function checkFirstRun(win) {
let orphanTabCount = contentWindow.GroupItems.getOrphanedTabs().length;
// Welcome tab disabled by bug 626754. To be fixed via bug 626926.
todo_is(orphanTabCount, 1, "There should also be an orphaned tab");
ok(experienced(), "we're now experienced");
}
is(orphanTabCount, 0, "There should also be no orphaned tabs");
function part2() {
newWindowWithTabView(checkNotFirstRun, endGame);
ok(!experienced(), "we're not experienced");
}
function checkNotFirstRun(win) {
@ -60,6 +63,9 @@ function checkNotFirstRun(win) {
function endGame() {
ok(!TabView.isVisible(), "Main window TabView is still hidden");
ok(experienced(), "should finish as experienced");
prefsBranch.setBoolPref("experienced_first_run", originalPrefState);
finish();
}