mirror of
https://github.com/servo/servo.git
synced 2025-09-05 04:28:22 +01:00
Update web-platform-tests to revision b94b41945d3c7c9b4f3346cf8654cc5ca7ae567c
This commit is contained in:
parent
cb42be9827
commit
950cd1ba87
26 changed files with 275 additions and 123 deletions
|
@ -12,7 +12,7 @@ test(() => {
|
|||
|
||||
test(() => {
|
||||
|
||||
for (let highWaterMark of [-Infinity, NaN, 'foo', {}, () => {}]) {
|
||||
for (const highWaterMark of [-Infinity, NaN, 'foo', {}, () => {}]) {
|
||||
const strategy = new ByteLengthQueuingStrategy({ highWaterMark });
|
||||
assert_equals(strategy.highWaterMark, highWaterMark, `${highWaterMark} gets set correctly`);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ test(() => {
|
|||
|
||||
test(() => {
|
||||
|
||||
for (let highWaterMark of [-Infinity, NaN, 'foo', {}, () => {}]) {
|
||||
for (const highWaterMark of [-Infinity, NaN, 'foo', {}, () => {}]) {
|
||||
const strategy = new CountQueuingStrategy({ highWaterMark });
|
||||
assert_equals(strategy.highWaterMark, highWaterMark, `${highWaterMark} gets set correctly`);
|
||||
}
|
||||
|
|
|
@ -19,9 +19,10 @@ test(() => {
|
|||
|
||||
}, 'Readable stream: throwing strategy.size getter');
|
||||
|
||||
test(() => {
|
||||
promise_test(t => {
|
||||
|
||||
const theError = new Error('a unique string');
|
||||
const controllerError = { name: 'controller error' };
|
||||
const thrownError = { name: 'thrown error' };
|
||||
|
||||
let controller;
|
||||
const rs = new ReadableStream(
|
||||
|
@ -32,22 +33,22 @@ test(() => {
|
|||
},
|
||||
{
|
||||
size() {
|
||||
controller.error(theError);
|
||||
throw theError;
|
||||
controller.error(controllerError);
|
||||
throw thrownError;
|
||||
},
|
||||
highWaterMark: 5
|
||||
}
|
||||
);
|
||||
|
||||
assert_throws(theError, () => {
|
||||
controller.enqueue('a');
|
||||
}, 'enqueue should re-throw the error');
|
||||
assert_throws(thrownError, () => controller.enqueue('a'), 'enqueue should re-throw the error');
|
||||
|
||||
return promise_rejects(t, controllerError, rs.getReader().closed);
|
||||
|
||||
}, 'Readable stream: strategy.size errors the stream and then throws');
|
||||
|
||||
test(() => {
|
||||
promise_test(t => {
|
||||
|
||||
const theError = new Error('a unique string');
|
||||
const theError = { name: 'my error' };
|
||||
|
||||
let controller;
|
||||
const rs = new ReadableStream(
|
||||
|
@ -65,11 +66,9 @@ test(() => {
|
|||
}
|
||||
);
|
||||
|
||||
try {
|
||||
controller.enqueue('a');
|
||||
} catch (error) {
|
||||
assert_equals(error.name, 'RangeError', 'enqueue should throw a RangeError');
|
||||
}
|
||||
assert_throws(new RangeError(), () => controller.enqueue('a'), 'enqueue should throw a RangeError');
|
||||
|
||||
return promise_rejects(t, theError, rs.getReader().closed, 'closed should reject with the error');
|
||||
|
||||
}, 'Readable stream: strategy.size errors the stream and then returns Infinity');
|
||||
|
||||
|
@ -115,7 +114,7 @@ test(() => {
|
|||
|
||||
test(() => {
|
||||
|
||||
for (let highWaterMark of [-1, -Infinity]) {
|
||||
for (const highWaterMark of [-1, -Infinity]) {
|
||||
assert_throws(new RangeError(), () => {
|
||||
new ReadableStream({}, {
|
||||
size() {
|
||||
|
@ -126,7 +125,7 @@ test(() => {
|
|||
}, 'construction should throw a RangeError for ' + highWaterMark);
|
||||
}
|
||||
|
||||
for (let highWaterMark of [NaN, 'foo', {}]) {
|
||||
for (const highWaterMark of [NaN, 'foo', {}]) {
|
||||
assert_throws(new TypeError(), () => {
|
||||
new ReadableStream({}, {
|
||||
size() {
|
||||
|
@ -142,7 +141,7 @@ test(() => {
|
|||
promise_test(() => {
|
||||
|
||||
const promises = [];
|
||||
for (let size of [NaN, -Infinity, Infinity, -1]) {
|
||||
for (const size of [NaN, -Infinity, Infinity, -1]) {
|
||||
let theError;
|
||||
const rs = new ReadableStream(
|
||||
{
|
||||
|
|
|
@ -153,11 +153,11 @@ promise_test(() => {
|
|||
});
|
||||
|
||||
rs.cancel();
|
||||
controller.enqueue('a'); // Calling enqueue after canceling should not throw anything.
|
||||
assert_throws(new TypeError, () => controller.enqueue('a'), 'Calling enqueue after canceling should throw');
|
||||
|
||||
return rs.getReader().closed;
|
||||
|
||||
}, 'Underlying source: calling enqueue on an empty canceled stream should not throw');
|
||||
}, 'Underlying source: calling enqueue on an empty canceled stream should throw');
|
||||
|
||||
promise_test(() => {
|
||||
|
||||
|
@ -171,11 +171,11 @@ promise_test(() => {
|
|||
});
|
||||
|
||||
rs.cancel();
|
||||
controller.enqueue('c'); // Calling enqueue after canceling should not throw anything.
|
||||
assert_throws(new TypeError, () => controller.enqueue('c'), 'Calling enqueue after canceling should throw');
|
||||
|
||||
return rs.getReader().closed;
|
||||
|
||||
}, 'Underlying source: calling enqueue on a non-empty canceled stream should not throw');
|
||||
}, 'Underlying source: calling enqueue on a non-empty canceled stream should throw');
|
||||
|
||||
promise_test(() => {
|
||||
|
||||
|
@ -194,7 +194,7 @@ promise_test(t => {
|
|||
const closed = new ReadableStream({
|
||||
start(c) {
|
||||
c.error(theError);
|
||||
assert_throws(theError, () => c.enqueue('a'), 'call to enqueue should throw the error');
|
||||
assert_throws(new TypeError(), () => c.enqueue('a'), 'call to enqueue should throw the error');
|
||||
}
|
||||
}).getReader().closed;
|
||||
|
||||
|
@ -251,13 +251,13 @@ promise_test(() => {
|
|||
});
|
||||
|
||||
rs.cancel();
|
||||
controller.close(); // Calling close after canceling should not throw anything.
|
||||
assert_throws(new TypeError(), () => controller.close(), 'Calling close after canceling should throw');
|
||||
|
||||
return rs.getReader().closed.then(() => {
|
||||
assert_true(startCalled);
|
||||
});
|
||||
|
||||
}, 'Underlying source: calling close on an empty canceled stream should not throw');
|
||||
}, 'Underlying source: calling close on an empty canceled stream should throw');
|
||||
|
||||
promise_test(() => {
|
||||
|
||||
|
@ -272,13 +272,13 @@ promise_test(() => {
|
|||
});
|
||||
|
||||
rs.cancel();
|
||||
controller.close(); // Calling close after canceling should not throw anything.
|
||||
assert_throws(new TypeError(), () => controller.close(), 'Calling close after canceling should throw');
|
||||
|
||||
return rs.getReader().closed.then(() => {
|
||||
assert_true(startCalled);
|
||||
});
|
||||
|
||||
}, 'Underlying source: calling close on a non-empty canceled stream should not throw');
|
||||
}, 'Underlying source: calling close on a non-empty canceled stream should throw');
|
||||
|
||||
promise_test(() => {
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ promise_test(() => {
|
|||
|
||||
cancel() {
|
||||
randomSource.readStop();
|
||||
randomSource.onend();
|
||||
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
|
|
|
@ -10,6 +10,7 @@ test(() => {
|
|||
|
||||
new ReadableStream(); // ReadableStream constructed with no parameters
|
||||
new ReadableStream({ }); // ReadableStream constructed with an empty object as parameter
|
||||
new ReadableStream({ type: undefined }); // ReadableStream constructed with undefined type
|
||||
new ReadableStream(undefined); // ReadableStream constructed with undefined as parameter
|
||||
|
||||
let x;
|
||||
|
@ -23,6 +24,17 @@ test(() => {
|
|||
|
||||
}, 'ReadableStream can\'t be constructed with garbage');
|
||||
|
||||
test(() => {
|
||||
|
||||
assert_throws(new RangeError(), () => new ReadableStream({ type: null }),
|
||||
'constructor should throw when the type is null');
|
||||
assert_throws(new RangeError(), () => new ReadableStream({ type: '' }),
|
||||
'constructor should throw when the type is empty string');
|
||||
assert_throws(new RangeError(), () => new ReadableStream({ type: 'asdf' }),
|
||||
'constructor should throw when the type is asdf');
|
||||
|
||||
}, 'ReadableStream can\'t be constructed with an invalid type');
|
||||
|
||||
test(() => {
|
||||
|
||||
const methods = ['cancel', 'constructor', 'getReader', 'pipeThrough', 'pipeTo', 'tee'];
|
||||
|
@ -33,7 +45,7 @@ test(() => {
|
|||
|
||||
assert_array_equals(Object.getOwnPropertyNames(proto).sort(), properties, 'should have all the correct methods');
|
||||
|
||||
for (let m of methods) {
|
||||
for (const m of methods) {
|
||||
const propDesc = Object.getOwnPropertyDescriptor(proto, m);
|
||||
assert_false(propDesc.enumerable, 'method should be non-enumerable');
|
||||
assert_true(propDesc.configurable, 'method should be configurable');
|
||||
|
@ -92,7 +104,7 @@ test(() => {
|
|||
assert_array_equals(Object.getOwnPropertyNames(proto).sort(), properties,
|
||||
'the controller should have the right properties');
|
||||
|
||||
for (let m of methods) {
|
||||
for (const m of methods) {
|
||||
const propDesc = Object.getOwnPropertyDescriptor(proto, m);
|
||||
assert_equals(typeof controller[m], 'function', `should have a ${m} method`);
|
||||
assert_false(propDesc.enumerable, m + ' should be non-enumerable');
|
||||
|
@ -108,7 +120,7 @@ test(() => {
|
|||
assert_true(desiredSizePropDesc.configurable, 'desiredSize should be configurable');
|
||||
|
||||
assert_equals(controller.close.length, 0, 'close should have no parameters');
|
||||
assert_equals(controller.constructor.length, 1, 'constructor should have 1 parameter');
|
||||
assert_equals(controller.constructor.length, 4, 'constructor should have 4 parameter');
|
||||
assert_equals(controller.enqueue.length, 1, 'enqueue should have 1 parameter');
|
||||
assert_equals(controller.error.length, 1, 'error should have 1 parameter');
|
||||
|
||||
|
@ -205,7 +217,7 @@ promise_test(() => {
|
|||
|
||||
const rs = new ReadableStream({
|
||||
start(c) {
|
||||
for (let o of objects) {
|
||||
for (const o of objects) {
|
||||
c.enqueue(o);
|
||||
}
|
||||
c.close();
|
||||
|
@ -608,6 +620,36 @@ promise_test(() => {
|
|||
|
||||
}, 'ReadableStream pull should be able to close a stream.');
|
||||
|
||||
promise_test(t => {
|
||||
|
||||
const controllerError = { name: 'controller error' };
|
||||
|
||||
const rs = new ReadableStream({
|
||||
pull(c) {
|
||||
c.error(controllerError);
|
||||
}
|
||||
});
|
||||
|
||||
return promise_rejects(t, controllerError, rs.getReader().closed);
|
||||
|
||||
}, 'ReadableStream pull should be able to error a stream.');
|
||||
|
||||
promise_test(t => {
|
||||
|
||||
const controllerError = { name: 'controller error' };
|
||||
const thrownError = { name: 'thrown error' };
|
||||
|
||||
const rs = new ReadableStream({
|
||||
pull(c) {
|
||||
c.error(controllerError);
|
||||
throw thrownError;
|
||||
}
|
||||
});
|
||||
|
||||
return promise_rejects(t, controllerError, rs.getReader().closed);
|
||||
|
||||
}, 'ReadableStream pull should be able to error a stream and throw.');
|
||||
|
||||
test(() => {
|
||||
|
||||
let startCalled = false;
|
||||
|
@ -643,24 +685,6 @@ test(() => {
|
|||
|
||||
}, 'ReadableStream: enqueue should throw when the stream is closed');
|
||||
|
||||
test(() => {
|
||||
|
||||
let startCalled = false;
|
||||
const expectedError = new Error('i am sad');
|
||||
|
||||
new ReadableStream({
|
||||
start(c) {
|
||||
c.error(expectedError);
|
||||
|
||||
assert_throws(expectedError, () => c.enqueue('a'), 'enqueue after error should throw that error');
|
||||
startCalled = true;
|
||||
}
|
||||
});
|
||||
|
||||
assert_true(startCalled);
|
||||
|
||||
}, 'ReadableStream: enqueue should throw the stored error when the stream is errored');
|
||||
|
||||
promise_test(() => {
|
||||
|
||||
let startCalled = 0;
|
||||
|
@ -799,7 +823,7 @@ promise_test(t => {
|
|||
|
||||
return readableStreamToArray(rs).then(chunks => {
|
||||
assert_equals(chunks.length, 8, '8 chunks should be read');
|
||||
for (let chunk of chunks) {
|
||||
for (const chunk of chunks) {
|
||||
assert_equals(chunk.length, 128, 'chunk should have 128 bytes');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ test(() => {
|
|||
|
||||
assert_array_equals(Object.getOwnPropertyNames(proto).sort(), properties);
|
||||
|
||||
for (let m of methods) {
|
||||
for (const m of methods) {
|
||||
const propDesc = Object.getOwnPropertyDescriptor(proto, m);
|
||||
assert_equals(propDesc.enumerable, false, 'method should be non-enumerable');
|
||||
assert_equals(propDesc.configurable, true, 'method should be configurable');
|
||||
|
|
|
@ -19,6 +19,16 @@ self.templatedRSEmpty = (label, factory) => {
|
|||
assert_equals(typeof rs.tee, 'function', 'has a tee method');
|
||||
|
||||
}, 'instances have the correct methods and properties');
|
||||
|
||||
test(() => {
|
||||
const rs = factory();
|
||||
|
||||
assert_throws(new RangeError(), () => rs.getReader({ mode: '' }), 'empty string mode should throw');
|
||||
assert_throws(new RangeError(), () => rs.getReader({ mode: null }), 'null mode should throw');
|
||||
assert_throws(new RangeError(), () => rs.getReader({ mode: 'asdf' }), 'asdf mode should throw');
|
||||
assert_throws(new TypeError(), () => rs.getReader(null), 'null should throw');
|
||||
|
||||
}, 'calling getReader with invalid arguments should throw appropriate errors');
|
||||
};
|
||||
|
||||
self.templatedRSClosed = (label, factory) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue