2011-02-27 17:36:36 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
2010-09-24 17:24:31 -07:00
|
|
|
|
2010-10-08 15:59:24 -07:00
|
|
|
let contentWindow = null;
|
2010-09-24 17:24:31 -07:00
|
|
|
let normalURLs = [];
|
|
|
|
let pbTabURL = "about:privatebrowsing";
|
2010-10-08 15:59:24 -07:00
|
|
|
let groupTitles = [];
|
|
|
|
let normalIteration = 0;
|
2010-09-24 17:24:31 -07:00
|
|
|
|
|
|
|
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
|
|
|
getService(Ci.nsIPrivateBrowsingService);
|
|
|
|
|
|
|
|
// -----------
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
2011-01-27 10:15:18 -08:00
|
|
|
showTabView(onTabViewLoadedAndShown);
|
2010-10-08 15:59:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------
|
|
|
|
function onTabViewLoadedAndShown() {
|
|
|
|
ok(TabView.isVisible(), "Tab View is visible");
|
|
|
|
|
2010-09-24 17:24:31 -07:00
|
|
|
// Establish initial state
|
2011-08-03 18:49:43 -07:00
|
|
|
contentWindow = TabView.getContentWindow();
|
2010-10-08 15:59:24 -07:00
|
|
|
verifyCleanState("start");
|
2011-06-16 22:05:30 -07:00
|
|
|
|
2010-10-08 15:59:24 -07:00
|
|
|
// register a clean up for private browsing just in case
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
pb.privateBrowsingEnabled = false;
|
|
|
|
});
|
2011-06-16 22:05:30 -07:00
|
|
|
|
2010-10-08 15:59:24 -07:00
|
|
|
// create a group
|
|
|
|
let box = new contentWindow.Rect(20, 20, 180, 180);
|
|
|
|
let groupItem = new contentWindow.GroupItem([], {bounds: box, title: "test1"});
|
2011-06-16 22:05:30 -07:00
|
|
|
let id = groupItem.id;
|
2010-10-08 15:59:24 -07:00
|
|
|
is(contentWindow.GroupItems.groupItems.length, 2, "we now have two groups");
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
contentWindow.GroupItems.groupItem(id).close();
|
|
|
|
});
|
2011-06-16 22:05:30 -07:00
|
|
|
|
2010-10-08 15:59:24 -07:00
|
|
|
// make it the active group so new tabs will be added to it
|
2011-04-22 13:05:11 -07:00
|
|
|
contentWindow.UI.setActive(groupItem);
|
2011-06-16 22:05:30 -07:00
|
|
|
|
2010-10-08 15:59:24 -07:00
|
|
|
// collect the group titles
|
|
|
|
let count = contentWindow.GroupItems.groupItems.length;
|
|
|
|
for (let a = 0; a < count; a++) {
|
|
|
|
let gi = contentWindow.GroupItems.groupItems[a];
|
|
|
|
groupTitles[a] = gi.getTitle();
|
|
|
|
}
|
2011-06-16 22:05:30 -07:00
|
|
|
|
2011-08-16 02:06:14 -07:00
|
|
|
contentWindow.gPrefBranch.setBoolPref("animate_zoom", false);
|
|
|
|
|
2010-09-24 17:24:31 -07:00
|
|
|
// Create a second tab
|
2011-08-03 18:49:43 -07:00
|
|
|
gBrowser.addTab("about:robots");
|
2010-09-24 17:24:31 -07:00
|
|
|
is(gBrowser.tabs.length, 2, "we now have 2 tabs");
|
2011-08-16 02:06:14 -07:00
|
|
|
|
2010-10-08 15:59:24 -07:00
|
|
|
registerCleanupFunction(function() {
|
|
|
|
gBrowser.removeTab(gBrowser.tabs[1]);
|
2011-08-16 02:06:14 -07:00
|
|
|
contentWindow.gPrefBranch.clearUserPref("animate_zoom");
|
2010-10-08 15:59:24 -07:00
|
|
|
});
|
|
|
|
|
2010-09-24 17:24:31 -07:00
|
|
|
afterAllTabsLoaded(function() {
|
2011-08-03 18:49:43 -07:00
|
|
|
// Get normal tab urls
|
|
|
|
for (let a = 0; a < gBrowser.tabs.length; a++)
|
|
|
|
normalURLs.push(gBrowser.tabs[a].linkedBrowser.currentURI.spec);
|
2010-09-24 17:24:31 -07:00
|
|
|
|
2011-08-03 18:49:43 -07:00
|
|
|
// verify that we're all set up for our test
|
|
|
|
verifyNormal();
|
2011-06-16 22:05:30 -07:00
|
|
|
|
2011-08-03 18:49:43 -07:00
|
|
|
// go into private browsing and make sure Tab View becomes hidden
|
2011-08-09 10:13:53 -07:00
|
|
|
togglePrivateBrowsing(function() {
|
2011-08-03 18:49:43 -07:00
|
|
|
whenTabViewIsHidden(function() {
|
|
|
|
ok(!TabView.isVisible(), "Tab View is no longer visible");
|
|
|
|
verifyPB();
|
2011-01-27 10:15:18 -08:00
|
|
|
|
2011-08-03 18:49:43 -07:00
|
|
|
// exit private browsing and make sure Tab View is shown again
|
2011-08-09 10:13:53 -07:00
|
|
|
togglePrivateBrowsing(function() {
|
2011-08-03 18:49:43 -07:00
|
|
|
whenTabViewIsShown(function() {
|
|
|
|
ok(TabView.isVisible(), "Tab View is visible again");
|
|
|
|
verifyNormal();
|
2011-06-16 22:05:30 -07:00
|
|
|
|
2011-08-03 18:49:43 -07:00
|
|
|
hideTabView(onTabViewHidden);
|
2011-06-16 22:05:30 -07:00
|
|
|
});
|
|
|
|
});
|
2011-01-27 10:15:18 -08:00
|
|
|
});
|
2011-08-03 18:49:43 -07:00
|
|
|
});
|
2010-09-24 17:24:31 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------
|
|
|
|
function onTabViewHidden() {
|
|
|
|
ok(!TabView.isVisible(), "Tab View is not visible");
|
|
|
|
|
|
|
|
// go into private browsing and make sure Tab View remains hidden
|
2011-08-09 10:13:53 -07:00
|
|
|
togglePrivateBrowsing(function() {
|
2010-10-20 13:06:44 -07:00
|
|
|
ok(!TabView.isVisible(), "Tab View is still not visible");
|
2010-09-24 17:24:31 -07:00
|
|
|
verifyPB();
|
|
|
|
|
|
|
|
// turn private browsing back off
|
2011-08-09 10:13:53 -07:00
|
|
|
togglePrivateBrowsing(function() {
|
2010-09-24 17:24:31 -07:00
|
|
|
verifyNormal();
|
|
|
|
|
2010-10-08 15:59:24 -07:00
|
|
|
// end game
|
2010-09-24 17:24:31 -07:00
|
|
|
ok(!TabView.isVisible(), "we finish with Tab View not visible");
|
2010-10-08 15:59:24 -07:00
|
|
|
registerCleanupFunction(verifyCleanState); // verify after all cleanups
|
2011-08-03 18:49:38 -07:00
|
|
|
|
|
|
|
gBrowser.selectedTab = gBrowser.tabs[0];
|
2010-09-24 17:24:31 -07:00
|
|
|
finish();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-10-08 15:59:24 -07:00
|
|
|
// ----------
|
|
|
|
function verifyCleanState(mode) {
|
|
|
|
let prefix = "we " + (mode || "finish") + " with ";
|
|
|
|
is(gBrowser.tabs.length, 1, prefix + "one tab");
|
|
|
|
is(contentWindow.GroupItems.groupItems.length, 1, prefix + "1 group");
|
2011-01-11 00:20:08 -08:00
|
|
|
ok(gBrowser.tabs[0]._tabViewTabItem.parent == contentWindow.GroupItems.groupItems[0],
|
2010-10-08 15:59:24 -07:00
|
|
|
"the tab is in the group");
|
|
|
|
ok(!pb.privateBrowsingEnabled, prefix + "private browsing off");
|
|
|
|
}
|
|
|
|
|
2010-09-24 17:24:31 -07:00
|
|
|
// ----------
|
|
|
|
function verifyPB() {
|
|
|
|
ok(pb.privateBrowsingEnabled == true, "private browsing is on");
|
|
|
|
is(gBrowser.tabs.length, 1, "we have 1 tab in private browsing");
|
2010-10-08 15:59:24 -07:00
|
|
|
is(contentWindow.GroupItems.groupItems.length, 1, "we have 1 group in private browsing");
|
2011-01-11 00:20:08 -08:00
|
|
|
ok(gBrowser.tabs[0]._tabViewTabItem.parent == contentWindow.GroupItems.groupItems[0],
|
2010-10-08 15:59:24 -07:00
|
|
|
"the tab is in the group");
|
2010-09-24 17:24:31 -07:00
|
|
|
|
|
|
|
let browser = gBrowser.tabs[0].linkedBrowser;
|
|
|
|
is(browser.currentURI.spec, pbTabURL, "correct URL for private browsing");
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
function verifyNormal() {
|
2010-10-08 15:59:24 -07:00
|
|
|
let prefix = "verify normal " + normalIteration + ": ";
|
|
|
|
normalIteration++;
|
|
|
|
|
|
|
|
ok(pb.privateBrowsingEnabled == false, prefix + "private browsing is off");
|
|
|
|
|
|
|
|
let tabCount = gBrowser.tabs.length;
|
|
|
|
let groupCount = contentWindow.GroupItems.groupItems.length;
|
|
|
|
is(tabCount, 2, prefix + "we have 2 tabs");
|
|
|
|
is(groupCount, 2, prefix + "we have 2 groups");
|
|
|
|
ok(tabCount == groupCount, prefix + "same number of tabs as groups");
|
|
|
|
for (let a = 0; a < tabCount; a++) {
|
|
|
|
let tab = gBrowser.tabs[a];
|
|
|
|
is(tab.linkedBrowser.currentURI.spec, normalURLs[a],
|
|
|
|
prefix + "correct URL");
|
|
|
|
|
|
|
|
let groupItem = contentWindow.GroupItems.groupItems[a];
|
|
|
|
is(groupItem.getTitle(), groupTitles[a], prefix + "correct group title");
|
|
|
|
|
2011-01-11 00:20:08 -08:00
|
|
|
ok(tab._tabViewTabItem.parent == groupItem,
|
2010-10-08 15:59:24 -07:00
|
|
|
prefix + "tab " + a + " is in group " + a);
|
2010-09-24 17:24:31 -07:00
|
|
|
}
|
|
|
|
}
|