diff options
author | Vitaly Dyatlov <md.xytop@gmail.com> | 2018-07-08 20:12:58 +0000 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-10-11 21:04:55 -0700 |
commit | 3f08c004c5c95abc8a2faf7e2ea156c72806b54b (patch) | |
tree | 590829ecbde95c45383b40b3dba953393daba194 /test | |
parent | e4dea40ce779ae03a77c194074e5aa06a8a28a78 (diff) | |
download | android-node-v8-3f08c004c5c95abc8a2faf7e2ea156c72806b54b.tar.gz android-node-v8-3f08c004c5c95abc8a2faf7e2ea156c72806b54b.tar.bz2 android-node-v8-3f08c004c5c95abc8a2faf7e2ea156c72806b54b.zip |
src: revert removal of SecureContext `_external` getter
This `_external` getter is essential for some libs to work:
uWebSockets as an example.
PR-URL: https://github.com/nodejs/node/pull/21711
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
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; +} |