Bug 567821 - Timeout in browser_privatebrowsing_downloadmonitor.js with bug 541739 landed; r=gavin

This commit is contained in:
Ehsan Akhgari 2010-05-25 20:33:26 -04:00
parent f6410e209a
commit 4afb409bce
2 changed files with 27 additions and 8 deletions

View File

@ -49,8 +49,19 @@ function test() {
let panel = document.getElementById("download-monitor");
waitForExplicitFinish();
let acceptDialog = 0;
let confirmCalls = 0;
function promptObserver(aSubject, aTopic, aData) {
let dialogWin = aSubject.QueryInterface(Ci.nsIDOMWindow);
confirmCalls++;
if (acceptDialog-- > 0)
dialogWin.document.documentElement.getButton("accept").click();
}
Services.obs.addObserver(promptObserver, "common-dialog-loaded", false);
// Add a new download
addDownload(dm, {
let [file, persist] = addDownload(dm, {
resultFileName: "pbtest-1",
downloadName: "PB Test 1"
});
@ -63,16 +74,19 @@ function test() {
ok(!panel.hidden, "The download panel should be successfully added initially");
// Enter the private browsing mode
acceptDialog = 1;
pb.privateBrowsingEnabled = true;
is(confirmCalls, 1, "One prompt was accepted");
ok(pb.privateBrowsingEnabled, "The private browsing transition was successful");
setTimeout(function () {
executeSoon(function () {
ok(panel.hidden, "The download panel should be hidden when entering the private browsing mode");
// Add a new download
let file = addDownload(dm, {
let [file2, persist2] = addDownload(dm, {
resultFileName: "pbtest-2",
downloadName: "PB Test 2"
}).targetFile;
});
// Update the panel
DownloadMonitorPanel.updateStatus();
@ -81,9 +95,12 @@ function test() {
ok(!panel.hidden, "The download panel should show up when a new download is added");
// Exit the private browsing mode
acceptDialog = 1;
pb.privateBrowsingEnabled = false;
is(confirmCalls, 2, "One prompt was accepted");
ok(!pb.privateBrowsingEnabled, "The private browsing transition was successful");
setTimeout(function () {
executeSoon(function () {
ok(panel.hidden, "The download panel should be hidden when leaving the private browsing mode");
// cleanup
@ -98,9 +115,10 @@ function test() {
if (file.exists())
file.remove(false);
Services.obs.removeObserver(promptObserver, "common-dialog-loaded", false);
finish();
}, 0);
}, 0);
});
});
}
/**
@ -154,7 +172,7 @@ function addDownload(dm, aParams)
persist.progressListener = dl.QueryInterface(Ci.nsIWebProgressListener);
persist.saveURI(dl.source, null, null, null, null, dl.targetFile);
return dl;
return [dl.targetFile, persist];
}
function createURI(aObj) {

View File

@ -55,5 +55,6 @@ function handleRequest(request, response) {
}
response.setHeader("Content-Type", "text/plain", false);
response.setHeader("Accept-Ranges", "none", false);
stall();
}