2014-06-25 09:12:07 +04:00
|
|
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
2007-01-29 23:08:50 +03:00
|
|
|
/* vim:set ts=2 sw=2 sts=2 et: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-01-29 23:08:50 +03:00
|
|
|
|
2015-10-07 15:03:21 +03:00
|
|
|
var Cc = Components.classes;
|
|
|
|
var Ci = Components.interfaces;
|
|
|
|
var Cr = Components.results;
|
|
|
|
var CC = Components.Constructor;
|
2007-03-25 11:31:45 +04:00
|
|
|
|
|
|
|
var Pipe = CC("@mozilla.org/pipe;1", "nsIPipe", "init");
|
2007-01-29 23:08:50 +03:00
|
|
|
|
2017-09-29 01:49:04 +03:00
|
|
|
function run_test() {
|
2007-01-29 23:08:50 +03:00
|
|
|
test_not_initialized();
|
2007-03-25 11:31:45 +04:00
|
|
|
test_ends_are_threadsafe();
|
2007-01-29 23:08:50 +03:00
|
|
|
}
|
|
|
|
|
2017-09-29 01:49:04 +03:00
|
|
|
function test_not_initialized() {
|
2007-01-29 23:08:50 +03:00
|
|
|
var p = Cc["@mozilla.org/pipe;1"]
|
|
|
|
.createInstance(Ci.nsIPipe);
|
2017-09-29 01:49:04 +03:00
|
|
|
try {
|
2007-01-29 23:08:50 +03:00
|
|
|
var dummy = p.outputStream;
|
2017-09-29 02:12:52 +03:00
|
|
|
dump("dummy: " + dummy + "\n");
|
2007-01-29 23:08:50 +03:00
|
|
|
throw Cr.NS_ERROR_FAILURE;
|
2017-09-29 01:49:04 +03:00
|
|
|
} catch (e) {
|
2007-01-29 23:08:50 +03:00
|
|
|
if (e.result != Cr.NS_ERROR_NOT_INITIALIZED)
|
|
|
|
do_throw("using a pipe before initializing it should throw NS_ERROR_NOT_INITIALIZED");
|
|
|
|
}
|
|
|
|
}
|
2007-03-25 11:31:45 +04:00
|
|
|
|
2017-09-29 01:49:04 +03:00
|
|
|
function test_ends_are_threadsafe() {
|
2007-03-25 11:31:45 +04:00
|
|
|
var p, is, os;
|
|
|
|
|
|
|
|
p = new Pipe(true, true, 1024, 1, null);
|
|
|
|
is = p.inputStream.QueryInterface(Ci.nsIClassInfo);
|
|
|
|
os = p.outputStream.QueryInterface(Ci.nsIClassInfo);
|
|
|
|
do_check_true(Boolean(is.flags & Ci.nsIClassInfo.THREADSAFE));
|
|
|
|
do_check_true(Boolean(os.flags & Ci.nsIClassInfo.THREADSAFE));
|
|
|
|
|
|
|
|
p = new Pipe(true, false, 1024, 1, null);
|
|
|
|
is = p.inputStream.QueryInterface(Ci.nsIClassInfo);
|
|
|
|
os = p.outputStream.QueryInterface(Ci.nsIClassInfo);
|
|
|
|
do_check_true(Boolean(is.flags & Ci.nsIClassInfo.THREADSAFE));
|
|
|
|
do_check_true(Boolean(os.flags & Ci.nsIClassInfo.THREADSAFE));
|
|
|
|
|
|
|
|
p = new Pipe(false, true, 1024, 1, null);
|
|
|
|
is = p.inputStream.QueryInterface(Ci.nsIClassInfo);
|
|
|
|
os = p.outputStream.QueryInterface(Ci.nsIClassInfo);
|
|
|
|
do_check_true(Boolean(is.flags & Ci.nsIClassInfo.THREADSAFE));
|
|
|
|
do_check_true(Boolean(os.flags & Ci.nsIClassInfo.THREADSAFE));
|
|
|
|
|
|
|
|
p = new Pipe(false, false, 1024, 1, null);
|
|
|
|
is = p.inputStream.QueryInterface(Ci.nsIClassInfo);
|
|
|
|
os = p.outputStream.QueryInterface(Ci.nsIClassInfo);
|
|
|
|
do_check_true(Boolean(is.flags & Ci.nsIClassInfo.THREADSAFE));
|
|
|
|
do_check_true(Boolean(os.flags & Ci.nsIClassInfo.THREADSAFE));
|
|
|
|
}
|