gecko-dev/testing/web-platform/tests/streams/readable-byte-streams/constructor.any.js
Jason Orendorff 47519c94b2 Bug 1513570 - Part 1: Adapt stream tests to run in the shell. r=Ms2ger
We don't support byte streams, transform streams, writable streams, or piping
yet, but we will, and in the meantime our own meta files disable those tests
for us.

Differential Revision: https://phabricator.services.mozilla.com/D14314

--HG--
extra : moz-landing-system : lando
2018-12-14 18:14:56 +00:00

48 lines
1.7 KiB
JavaScript

// META: global=worker,jsshell
// META: script=../resources/constructor-ordering.js
'use strict';
const operations = [
op('get', 'size'),
op('get', 'highWaterMark'),
op('get', 'type'),
op('validate', 'type'),
op('validate', 'size'),
op('tonumber', 'highWaterMark'),
op('validate', 'highWaterMark'),
op('get', 'pull'),
op('validate', 'pull'),
op('get', 'cancel'),
op('validate', 'cancel'),
op('get', 'autoAllocateChunkSize'),
op('tonumber', 'autoAllocateChunkSize'),
op('validate', 'autoAllocateChunkSize'),
op('get', 'start'),
op('validate', 'start')
];
for (const failureOp of operations) {
test(() => {
const record = new OpRecorder(failureOp);
const underlyingSource = createRecordingObjectWithProperties(record, ['start', 'pull', 'cancel']);
// The valid value for "type" is "bytes", so set it separately.
defineCheckedProperty(record, underlyingSource, 'type', () => record.check('type') ? 'invalid' : 'bytes');
// autoAllocateChunkSize is a special case because it has a tonumber step.
defineCheckedProperty(record, underlyingSource, 'autoAllocateChunkSize',
() => createRecordingNumberObject(record, 'autoAllocateChunkSize'));
const strategy = createRecordingStrategy(record);
try {
new ReadableStream(underlyingSource, strategy);
assert_unreached('constructor should throw');
} catch (e) {
assert_equals(typeof e, 'object', 'e should be an object');
}
assert_equals(record.actual(), expectedAsString(operations, failureOp),
'operations should be performed in the right order');
}, `ReadableStream constructor should stop after ${failureOp} fails`);
}