test_stringstream.js 785 B

123456789101112131415161718192021222324
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. var Cc = Components.classes;
  6. var Ci = Components.interfaces;
  7. var Cr = Components.results;
  8. function run_test()
  9. {
  10. var s = Cc["@mozilla.org/io/string-input-stream;1"]
  11. .createInstance(Ci.nsIStringInputStream);
  12. var body = "This is a test";
  13. s.setData(body, body.length);
  14. do_check_eq(s.available(), body.length);
  15. var sis = Cc["@mozilla.org/scriptableinputstream;1"]
  16. .createInstance(Ci.nsIScriptableInputStream);
  17. sis.init(s);
  18. do_check_eq(sis.read(body.length), body);
  19. }