ChromeDebugger class
class ChromeDebugger extends ChromeApi { static final JsObject _debugger = chrome['debugger']; ChromeDebugger._(); bool get available => _debugger != null; /** * Attaches debugger to the given target. * * [target] Debugging target to which you want to attach. * * [requiredVersion] Required debugging protocol version ("0.1"). One can only * attach to the debuggee with matching major version and greater or equal * minor version. List of the protocol versions can be obtained * [here](http://code.google.com/chrome/devtools/docs/remote-debugging.html). */ Future attach(Debuggee target, String requiredVersion) { if (_debugger == null) _throwNotAvailable(); var completer = new ChromeCompleter.noArgs(); _debugger.callMethod('attach', [jsify(target), requiredVersion, completer.callback]); return completer.future; } /** * Detaches debugger from the given target. * * [target] Debugging target from which you want to detach. */ Future detach(Debuggee target) { if (_debugger == null) _throwNotAvailable(); var completer = new ChromeCompleter.noArgs(); _debugger.callMethod('detach', [jsify(target), completer.callback]); return completer.future; } /** * Sends given command to the debugging target. * * [target] Debugging target to which you want to send the command. * * [method] Method name. Should be one of the methods defined by the [remote * debugging * protocol](http://code.google.com/chrome/devtools/docs/remote-debugging.html). * * [commandParams] JSON object with request parameters. This object must * conform to the remote debugging params scheme for given method. * * Returns: * JSON object with the response. Structure of the response varies depending * on the method and is defined by the remote debugging protocol. */ Future<Map<String, dynamic>> sendCommand(Debuggee target, String method, [Map<String, dynamic> commandParams]) { if (_debugger == null) _throwNotAvailable(); var completer = new ChromeCompleter<Map<String, dynamic>>.oneArg(mapify); _debugger.callMethod('sendCommand', [jsify(target), method, jsify(commandParams), completer.callback]); return completer.future; } /** * Returns the list of available debug targets. * * Returns: * Array of TargetInfo objects corresponding to the available debug targets. */ Future<List<TargetInfo>> getTargets() { if (_debugger == null) _throwNotAvailable(); var completer = new ChromeCompleter<List<TargetInfo>>.oneArg((e) => listify(e, _createTargetInfo)); _debugger.callMethod('getTargets', [completer.callback]); return completer.future; } /** * Fired whenever debugging target issues instrumentation event. */ Stream<OnEventEvent> get onEvent => _onEvent.stream; final ChromeStreamController<OnEventEvent> _onEvent = new ChromeStreamController<OnEventEvent>.threeArgs(_debugger, 'onEvent', _createOnEventEvent); /** * Fired when browser terminates debugging session for the tab. This happens * when either the tab is being closed or Chrome DevTools is being invoked for * the attached tab. */ Stream<OnDetachEvent> get onDetach => _onDetach.stream; final ChromeStreamController<OnDetachEvent> _onDetach = new ChromeStreamController<OnDetachEvent>.twoArgs(_debugger, 'onDetach', _createOnDetachEvent); void _throwNotAvailable() { throw new UnsupportedError("'chrome.debugger' is not available"); } }
Extends
ChromeApi > ChromeDebugger
Properties
final bool available #
Returns true if the API is available. The common causes of an API not being avilable are:
- a permission is missing in the application's manifest.json file
- the API is defined on a newer version of Chrome then the current runtime
bool get available => _debugger != null;
final Stream<OnDetachEvent> onDetach #
Fired when browser terminates debugging session for the tab. This happens when either the tab is being closed or Chrome DevTools is being invoked for the attached tab.
Stream<OnDetachEvent> get onDetach => _onDetach.stream;
final Stream<OnEventEvent> onEvent #
Fired whenever debugging target issues instrumentation event.
Stream<OnEventEvent> get onEvent => _onEvent.stream;
Methods
Future attach(Debuggee target, String requiredVersion) #
Attaches debugger to the given target.
target Debugging target to which you want to attach.
requiredVersion Required debugging protocol version ("0.1"). One can only attach to the debuggee with matching major version and greater or equal minor version. List of the protocol versions can be obtained here.
Future attach(Debuggee target, String requiredVersion) { if (_debugger == null) _throwNotAvailable(); var completer = new ChromeCompleter.noArgs(); _debugger.callMethod('attach', [jsify(target), requiredVersion, completer.callback]); return completer.future; }
Future detach(Debuggee target) #
Detaches debugger from the given target.
target Debugging target from which you want to detach.
Future detach(Debuggee target) { if (_debugger == null) _throwNotAvailable(); var completer = new ChromeCompleter.noArgs(); _debugger.callMethod('detach', [jsify(target), completer.callback]); return completer.future; }
Future<List<TargetInfo>> getTargets() #
Returns the list of available debug targets.
Returns: Array of TargetInfo objects corresponding to the available debug targets.
Future<List<TargetInfo>> getTargets() { if (_debugger == null) _throwNotAvailable(); var completer = new ChromeCompleter<List<TargetInfo>>.oneArg((e) => listify(e, _createTargetInfo)); _debugger.callMethod('getTargets', [completer.callback]); return completer.future; }
Future<Map<String, dynamic>> sendCommand(Debuggee target, String method, [Map<String, dynamic> commandParams]) #
Sends given command to the debugging target.
target Debugging target to which you want to send the command.
method Method name. Should be one of the methods defined by the remote debugging protocol.
commandParams JSON object with request parameters. This object must conform to the remote debugging params scheme for given method.
Returns: JSON object with the response. Structure of the response varies depending on the method and is defined by the remote debugging protocol.
Future<Map<String, dynamic>> sendCommand(Debuggee target, String method, [Map<String, dynamic> commandParams]) { if (_debugger == null) _throwNotAvailable(); var completer = new ChromeCompleter<Map<String, dynamic>>.oneArg(mapify); _debugger.callMethod('sendCommand', [jsify(target), method, jsify(commandParams), completer.callback]); return completer.future; }