mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
PR-URL: https://github.com/nodejs/node/pull/60641 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
{
|
|
const domException = new DOMException('no cause', 'abc');
|
|
assert.strictEqual(domException.name, 'abc');
|
|
assert.strictEqual('cause' in domException, false);
|
|
assert.strictEqual(domException.cause, undefined);
|
|
}
|
|
|
|
{
|
|
const domException = new DOMException('with undefined cause', { name: 'abc', cause: undefined });
|
|
assert.strictEqual(domException.name, 'abc');
|
|
assert.strictEqual('cause' in domException, true);
|
|
assert.strictEqual(domException.cause, undefined);
|
|
}
|
|
|
|
{
|
|
const domException = new DOMException('with string cause', { name: 'abc', cause: 'foo' });
|
|
assert.strictEqual(domException.name, 'abc');
|
|
assert.strictEqual('cause' in domException, true);
|
|
assert.strictEqual(domException.cause, 'foo');
|
|
}
|
|
|
|
{
|
|
const object = { reason: 'foo' };
|
|
const domException = new DOMException('with object cause', { name: 'abc', cause: object });
|
|
assert.strictEqual(domException.name, 'abc');
|
|
assert.strictEqual('cause' in domException, true);
|
|
assert.deepStrictEqual(domException.cause, object);
|
|
}
|