| Index: third_party/WebKit/LayoutTests/http/tests/streams/resources/recording-streams.js
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/streams/resources/recording-streams.js b/third_party/WebKit/LayoutTests/http/tests/streams/resources/recording-streams.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9837318dbcc025c39327243d51ff74fed884de9e
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/streams/resources/recording-streams.js
|
| @@ -0,0 +1,90 @@
|
| +'use strict';
|
| +
|
| +self.recordingReadableStream = (extras = {}, strategy) => {
|
| + let controllerToCopyOver;
|
| + const stream = new ReadableStream({
|
| + start(controller) {
|
| + controllerToCopyOver = controller;
|
| +
|
| + if (extras.start) {
|
| + return extras.start(controller);
|
| + }
|
| +
|
| + return undefined;
|
| + },
|
| + pull(controller) {
|
| + stream.events.push('pull');
|
| +
|
| + if (extras.pull) {
|
| + return extras.pull(controller);
|
| + }
|
| +
|
| + return undefined;
|
| + },
|
| + cancel(reason) {
|
| + stream.events.push('cancel', reason);
|
| + stream.eventsWithoutPulls.push('cancel', reason);
|
| +
|
| + if (extras.cancel) {
|
| + return extras.cancel(reason);
|
| + }
|
| +
|
| + return undefined;
|
| + }
|
| + }, strategy);
|
| +
|
| + stream.controller = controllerToCopyOver;
|
| + stream.events = [];
|
| + stream.eventsWithoutPulls = [];
|
| +
|
| + return stream;
|
| +};
|
| +
|
| +self.recordingWritableStream = (extras = {}, strategy) => {
|
| + let controllerToCopyOver;
|
| + const stream = new WritableStream({
|
| + start(controller) {
|
| + controllerToCopyOver = controller;
|
| +
|
| + if (extras.start) {
|
| + return extras.start(controller);
|
| + }
|
| +
|
| + return undefined;
|
| + },
|
| + write(chunk) {
|
| + stream.events.push('write', chunk);
|
| +
|
| + if (extras.write) {
|
| + return extras.write(chunk);
|
| + }
|
| +
|
| + return undefined;
|
| + },
|
| + close(...args) {
|
| + assert_array_equals(args, [controllerToCopyOver], 'close must always be called with the controller');
|
| +
|
| + stream.events.push('close');
|
| +
|
| + if (extras.close) {
|
| + return extras.close();
|
| + }
|
| +
|
| + return undefined;
|
| + },
|
| + abort(e) {
|
| + stream.events.push('abort', e);
|
| +
|
| + if (extras.abort) {
|
| + return extras.abort(e);
|
| + }
|
| +
|
| + return undefined;
|
| + }
|
| + }, strategy);
|
| +
|
| + stream.controller = controllerToCopyOver;
|
| + stream.events = [];
|
| +
|
| + return stream;
|
| +};
|
|
|