diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-accessor-properties.js | 17 | ||||
-rw-r--r-- | test/parallel/test-tls-external-accessor.js | 22 |
2 files changed, 38 insertions, 1 deletions
diff --git a/test/parallel/test-accessor-properties.js b/test/parallel/test-accessor-properties.js index 453100d108..95b960b202 100644 --- a/test/parallel/test-accessor-properties.js +++ b/test/parallel/test-accessor-properties.js @@ -1,7 +1,7 @@ // Flags: --expose-internals 'use strict'; -require('../common'); +const common = require('../common'); // This tests that the accessor properties do not raise assertions // when called with incompatible receivers. @@ -54,4 +54,19 @@ const UDP = internalBinding('udp_wrap').UDP; typeof Object.getOwnPropertyDescriptor(StreamWrapProto, 'fd'), 'object' ); + + if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check + // There are accessor properties in crypto too + const crypto = process.binding('crypto'); + + assert.throws(() => { + crypto.SecureContext.prototype._external; + }, TypeError); + + assert.strictEqual( + typeof Object.getOwnPropertyDescriptor( + crypto.SecureContext.prototype, '_external'), + 'object' + ); + } } diff --git a/test/parallel/test-tls-external-accessor.js b/test/parallel/test-tls-external-accessor.js new file mode 100644 index 0000000000..33d371923a --- /dev/null +++ b/test/parallel/test-tls-external-accessor.js @@ -0,0 +1,22 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); + +const assert = require('assert'); +const tls = require('tls'); + +// Ensure accessing ._external doesn't hit an assert in the accessor method. +{ + const pctx = tls.createSecureContext().context; + const cctx = Object.create(pctx); + assert.throws(() => cctx._external, TypeError); + pctx._external; +} +{ + const pctx = tls.createSecurePair().credentials.context; + const cctx = Object.create(pctx); + assert.throws(() => cctx._external, TypeError); + pctx._external; +} |