lib: set abort-controller toStringTag
PR-URL: https://github.com/nodejs/node/pull/36115 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
2097ffd7cb
commit
d7bfa58942
@ -7,7 +7,9 @@ const {
|
|||||||
ObjectAssign,
|
ObjectAssign,
|
||||||
ObjectDefineProperties,
|
ObjectDefineProperties,
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
|
ObjectDefineProperty,
|
||||||
Symbol,
|
Symbol,
|
||||||
|
SymbolToStringTag,
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
@ -55,6 +57,13 @@ ObjectDefineProperties(AbortSignal.prototype, {
|
|||||||
aborted: { enumerable: true }
|
aborted: { enumerable: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ObjectDefineProperty(AbortSignal.prototype, SymbolToStringTag, {
|
||||||
|
writable: false,
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true,
|
||||||
|
value: 'AbortSignal',
|
||||||
|
});
|
||||||
|
|
||||||
defineEventHandler(AbortSignal.prototype, 'abort');
|
defineEventHandler(AbortSignal.prototype, 'abort');
|
||||||
|
|
||||||
function createAbortSignal() {
|
function createAbortSignal() {
|
||||||
@ -98,6 +107,13 @@ ObjectDefineProperties(AbortController.prototype, {
|
|||||||
abort: { enumerable: true }
|
abort: { enumerable: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ObjectDefineProperty(AbortController.prototype, SymbolToStringTag, {
|
||||||
|
writable: false,
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true,
|
||||||
|
value: 'AbortController',
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
AbortController,
|
AbortController,
|
||||||
AbortSignal,
|
AbortSignal,
|
||||||
|
@ -60,3 +60,10 @@ const { ok, strictEqual, throws } = require('assert');
|
|||||||
/^TypeError: Illegal constructor$/
|
/^TypeError: Illegal constructor$/
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
// Symbol.toStringTag
|
||||||
|
const toString = (o) => Object.prototype.toString.call(o);
|
||||||
|
const ac = new AbortController();
|
||||||
|
strictEqual(toString(ac), '[object AbortController]');
|
||||||
|
strictEqual(toString(ac.signal), '[object AbortSignal]');
|
||||||
|
}
|
||||||
|
@ -21,7 +21,7 @@ common.expectWarning({
|
|||||||
'Use events.setMaxListeners() to increase ' +
|
'Use events.setMaxListeners() to increase ' +
|
||||||
'limit'],
|
'limit'],
|
||||||
['Possible EventTarget memory leak detected. 3 foo listeners added to ' +
|
['Possible EventTarget memory leak detected. 3 foo listeners added to ' +
|
||||||
'[AbortSignal [EventTarget]]. ' +
|
'[AbortSignal]. ' +
|
||||||
'Use events.setMaxListeners() to increase ' +
|
'Use events.setMaxListeners() to increase ' +
|
||||||
'limit'],
|
'limit'],
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user