|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -require('../common'); |
| 3 | +const common = require('../common'); |
4 | 4 |
|
5 | 5 | // This tests that the accessor properties do not raise assertions |
6 | 6 | // when called with incompatible receivers. |
@@ -12,9 +12,6 @@ const assert = require('assert'); |
12 | 12 | const TTY = process.binding('tty_wrap').TTY; |
13 | 13 | const UDP = process.binding('udp_wrap').UDP; |
14 | 14 |
|
15 | | -// There are accessor properties in crypto too |
16 | | -const crypto = process.binding('crypto'); |
17 | | - |
18 | 15 | { |
19 | 16 | // Should throw instead of raise assertions |
20 | 17 | assert.throws(() => { |
@@ -33,15 +30,6 @@ const crypto = process.binding('crypto'); |
33 | 30 | UDP.prototype.fd; |
34 | 31 | }, TypeError); |
35 | 32 |
|
36 | | - assert.throws(() => { |
37 | | - crypto.SecureContext.prototype._external; |
38 | | - }, TypeError); |
39 | | - |
40 | | - assert.throws(() => { |
41 | | - crypto.Connection.prototype._external; |
42 | | - }, TypeError); |
43 | | - |
44 | | - |
45 | 33 | // Should not throw for Object.getOwnPropertyDescriptor |
46 | 34 | assert.strictEqual( |
47 | 35 | typeof Object.getOwnPropertyDescriptor(TTY.prototype, 'bytesRead'), |
@@ -63,15 +51,28 @@ const crypto = process.binding('crypto'); |
63 | 51 | 'object' |
64 | 52 | ); |
65 | 53 |
|
66 | | - assert.strictEqual( |
67 | | - typeof Object.getOwnPropertyDescriptor( |
68 | | - crypto.SecureContext.prototype, '_external'), |
69 | | - 'object' |
70 | | - ); |
71 | | - |
72 | | - assert.strictEqual( |
73 | | - typeof Object.getOwnPropertyDescriptor( |
74 | | - crypto.Connection.prototype, '_external'), |
75 | | - 'object' |
76 | | - ); |
| 54 | + if (common.hasCrypto) { // eslint-disable-line crypto-check |
| 55 | + // There are accessor properties in crypto too |
| 56 | + const crypto = process.binding('crypto'); |
| 57 | + |
| 58 | + assert.throws(() => { |
| 59 | + crypto.SecureContext.prototype._external; |
| 60 | + }, TypeError); |
| 61 | + |
| 62 | + assert.throws(() => { |
| 63 | + crypto.Connection.prototype._external; |
| 64 | + }, TypeError); |
| 65 | + |
| 66 | + assert.strictEqual( |
| 67 | + typeof Object.getOwnPropertyDescriptor( |
| 68 | + crypto.SecureContext.prototype, '_external'), |
| 69 | + 'object' |
| 70 | + ); |
| 71 | + |
| 72 | + assert.strictEqual( |
| 73 | + typeof Object.getOwnPropertyDescriptor( |
| 74 | + crypto.Connection.prototype, '_external'), |
| 75 | + 'object' |
| 76 | + ); |
| 77 | + } |
77 | 78 | } |