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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/streams/readable-streams/bad-underlying-sources.js

Issue 2808853003: Remove Blink copies of readable-streams layout tests (Closed)
Patch Set: Restore rs-utils.js as it is used by fetch tests Created 3 years, 8 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/bad-underlying-sources.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/streams/readable-streams/bad-underlying-sources.js b/third_party/WebKit/LayoutTests/http/tests/streams/readable-streams/bad-underlying-sources.js
deleted file mode 100644
index b95b54bc7fc9a6f1446b06b85a47efe9c2dc9611..0000000000000000000000000000000000000000
--- a/third_party/WebKit/LayoutTests/http/tests/streams/readable-streams/bad-underlying-sources.js
+++ /dev/null
@@ -1,383 +0,0 @@
-'use strict';
-
-if (self.importScripts) {
- self.importScripts('/resources/testharness.js');
-}
-
-
-test(() => {
-
- const theError = new Error('a unique string');
-
- assert_throws(theError, () => {
- new ReadableStream({
- get start() {
- throw theError;
- }
- });
- }, 'constructing the stream should re-throw the error');
-
-}, 'Underlying source start: throwing getter');
-
-
-test(() => {
-
- const theError = new Error('a unique string');
-
- assert_throws(theError, () => {
- new ReadableStream({
- start() {
- throw theError;
- }
- });
- }, 'constructing the stream should re-throw the error');
-
-}, 'Underlying source start: throwing method');
-
-
-promise_test(t => {
-
- const theError = new Error('a unique string');
- const rs = new ReadableStream({
- get pull() {
- throw theError;
- }
- });
-
- return promise_rejects(t, theError, rs.getReader().closed);
-
-}, 'Underlying source: throwing pull getter (initial pull)');
-
-
-promise_test(t => {
-
- const theError = new Error('a unique string');
- const rs = new ReadableStream({
- pull() {
- throw theError;
- }
- });
-
- return promise_rejects(t, theError, rs.getReader().closed);
-
-}, 'Underlying source: throwing pull method (initial pull)');
-
-
-promise_test(t => {
-
- const theError = new Error('a unique string');
-
- let counter = 0;
- const rs = new ReadableStream({
- get pull() {
- ++counter;
- if (counter === 1) {
- return c => c.enqueue('a');
- }
-
- throw theError;
- }
- });
- const reader = rs.getReader();
-
- return Promise.all([
- reader.read().then(r => {
- assert_object_equals(r, { value: 'a', done: false }, 'the chunk read should be correct');
- }),
- promise_rejects(t, theError, reader.closed)
- ]);
-
-}, 'Underlying source pull: throwing getter (second pull)');
-
-
-promise_test(t => {
-
- const theError = new Error('a unique string');
-
- let counter = 0;
- const rs = new ReadableStream({
- pull(c) {
- ++counter;
- if (counter === 1) {
- c.enqueue('a');
- return;
- }
-
- throw theError;
- }
- });
- const reader = rs.getReader();
-
- return Promise.all([
- reader.read().then(r => {
- assert_object_equals(r, { value: 'a', done: false }, 'the chunk read should be correct');
- }),
- promise_rejects(t, theError, reader.closed)
- ]);
-
-}, 'Underlying source pull: throwing method (second pull)');
-
-promise_test(t => {
-
- const theError = new Error('a unique string');
- const rs = new ReadableStream({
- get cancel() {
- throw theError;
- }
- });
-
- return promise_rejects(t, theError, rs.cancel());
-
-}, 'Underlying source cancel: throwing getter');
-
-promise_test(t => {
-
- const theError = new Error('a unique string');
- const rs = new ReadableStream({
- cancel() {
- throw theError;
- }
- });
-
- return promise_rejects(t, theError, rs.cancel());
-
-}, 'Underlying source cancel: throwing method');
-
-promise_test(() => {
-
- let controller;
- const rs = new ReadableStream({
- start(c) {
- controller = c;
- }
- });
-
- rs.cancel();
- 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 throw');
-
-promise_test(() => {
-
- let controller;
- const rs = new ReadableStream({
- start(c) {
- c.enqueue('a');
- c.enqueue('b');
- controller = c;
- }
- });
-
- rs.cancel();
- 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 throw');
-
-promise_test(() => {
-
- return new ReadableStream({
- start(c) {
- c.close();
- assert_throws(new TypeError(), () => c.enqueue('a'), 'call to enqueue should throw a TypeError');
- }
- }).getReader().closed;
-
-}, 'Underlying source: calling enqueue on a closed stream should throw');
-
-promise_test(t => {
-
- const theError = new Error('boo');
- const closed = new ReadableStream({
- start(c) {
- c.error(theError);
- assert_throws(new TypeError(), () => c.enqueue('a'), 'call to enqueue should throw the error');
- }
- }).getReader().closed;
-
- return promise_rejects(t, theError, closed);
-
-}, 'Underlying source: calling enqueue on an errored stream should throw');
-
-promise_test(() => {
-
- return new ReadableStream({
- start(c) {
- c.close();
- assert_throws(new TypeError(), () => c.close(), 'second call to close should throw a TypeError');
- }
- }).getReader().closed;
-
-}, 'Underlying source: calling close twice on an empty stream should throw the second time');
-
-promise_test(() => {
-
- let startCalled = false;
- let readCalled = false;
- const reader = new ReadableStream({
- start(c) {
- c.enqueue('a');
- c.close();
- assert_throws(new TypeError(), () => c.close(), 'second call to close should throw a TypeError');
- startCalled = true;
- }
- }).getReader();
-
- return Promise.all([
- reader.read().then(r => {
- assert_object_equals(r, { value: 'a', done: false }, 'read() should read the enqueued chunk');
- readCalled = true;
- }),
- reader.closed.then(() => {
- assert_true(startCalled);
- assert_true(readCalled);
- })
- ]);
-
-}, 'Underlying source: calling close twice on a non-empty stream should throw the second time');
-
-promise_test(() => {
-
- let controller;
- let startCalled = false;
- const rs = new ReadableStream({
- start(c) {
- controller = c;
- startCalled = true;
- }
- });
-
- rs.cancel();
- 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 throw');
-
-promise_test(() => {
-
- let controller;
- let startCalled = false;
- const rs = new ReadableStream({
- start(c) {
- controller = c;
- c.enqueue('a');
- startCalled = true;
- }
- });
-
- rs.cancel();
- 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 throw');
-
-promise_test(() => {
-
- const theError = new Error('boo');
- let startCalled = false;
-
- const closed = new ReadableStream({
- start(c) {
- c.error(theError);
- assert_throws(new TypeError(), () => c.close(), 'call to close should throw a TypeError');
- startCalled = true;
- }
- }).getReader().closed;
-
- return closed.catch(e => {
- assert_true(startCalled);
- assert_equals(e, theError, 'closed should reject with the error');
- });
-
-}, 'Underlying source: calling close after error should throw');
-
-promise_test(() => {
-
- const theError = new Error('boo');
- let startCalled = false;
-
- const closed = new ReadableStream({
- start(c) {
- c.error(theError);
- assert_throws(new TypeError(), () => c.error(), 'second call to error should throw a TypeError');
- startCalled = true;
- }
- }).getReader().closed;
-
- return closed.catch(e => {
- assert_true(startCalled);
- assert_equals(e, theError, 'closed should reject with the error');
- });
-
-}, 'Underlying source: calling error twice should throw the second time');
-
-promise_test(() => {
-
- let startCalled = false;
-
- const closed = new ReadableStream({
- start(c) {
- c.close();
- assert_throws(new TypeError(), () => c.error(), 'second call to error should throw a TypeError');
- startCalled = true;
- }
- }).getReader().closed;
-
- return closed.then(() => assert_true(startCalled));
-
-}, 'Underlying source: calling error after close should throw');
-
-promise_test(() => {
-
- let startCalled = false;
- const firstError = new Error('1');
- const secondError = new Error('2');
-
- const closed = new ReadableStream({
- start(c) {
- c.error(firstError);
- startCalled = true;
- return Promise.reject(secondError);
- }
- }).getReader().closed;
-
- return closed.catch(e => {
- assert_true(startCalled);
- assert_equals(e, firstError, 'closed should reject with the first error');
- });
-
-}, 'Underlying source: calling error and returning a rejected promise from start should cause the stream to error ' +
- 'with the first error');
-
-promise_test(() => {
-
- let startCalled = false;
- const firstError = new Error('1');
- const secondError = new Error('2');
-
- const closed = new ReadableStream({
- pull(c) {
- c.error(firstError);
- startCalled = true;
- return Promise.reject(secondError);
- }
- }).getReader().closed;
-
- return closed.catch(e => {
- assert_true(startCalled);
- assert_equals(e, firstError, 'closed should reject with the first error');
- });
-
-}, 'Underlying source: calling error and returning a rejected promise from pull should cause the stream to error ' +
- 'with the first error');
-
-done();

Powered by Google App Engine
This is Rietveld 408576698