blob: bb00545c3abda632db93980c2de2fae9e2f6b148 [file] [log] [blame]
<!DOCTYPE html>
<script src='../resources/testharness.js'></script>
<script src='../resources/testharnessreport.js'></script>
<script>
test(function() {
assert_throws(new TypeError(), function() {
new ReadableStream('potato');
});
var x
assert_throws(new TypeError(), function() {
new ReadableStream(x);
});
assert_throws(new TypeError(), function() {
new ReadableStream(null);
});
}, 'ReadableStream constructor should get an object as argument');
test(function() {
new ReadableStream();
}, 'ReadableStream can be constructed with no arguments');
test(function() {
rs = new ReadableStream();
assert_array_equals(Object.getOwnPropertyNames(rs), []);
assert_array_equals(Object.getOwnPropertyNames(Object.getPrototypeOf(rs)), ['constructor','cancel', 'getReader', 'pipeTo', 'pipeThrough']);
assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rs), 'cancel').enumerable);
assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rs), 'cancel').configurable);
assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rs), 'cancel').writable);
assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rs), 'getReader').enumerable);
assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rs), 'getReader').configurable);
assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rs), 'getReader').writable);
assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rs), 'pipeTo').enumerable);
assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rs), 'pipeTo').configurable);
assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rs), 'pipeTo').writable);
assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rs), 'pipeThrough').enumerable);
assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rs), 'pipeThrough').configurable);
assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rs), 'pipeThrough').writable);
assert_equals(typeof rs.cancel, 'function', 'has an cancel method');
assert_equals(rs.cancel.length, 1);
assert_equals(typeof rs.getReader, 'function', 'has a getReader method');
assert_equals(rs.getReader.length, 0);
assert_equals(typeof rs.pipeTo, 'function', 'has a pipeTo method');
assert_equals(rs.pipeTo.length, 2);
assert_equals(typeof rs.pipeThrough, 'function', 'has a pipeThrough method');
assert_equals(rs.pipeThrough.length, 2);
}, 'ReadableStream instances should have the correct list of properties');
test(function() {
new ReadableStream({ });
}, 'ReadableStream can be constructed with an empty object as argument');
</script>