mirror of https://github.com/lukechilds/node.git
Browse Source
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>v9.x-staging
James M Snell
7 years ago
4 changed files with 101 additions and 10 deletions
@ -0,0 +1,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()); |
Loading…
Reference in new issue