node/test/parallel/test-tls-external-accessor.js
Jordan Harband 757c104147
tools: add prefer-proto rule
fixup: add support for `Object.create(null)`

fixup: extend to any 1-argument Object.create call

fixup: add tests
PR-URL: https://github.com/nodejs/node/pull/46083
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-01-10 05:38:36 +00:00

23 lines
664 B
JavaScript

'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 = { __proto__: pctx };
assert.throws(() => cctx._external, TypeError);
pctx._external; // eslint-disable-line no-unused-expressions
}
{
const pctx = tls.createSecurePair().credentials.context;
const cctx = { __proto__: pctx };
assert.throws(() => cctx._external, TypeError);
pctx._external; // eslint-disable-line no-unused-expressions
}