Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/streams/readable-streams/general.js

Issue 1902673003: Reflect recent spec changes to V8 Extra ReadableStream impl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed build Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/streams/readable-streams/general.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/streams/readable-streams/general.js b/third_party/WebKit/LayoutTests/http/tests/streams/readable-streams/general.js
index b5b24c76f849a9638850357c36e2584a7231493b..28c0c104ed69dc38cb1adb959badbba1118bae34 100644
--- a/third_party/WebKit/LayoutTests/http/tests/streams/readable-streams/general.js
+++ b/third_party/WebKit/LayoutTests/http/tests/streams/readable-streams/general.js
@@ -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;
@@ -25,6 +26,17 @@ test(() => {
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', 'tee'];
const properties = methods.concat(['locked']).sort();
@@ -106,7 +118,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, 5, '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');
@@ -606,23 +618,35 @@ promise_test(() => {
}, 'ReadableStream pull should be able to close a stream.');
-test(() => {
+promise_test(t => {
- let startCalled = false;
+ const controllerError = { name: 'controller error' };
- new ReadableStream({
- start(c) {
- assert_equals(c.enqueue('a'), undefined, 'the first enqueue should return undefined');
- c.close();
+ const rs = new ReadableStream({
+ pull(c) {
+ c.error(controllerError);
+ }
+ });
- assert_throws(new TypeError(), () => c.enqueue('b'), 'enqueue after close should throw a TypeError');
- startCalled = true;
+ 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;
}
});
- assert_true(startCalled);
+ return promise_rejects(t, controllerError, rs.getReader().closed);
-}, 'ReadableStream: enqueue should throw when the stream is readable but draining');
+}, 'ReadableStream pull should be able to error a stream and throw.');
test(() => {
@@ -630,34 +654,34 @@ test(() => {
new ReadableStream({
start(c) {
+ assert_equals(c.enqueue('a'), undefined, 'the first enqueue should return undefined');
c.close();
- assert_throws(new TypeError(), () => c.enqueue('a'), 'enqueue after close should throw a TypeError');
+ assert_throws(new TypeError(), () => c.enqueue('b'), 'enqueue after close should throw a TypeError');
startCalled = true;
}
});
assert_true(startCalled);
-}, 'ReadableStream: enqueue should throw when the stream is closed');
+}, 'ReadableStream: enqueue should throw when the stream is readable but draining');
test(() => {
let startCalled = false;
- const expectedError = new Error('i am sad');
new ReadableStream({
start(c) {
- c.error(expectedError);
+ c.close();
- assert_throws(expectedError, () => c.enqueue('a'), 'enqueue after error should throw that error');
+ assert_throws(new TypeError(), () => c.enqueue('a'), 'enqueue after close should throw a TypeError');
startCalled = true;
}
});
assert_true(startCalled);
-}, 'ReadableStream: enqueue should throw the stored error when the stream is errored');
+}, 'ReadableStream: enqueue should throw when the stream is closed');
promise_test(() => {

Powered by Google App Engine
This is Rietveld 408576698