Temporary debugging patch to try and get to the bottom of the test_sleep_wake failures (bug 431745)

This commit is contained in:
Gavin Sharp 2008-07-06 18:39:37 -04:00
parent 7267233b08
commit d2915d5735
2 changed files with 16 additions and 1 deletions

View File

@ -61,6 +61,7 @@ function run_test()
Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch).
setIntPref("browser.download.manager.resumeOnWakeDelay", 1000);
dump("%%%Set pref\n");
/**
* 1. Create data for http server to send
@ -70,6 +71,7 @@ function run_test()
// data * 10^4 = 100,000 bytes (actually 101,111 bytes with newline)
for (let i = 0; i < 4; i++)
data = [data,data,data,data,data,data,data,data,data,data,"\n"].join("");
dump("%%%Generated data\n");
/**
* 2. Start the http server that can handle resume
@ -99,6 +101,7 @@ function run_test()
resp.bodyOutputStream.write(body, body.length);
});
httpserv.start(4444);
dump("%%%Started server\n");
/**
* 3. Perform various actions for certain download states
@ -107,17 +110,21 @@ function run_test()
let didResumeDownload = false;
dm.addListener({
onDownloadStateChange: function(a, aDl) {
dump("%%%onDownloadStateChange\n");
if (aDl.state == nsIDM.DOWNLOAD_DOWNLOADING && !didPause) {
dump("%%%aDl.state: DOWNLOAD_DOWNLOADING\n");
/**
* (1) queued -> downloading = pause the download with sleep
*/
notify("sleep_notification");
} else if (aDl.state == nsIDM.DOWNLOAD_PAUSED) {
dump("%%%aDl.state: DOWNLOAD_PAUSED\n");
/**
* (2) downloading -> paused
*/
didPause = true;
} else if (aDl.state == nsIDM.DOWNLOAD_FINISHED) {
dump("%%%aDl.state: DOWNLOAD_FINISHED\n");
/**
* (4) downloading (resumed) -> finished = check tests
*/
@ -135,6 +142,7 @@ function run_test()
}
},
onStateChange: function(a, b, aState, d, aDl) {
dump("%%%onStateChange\n");
if ((aState & nsIWPL.STATE_STOP) && didPause && !didResumeServer &&
!didResumeDownload) {
/**
@ -148,6 +156,7 @@ function run_test()
onSecurityChange: function(a, b, c, d) { }
});
dm.addListener(getDownloadListener());
dump("%%%Added listener\n");
/**
* 4. Start the download
@ -168,4 +177,5 @@ function run_test()
// Mark as pending, so clear this when we actually finish the download
do_test_pending();
dump("%%%Started test\n");
}

View File

@ -111,7 +111,12 @@ done
for t in $testdir/test_*.js
do
echo -n "$t: "
NATIVE_TOPSRCDIR="$native_topsrcdir" TOPSRCDIR="$topsrcdir" $xpcshell -s $headfiles -f $t $tailfiles 2> $t.log 1>&2
if [ `echo $t | grep -c 'test_sleep_wake.js'` != 0 ]
then
NATIVE_TOPSRCDIR="$native_topsrcdir" TOPSRCDIR="$topsrcdir" $xpcshell -s $headfiles -f $t $tailfiles
else
NATIVE_TOPSRCDIR="$native_topsrcdir" TOPSRCDIR="$topsrcdir" $xpcshell -s $headfiles -f $t $tailfiles 2> $t.log 1>&2
fi
rv="$?"
if [ ! "$rv" = "0" -o \
`grep -c '\*\*\* PASS' $t.log` = 0 ]