xref: /third_party/node/test/parallel/test-webstream-readablestream-pipeto.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_cirequire('../common');
51cb0ef41Sopenharmony_ciconst assert = require('node:assert');
61cb0ef41Sopenharmony_ciconst { AbortError } = require('internal/errors');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci// Purpose: pass an AbortError instance, which isn't the DOMException, as an
91cb0ef41Sopenharmony_ci// abort reason.
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cifor (const message of [undefined, 'abc']) {
121cb0ef41Sopenharmony_ci  const rs = new ReadableStream();
131cb0ef41Sopenharmony_ci  const ws = new WritableStream();
141cb0ef41Sopenharmony_ci  const ac = new AbortController();
151cb0ef41Sopenharmony_ci  const reason = new AbortError(message);
161cb0ef41Sopenharmony_ci  ac.abort(reason);
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci  assert.rejects(rs.pipeTo(ws, { signal: ac.signal }), (e) => {
191cb0ef41Sopenharmony_ci    assert(e instanceof DOMException);
201cb0ef41Sopenharmony_ci    assert.strictEqual(e.name, 'AbortError');
211cb0ef41Sopenharmony_ci    assert.strictEqual(e.message, reason.message);
221cb0ef41Sopenharmony_ci    return true;
231cb0ef41Sopenharmony_ci  });
241cb0ef41Sopenharmony_ci}
25

Indexes created Thu Nov 07 10:32:03 CST 2024