Bug 805712 - Try to fix Intermittent test_archivereader_zip_in_zip.html r=mounir

This commit is contained in:
Andrea Marchesini 2012-10-30 11:31:34 +01:00
parent 60a53499f4
commit df40ca231f

View File

@ -8,8 +8,14 @@
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<script type="text/javascript;version=1.7">
<body>
<p id="display">
<input id="fileList" type="file"></input>
</p>
<script type="text/javascript;version=1.7">
function createZipFileWithData(fileData) {
var Cc = SpecialPowers.Cc;
var Ci = SpecialPowers.Ci;
@ -48,6 +54,17 @@
return fileList.files[0];
}
handleFinished = 0;
function markTestDone() {
++handleFinished;
if (isFinished()) {
SimpleTest.finish();
}
}
function isFinished() {
return handleFinished == 5;
}
function testSteps()
{
var binaryString = '504B03040A00000000002E6BF14000000000000000000000000005001C00746573742F555409000337CA055039CA055075780B' +
@ -111,10 +128,12 @@
isnot(handle, null, "ArchiveReader.getFilenames() cannot be null");
handle.onsuccess = function() {
ok(false, "ArchiveReader.getFilenames() should return a 'failure' if the input file is not a zip");
markTestDone();
}
handle.onerror = function() {
ok(true, "ArchiveReader.getFilenames() should return a 'error' if the input file is a zip file");
is(this.reader, rt, "ArchiveRequest.reader == ArchiveReader");
markTestDone();
}
// Create - good!
@ -131,9 +150,11 @@
is(this.result[0], "test/a.txt", "ArchiveReader.getFilenames(): first file is 'test/a.txt'");
is(this.result[1], "test/b.txt", "ArchiveReader.getFilenames(): second file is 'test/b.txt'");
ok(this.reader, r, "ArchiveRequest.reader should be == ArchiveReader");
markTestDone();
}
handle.onerror = function() {
ok(false, "ArchiveReader.getFilenames() should not return any 'error'");
markTestDone();
}
// GetFile - wrong (no args)
@ -150,10 +171,12 @@
isnot(handle2, null, "ArchiveReader.getFile() cannot be null");
handle2.onsuccess = function() {
ok(false, "ArchiveReader.getFile('unknown file') should not return a 'success'");
markTestDone();
}
handle2.onerror = function() {
ok(true, "ArchiveReader.getFile('unknown file') should return an 'error'");
ok(this.reader, r, "ArchiveRequest.reader should be == ArchiveReader");
markTestDone();
}
var handle3 = r.getFile("test/b.txt");
@ -168,14 +191,17 @@
fr.readAsText(this.result);
fr.onerror = function() {
ok(false, "ArchiveReader + FileReader should work!");
markTestDone();
}
fr.onload = function(event) {
is(event.target.result, "hello world, 2!\n", "ArchiveReader + FileReader are working together.");
markTestDone();
}
}
handle3.onerror = function() {
ok(false, "ArchiveReader.getFile('test/b.txt') should not return an 'error'");
markTestDone();
}
var handle4 = r.getFile("test/a.txt");
@ -190,6 +216,7 @@
fr.readAsText(this.result);
fr.onerror = function() {
ok(false, "ArchiveReader + FileReader should work!");
markTestDone();
}
fr.onload = function(event) {
is(event.target.result.length, 600, "ArchiveReader + FileReader are working with a compress data");
@ -198,24 +225,18 @@
for (var i = 0; i < p.length; ++i)
is(p[i], "hello world", "ArchiveReader + FileReader are working with a compress data");
markTestDone();
}
}
handle4.onerror = function() {
ok(false, "ArchiveReader.getFile('test/a.txt') should not return an 'error'");
markTestDone();
}
finishTest();
yield;
}
SimpleTest.waitForExplicitFinish();
testSteps();
</script>
<script type="text/javascript;version=1.7" src="helpers.js"></script>
</head>
<body onload="runTest();">
<p id="display">
<input id="fileList" type="file"></input>
</p>
</body>
</html>