[node] Add inspector type definitions (#19330)

* Add inspector types

* Move inspector to separate file

* Add tests and various updates

* substitute object with empty object

* fix copy-paste lapse

* use protocol definition bundled with Node 8.4.0

* Add inspector type def generator script

* fix issues from rebase

* address comments
This commit is contained in:
Kelvin Jin
2017-09-06 14:40:47 -07:00
committed by Andy
parent c18948341a
commit 7809b0138f
10 changed files with 3080 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ import * as v8 from "v8";
import * as dns from "dns";
import * as async_hooks from "async_hooks";
import * as http2 from "http2";
import * as inspector from "inspector";
import Module = require("module");
// Specifically test buffer module regression.
@@ -3387,6 +3388,48 @@ namespace http2_tests {
}
}
///////////////////////////////////////////////////////////
/// Inspector Tests ///
///////////////////////////////////////////////////////////
namespace inspector_tests {
{
inspector.open();
inspector.open(0);
inspector.open(0, 'localhost');
inspector.open(0, 'localhost', true);
inspector.close();
const inspectorUrl: string = inspector.url();
const session = new inspector.Session();
session.connect();
session.disconnect();
// Unknown post method
session.post('A.b', { key: 'value' }, (err: Error, params: object) => {});
session.post('A.b', (err: Error, params: object) => {});
session.post('A.b');
// Known post method
const parameter: inspector.Runtime.EvaluateParameterType = { expression: '2 + 2' };
session.post('Runtime.evaluate', parameter,
(err: Error, params: inspector.Runtime.EvaluateReturnType) => {});
session.post('Runtime.evaluate', (err: Error, params: inspector.Runtime.EvaluateReturnType) => {
const exceptionDetails: inspector.Runtime.ExceptionDetails = params.exceptionDetails;
const resultClassName: string = params.result.className;
});
session.post('Runtime.evaluate');
// General event
session.on('inspectorNotification', (message: inspector.InspectorNotification<object>) => {});
// Known events
session.on('Debugger.paused', (message: inspector.InspectorNotification<inspector.Debugger.PausedEventDataType>) => {
const method: string = message.method;
const pauseReason: string = message.params.reason;
});
session.on('Debugger.resumed', () => {});
}
}
////////////////////////////////////////////////////
/// module tests : http://nodejs.org/api/modules.html
////////////////////////////////////////////////////