test_bug321379.js (1028B)
1 // Tests that calling close on a converter in/output stream doesn't crash 2 // (bug 321379) 3 4 function run_test() { 5 var StorageStream = Components.Constructor( 6 "@mozilla.org/storagestream;1", 7 "nsIStorageStream", 8 "init" 9 ); 10 var ConverterInputStream = Components.Constructor( 11 "@mozilla.org/intl/converter-input-stream;1", 12 "nsIConverterInputStream", 13 "init" 14 ); 15 var ConverterOutputStream = Components.Constructor( 16 "@mozilla.org/intl/converter-output-stream;1", 17 "nsIConverterOutputStream", 18 "init" 19 ); 20 21 var storage = new StorageStream(1024, -1, null); 22 23 // Output 24 var outStr = storage.getOutputStream(0); 25 var out = new ConverterOutputStream(outStr, "UTF-8"); 26 out.writeString("Foo."); 27 out.close(); 28 out.close(); // This line should not crash. It should just do nothing. 29 30 // Input 31 var inStr = storage.newInputStream(0); 32 var inp = new ConverterInputStream(inStr, "UTF-8", 1024, 0xfffd); 33 inp.close(); 34 inp.close(); // This line should not crash. It should just do nothing. 35 }