Bug 462986 - Fix private browsing tests to pass on tinderbox (session store test); r=zeniko

This commit is contained in:
Ehsan Akhgari 2008-11-04 12:58:07 +03:30
Родитель d8ec7bcb09
Коммит 6de238934f
1 изменённых файлов: 46 добавлений и 42 удалений

Просмотреть файл

@ -82,61 +82,65 @@ function test() {
this.removeEventListener("load", arguments.callee, true);
let prePBModeTimeStamp = getSessionstorejsModificationTime();
// enter private browsing mode
pb.privateBrowsingEnabled = true;
ok(pb.privateBrowsingEnabled, "private browsing enabled");
// sessionstore.js should be modified at this point
/* XXX this strangely fails!
TODO filed bug 462986
isnot(prePBModeTimeStamp, getSessionstorejsModificationTime(),
"sessionstore.js should be modified when entering the private browsing mode");
*/
// make sure that the timestamp is bound to differ if sessionstore.js
// is modified when entering the private mode.
let timer = Cc["@mozilla.org/timer;1"].
createInstance(Ci.nsITimer);
timer.initWithCallback(function (aTimer) {
// enter private browsing mode
pb.privateBrowsingEnabled = true;
ok(pb.privateBrowsingEnabled, "private browsing enabled");
// record the time stamp of sessionstore.js in the private session
let startPBModeTimeStamp = getSessionstorejsModificationTime();
// sessionstore.js should be modified at this point
isnot(prePBModeTimeStamp, getSessionstorejsModificationTime(),
"sessionstore.js should be modified when entering the private browsing mode");
// private browsing session, add new tab: (B)
const testURL_B = "http://test1.example.org/";
let tab_B = gBrowser.addTab(testURL_B);
// record the time stamp of sessionstore.js in the private session
let startPBModeTimeStamp = getSessionstorejsModificationTime();
tab_B.linkedBrowser.addEventListener("load", function (aEvent) {
this.removeEventListener("load", arguments.callee, true);
// private browsing session, add new tab: (B)
const testURL_B = "http://test1.example.org/";
let tab_B = gBrowser.addTab(testURL_B);
// private browsing session, add new tab: (C)
const testURL_C = "http://localhost:8888/";
let tab_C = gBrowser.addTab(testURL_C);
tab_C.linkedBrowser.addEventListener("load", function (aEvent) {
tab_B.linkedBrowser.addEventListener("load", function (aEvent) {
this.removeEventListener("load", arguments.callee, true);
// private browsing session, close tab: (C)
gBrowser.removeTab(tab_C);
// private browsing session, add new tab: (C)
const testURL_C = "http://localhost:8888/";
let tab_C = gBrowser.addTab(testURL_C);
// private browsing session, close tab: (B)
gBrowser.removeTab(tab_B);
tab_C.linkedBrowser.addEventListener("load", function (aEvent) {
this.removeEventListener("load", arguments.callee, true);
// private browsing session, close tab: (A)
gBrowser.removeTab(tab_A);
// private browsing session, close tab: (C)
gBrowser.removeTab(tab_C);
// record the timestamp of sessionstore.js at the end of the private session
gPrefService.setIntPref("browser.sessionstore.interval", ss_interval);
gPrefService.setIntPref("browser.sessionstore.interval", 0);
let endPBModeTimeStamp = getSessionstorejsModificationTime();
// private browsing session, close tab: (B)
gBrowser.removeTab(tab_B);
// exit private browsing mode
pb.privateBrowsingEnabled = false;
ok(!pb.privateBrowsingEnabled, "private browsing disabled");
// private browsing session, close tab: (A)
gBrowser.removeTab(tab_A);
// compare timestamps: pre and post private browsing session
is(startPBModeTimeStamp, endPBModeTimeStamp,
"outside private browsing - sessionStore.js timestamp has not changed");
// record the timestamp of sessionstore.js at the end of the private session
gPrefService.setIntPref("browser.sessionstore.interval", ss_interval);
gPrefService.setIntPref("browser.sessionstore.interval", 0);
let endPBModeTimeStamp = getSessionstorejsModificationTime();
// cleanup
gPrefService.setIntPref("browser.sessionstore.interval", ss_interval);
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
finish();
// exit private browsing mode
pb.privateBrowsingEnabled = false;
ok(!pb.privateBrowsingEnabled, "private browsing disabled");
// compare timestamps: pre and post private browsing session
is(startPBModeTimeStamp, endPBModeTimeStamp,
"outside private browsing - sessionStore.js timestamp has not changed");
// cleanup
gPrefService.setIntPref("browser.sessionstore.interval", ss_interval);
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
finish();
}, true);
}, true);
}, true);
}, 50, Ci.nsITimer.TYPE_ONE_SHOT);
}, true);
}