2018-08-23 10:20:12 -04:00
|
|
|
// Flags: --expose-internals
|
2017-12-13 22:35:32 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-04-24 00:25:21 +02:00
|
|
|
require('../common');
|
2017-12-13 22:35:32 +00:00
|
|
|
|
|
|
|
// This tests that the accessor properties do not raise assertions
|
|
|
|
// when called with incompatible receivers.
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
// Objects that call StreamBase::AddMethods, when setting up
|
|
|
|
// their prototype
|
2018-08-23 10:20:12 -04:00
|
|
|
const { internalBinding } = require('internal/test/binding');
|
|
|
|
const TTY = internalBinding('tty_wrap').TTY;
|
2018-08-23 09:49:35 -04:00
|
|
|
const UDP = internalBinding('udp_wrap').UDP;
|
2017-12-13 22:35:32 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
// Should throw instead of raise assertions
|
|
|
|
assert.throws(() => {
|
|
|
|
TTY.prototype.bytesRead;
|
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
TTY.prototype.fd;
|
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
TTY.prototype._externalStream;
|
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
UDP.prototype.fd;
|
|
|
|
}, TypeError);
|
|
|
|
|
2018-09-23 19:24:33 +02:00
|
|
|
const StreamWrapProto = Object.getPrototypeOf(TTY.prototype);
|
|
|
|
|
2017-12-13 22:35:32 +00:00
|
|
|
// Should not throw for Object.getOwnPropertyDescriptor
|
|
|
|
assert.strictEqual(
|
2018-09-23 19:24:33 +02:00
|
|
|
typeof Object.getOwnPropertyDescriptor(StreamWrapProto, 'bytesRead'),
|
2017-12-13 22:35:32 +00:00
|
|
|
'object'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2018-09-23 19:24:33 +02:00
|
|
|
typeof Object.getOwnPropertyDescriptor(StreamWrapProto, 'fd'),
|
2017-12-13 22:35:32 +00:00
|
|
|
'object'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2018-09-23 19:24:33 +02:00
|
|
|
typeof Object.getOwnPropertyDescriptor(StreamWrapProto, '_externalStream'),
|
2017-12-13 22:35:32 +00:00
|
|
|
'object'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2018-09-23 19:24:33 +02:00
|
|
|
typeof Object.getOwnPropertyDescriptor(StreamWrapProto, 'fd'),
|
2017-12-13 22:35:32 +00:00
|
|
|
'object'
|
|
|
|
);
|
|
|
|
}
|