зеркало из https://github.com/mozilla/gecko-dev.git
Bug 431745 - qm-centos5-02 is intermittently failing test_sleep_wake.js
This makes the test not fail if a specific failure point is met that can occur when test execution is slow (like the tinderbox). r=gavin
This commit is contained in:
Родитель
5cf0edfc65
Коммит
bc37ca7855
|
@ -39,6 +39,12 @@
|
|||
* wake notifications by pausing and resuming downloads.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Used to indicate if we should error out or not. See bug 431745 for more
|
||||
* details.
|
||||
*/
|
||||
let doNotError = false;
|
||||
|
||||
const nsIF = Ci.nsIFile;
|
||||
const nsIDM = Ci.nsIDownloadManager;
|
||||
const nsIWBP = Ci.nsIWebBrowserPersist;
|
||||
|
@ -61,7 +67,6 @@ 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
|
||||
|
@ -71,7 +76,6 @@ dump("%%%Set pref\n");
|
|||
// 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
|
||||
|
@ -88,14 +92,11 @@ dump("%%%Generated data\n");
|
|||
let matches = meta.getHeader("Range").match(/^\s*bytes=(\d+)?-(\d+)?\s*$/);
|
||||
let from = (matches[1] === undefined) ? 0 : matches[1];
|
||||
let to = (matches[2] === undefined) ? data.length - 1 : matches[2];
|
||||
dump("%%%meta.getHeader('Range'): " + meta.getHeader("Range") + "\n");
|
||||
dump("%%%from: " + from + "\n");
|
||||
dump("%%%to: " + to + "\n");
|
||||
dump("%%%data.length: " + data.length + "\n");
|
||||
if (from >= data.length) {
|
||||
resp.setStatusLine(meta.httpVersion, 416, "Start pos too high");
|
||||
resp.setHeader("Content-Range", "*/" + data.length);
|
||||
dump("%%% Returning early - from >= data.length\n");
|
||||
dump("Returning early - from >= data.length. Not an error (bug 431745)\n");
|
||||
doNotError = true;
|
||||
return;
|
||||
}
|
||||
body = body.substring(from, to + 1);
|
||||
|
@ -106,7 +107,6 @@ dump("%%% Returning early - from >= data.length\n");
|
|||
resp.bodyOutputStream.write(body, body.length);
|
||||
});
|
||||
httpserv.start(4444);
|
||||
dump("%%%Started server\n");
|
||||
|
||||
/**
|
||||
* 3. Perform various actions for certain download states
|
||||
|
@ -115,21 +115,17 @@ dump("%%%Started server\n");
|
|||
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
|
||||
*/
|
||||
|
@ -144,13 +140,16 @@ dump("%%%aDl.state: DOWNLOAD_FINISHED\n");
|
|||
aDl.targetFile.remove(false);
|
||||
// we're done with the test!
|
||||
do_test_finished();
|
||||
} else
|
||||
dump("%%%aDl.state: " + aDl.state + "\n");
|
||||
}
|
||||
else if (aDl.state == nsIDM.DOWNLOAD_FAILED) {
|
||||
// this is only ok if we are not supposed to fail
|
||||
do_check_true(doNotError);
|
||||
httpserv.stop();
|
||||
// we're done with the test!
|
||||
do_test_finished();
|
||||
}
|
||||
},
|
||||
onStateChange: function(a, b, aState, d, aDl) {
|
||||
dump("%%%onStateChange\n");
|
||||
dump("%%%aState: " + aState + "\n");
|
||||
dump("%%%status: " + d + "\n");
|
||||
if ((aState & nsIWPL.STATE_STOP) && didPause && !didResumeServer &&
|
||||
!didResumeDownload) {
|
||||
/**
|
||||
|
@ -164,7 +163,6 @@ dump("%%%status: " + d + "\n");
|
|||
onSecurityChange: function(a, b, c, d) { }
|
||||
});
|
||||
dm.addListener(getDownloadListener());
|
||||
dump("%%%Added listener\n");
|
||||
|
||||
/**
|
||||
* 4. Start the download
|
||||
|
@ -185,5 +183,4 @@ dump("%%%Added listener\n");
|
|||
|
||||
// Mark as pending, so clear this when we actually finish the download
|
||||
do_test_pending();
|
||||
dump("%%%Started test\n");
|
||||
}
|
||||
|
|
|
@ -111,10 +111,6 @@ done
|
|||
for t in $testdir/test_*.js
|
||||
do
|
||||
echo -n "$t: "
|
||||
if [ `echo $t | grep -c 'test_sleep_wake.js'` != 0 ]
|
||||
then
|
||||
NATIVE_TOPSRCDIR="$native_topsrcdir" TOPSRCDIR="$topsrcdir" NSPR_LOG_MODULES="nsHttp:5" $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="$?"
|
||||
|
|
Загрузка…
Ссылка в новой задаче