1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
'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());
|