mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
[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:
@@ -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
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user