test_bug1550815.js (927B)
1 // Test checks SIGBUS handling on Linux. The test cannot be used to check page 2 // error exception on Windows because the file cannot be truncated while it's 3 // being used by zipreader. 4 function run_test() { 5 var file = do_get_file("data/test_bug333423.zip"); 6 var tmpFile = do_get_tempdir(); 7 8 file.copyTo(tmpFile, "bug1550815.zip"); 9 tmpFile.append("bug1550815.zip"); 10 11 var zipReader = Cc["@mozilla.org/libjar/zip-reader;1"].createInstance( 12 Ci.nsIZipReader 13 ); 14 zipReader.open(tmpFile); 15 16 // Truncate the file 17 var ostream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance( 18 Ci.nsIFileOutputStream 19 ); 20 ostream.init(tmpFile, -1, -1, 0); 21 ostream.close(); 22 23 try { 24 zipReader.test("modules/libjar/test/Makefile.in"); 25 Assert.ok(false, "Should not reach here."); 26 } catch (e) { 27 Assert.equal(e.result, Cr.NS_ERROR_FILE_NOT_FOUND); 28 } 29 30 zipReader.close(); 31 tmpFile.remove(false); 32 }