summaryrefslogtreecommitdiffstats
path: root/intl/uconv/tests/unit/test_bug321379.js
blob: 2493e82dc8352644f4151c792c98d011ae5c3683 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Tests that calling close on a converter in/output stream doesn't crash
// (bug 321379)

function run_test() {
  var StorageStream = Components.Constructor("@mozilla.org/storagestream;1",
                                             "nsIStorageStream",
                                             "init");
  var ConverterInputStream = Components.Constructor("@mozilla.org/intl/converter-input-stream;1",
                                                    "nsIConverterInputStream",
                                                    "init");
  var ConverterOutputStream = Components.Constructor("@mozilla.org/intl/converter-output-stream;1",
                                                     "nsIConverterOutputStream",
                                                     "init");



  var storage = new StorageStream(1024, -1, null);

  // Output
  var outStr = storage.getOutputStream(0);
  var out = new ConverterOutputStream(outStr, "UTF-8", 1024, 0xFFFD);
  out.writeString("Foo.");
  out.close();
  out.close(); // This line should not crash. It should just do nothing.

  // Input
  var inStr = storage.newInputStream(0);
  var inp = new ConverterInputStream(inStr, "UTF-8", 1024, 0xFFFD);
  inp.close();
  inp.close(); // This line should not crash. It should just do nothing.
}