mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
8c4b8b201a
Refs: https://github.com/nodejs/node/pull/41660 PR-URL: https://github.com/nodejs/node/pull/41678 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
72 lines
1.5 KiB
JavaScript
72 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const assert = require('assert');
|
|
const { Session } = require('inspector');
|
|
|
|
const session = new Session();
|
|
|
|
assert.throws(
|
|
() => session.post('Runtime.evaluate', { expression: '2 + 2' }),
|
|
{
|
|
code: 'ERR_INSPECTOR_NOT_CONNECTED',
|
|
name: 'Error',
|
|
message: 'Session is not connected'
|
|
}
|
|
);
|
|
|
|
session.connect();
|
|
session.post('Runtime.evaluate', { expression: '2 + 2' });
|
|
|
|
[1, {}, [], true, Infinity, undefined].forEach((i) => {
|
|
assert.throws(
|
|
() => session.post(i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError',
|
|
message:
|
|
'The "method" argument must be of type string.' +
|
|
common.invalidArgTypeHelper(i)
|
|
}
|
|
);
|
|
});
|
|
|
|
[1, true, Infinity].forEach((i) => {
|
|
assert.throws(
|
|
() => session.post('test', i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError',
|
|
message:
|
|
'The "params" argument must be of type object.' +
|
|
common.invalidArgTypeHelper(i)
|
|
}
|
|
);
|
|
});
|
|
|
|
[1, 'a', {}, [], true, Infinity].forEach((i) => {
|
|
assert.throws(
|
|
() => session.post('test', {}, i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError',
|
|
}
|
|
);
|
|
});
|
|
|
|
assert.throws(
|
|
() => session.connect(),
|
|
{
|
|
code: 'ERR_INSPECTOR_ALREADY_CONNECTED',
|
|
name: 'Error',
|
|
message: 'The inspector session is already connected'
|
|
}
|
|
);
|
|
|
|
session.disconnect();
|
|
// Calling disconnect twice should not throw.
|
|
session.disconnect();
|