mirror of
https://github.com/nodejs/node.git
synced 2025-05-22 22:11:41 +00:00

PR-URL: https://github.com/nodejs/node/pull/15619 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
63 lines
1.4 KiB
JavaScript
63 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const assert = require('assert');
|
|
const { Session } = require('inspector');
|
|
|
|
const session = new Session();
|
|
|
|
common.expectsError(
|
|
() => session.post('Runtime.evaluate', { expression: '2 + 2' }),
|
|
{
|
|
code: 'ERR_INSPECTOR_NOT_CONNECTED',
|
|
type: Error,
|
|
message: 'Session is not connected'
|
|
}
|
|
);
|
|
|
|
assert.doesNotThrow(() => session.connect());
|
|
|
|
assert.doesNotThrow(
|
|
() => session.post('Runtime.evaluate', { expression: '2 + 2' }));
|
|
|
|
[1, {}, [], true, Infinity, undefined].forEach((i) => {
|
|
common.expectsError(
|
|
() => session.post(i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message:
|
|
'The "method" argument must be of type string. ' +
|
|
`Received type ${typeof i}`
|
|
}
|
|
);
|
|
});
|
|
|
|
[1, true, Infinity].forEach((i) => {
|
|
common.expectsError(
|
|
() => session.post('test', i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message:
|
|
'The "params" argument must be of type object. ' +
|
|
`Received type ${typeof i}`
|
|
}
|
|
);
|
|
});
|
|
|
|
common.expectsError(
|
|
() => session.connect(),
|
|
{
|
|
code: 'ERR_INSPECTOR_ALREADY_CONNECTED',
|
|
type: Error,
|
|
message: 'The inspector is already connected'
|
|
}
|
|
);
|
|
|
|
assert.doesNotThrow(() => session.disconnect());
|
|
assert.doesNotThrow(() => session.disconnect());
|