summaryrefslogtreecommitdiff
path: root/test/sequential/test-inspector-module.js
blob: 26bb7fe9262889b88a42b83523b0664e3fbbce08 (plain)
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
63
64
65
66
67
68
69
70
71
'use strict';

const common = require('../common');

common.skipIfInspectorDisabled();

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'
  }
);

session.connect();
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}`
    }
  );
});

[1, 'a', {}, [], true, Infinity].forEach((i) => {
  common.expectsError(
    () => session.post('test', {}, i),
    {
      code: 'ERR_INVALID_CALLBACK',
      type: TypeError,
      message: 'Callback must be a function'
    }
  );
});

common.expectsError(
  () => session.connect(),
  {
    code: 'ERR_INSPECTOR_ALREADY_CONNECTED',
    type: Error,
    message: 'The inspector session is already connected'
  }
);

session.disconnect();
// Calling disconnect twice should not throw.
session.disconnect();