2022-09-03 23:24:29 +09:00
|
|
|
// Flags: --expose-internals
|
|
|
|
'use strict';
|
|
|
|
|
2023-10-23 19:55:50 +02:00
|
|
|
const common = require('../common');
|
2022-09-03 23:24:29 +09:00
|
|
|
const assert = require('node:assert');
|
|
|
|
const { AbortError } = require('internal/errors');
|
|
|
|
|
|
|
|
// Purpose: pass an AbortError instance, which isn't the DOMException, as an
|
|
|
|
// abort reason.
|
|
|
|
|
|
|
|
for (const message of [undefined, 'abc']) {
|
|
|
|
const rs = new ReadableStream();
|
|
|
|
const ws = new WritableStream();
|
|
|
|
const ac = new AbortController();
|
|
|
|
const reason = new AbortError(message);
|
|
|
|
ac.abort(reason);
|
|
|
|
|
|
|
|
assert.rejects(rs.pipeTo(ws, { signal: ac.signal }), (e) => {
|
|
|
|
assert(e instanceof DOMException);
|
|
|
|
assert.strictEqual(e.name, 'AbortError');
|
|
|
|
assert.strictEqual(e.message, reason.message);
|
|
|
|
return true;
|
2023-10-23 19:55:50 +02:00
|
|
|
}).then(common.mustCall());
|
2022-09-03 23:24:29 +09:00
|
|
|
}
|