intl/uconv/tests/unit/test_bug321379.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial