GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: add hasCrypto when using binding('crypto') · nodejs/node@9e68947

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-accessor-properties.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-accessor-properties.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-accessor-properties.js
+25-24Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
44

55
// This tests that the accessor properties do not raise assertions
66
// when called with incompatible receivers.
@@ -12,9 +12,6 @@ const assert = require('assert');
1212
const TTY = process.binding('tty_wrap').TTY;
1313
const UDP = process.binding('udp_wrap').UDP;
1414

15-
// There are accessor properties in crypto too
16-
const crypto = process.binding('crypto');
17-
1815
{
1916
// Should throw instead of raise assertions
2017
assert.throws(() => {
@@ -33,15 +30,6 @@ const crypto = process.binding('crypto');
3330
UDP.prototype.fd;
3431
}, TypeError);
3532

36-
assert.throws(() => {
37-
crypto.SecureContext.prototype._external;
38-
}, TypeError);
39-
40-
assert.throws(() => {
41-
crypto.Connection.prototype._external;
42-
}, TypeError);
43-
44-
4533
// Should not throw for Object.getOwnPropertyDescriptor
4634
assert.strictEqual(
4735
typeof Object.getOwnPropertyDescriptor(TTY.prototype, 'bytesRead'),
@@ -63,15 +51,28 @@ const crypto = process.binding('crypto');
6351
'object'
6452
);
6553

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+
}
7778
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.