chrome.experimental.debugger
For information on how to use experimental APIs, see the chrome.experimental.* APIs page.
Notes
Debugger API serves as an alternate transport for Chrome's
remote debugging protocol. Use chrome.experimental.debugger
to attach to one or more tabs to instrument network interaction, debug
JavaScript, mutate the DOM and CSS, etc. Use the Debuggee tabId to target tabs
with sendCommand and route events by tabId
from onEvent callbacks.
As of today, attaching to the tab by means of the debugger API
and using embedded Chrome DevTools with that tab are mutually exclusive.
If user invokes Chrome DevTools while extension is attached to the tab,
debugging session is terminated. Extension can re-establish it later.
Manifest
You must declare the "debugger" permission in your extension's manifest
to use this API. The debugger API is currently experimental, so you must
declare the "experimental" permission to use it as well.
{
"name": "My extension",
...
"permissions": [
"debugger",
"experimental"
],
...
}
Examples
You can find samples of this API in
Samples.
API reference: chrome.experimental.debugger
Properties
getLastError
chrome.extensionlastError
Methods
attach
void
chrome.experimental.debugger.attach(, Debuggee
target, string
requiredVersion, function
callback)
Undocumented.
Attaches debugger to the given target.
Parameters
-
target
(
optional
enumerated
Debuggee
array of
paramType
)
-
Undocumented.
- Debugging target to which you want to attach.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
requiredVersion
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- 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.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
- Called once the attach operation succeeds or fails. Callback receives no arguments. If the attach fails, chrome.extension.lastError will be set to the error message.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function() {...};
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
detach
void
chrome.experimental.debugger.detach(, Debuggee
target, function
callback)
Undocumented.
Detaches debugger from the given target.
Parameters
-
target
(
optional
enumerated
Debuggee
array of
paramType
)
-
Undocumented.
- Debugging target from which you want to detach.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
- Called once the detach operation succeeds or fails. Callback receives no arguments. If the detach fails, chrome.extension.lastError will be set to the error message.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function() {...};
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
sendCommand
void
chrome.experimental.debugger.sendCommand(, Debuggee
target, string
method, object
params, function
callback)
Undocumented.
Sends given command to the debugging target.
Parameters
-
target
(
optional
enumerated
Debuggee
array of
paramType
)
-
Undocumented.
- Debugging target to which you want to send the command.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
method
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- Method name. Should be one of the methods defined by the remote debugging protocol.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
params
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
- JSON object with request parameters. This object must conform to the remote debugging params scheme for given method.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
- Response body. If an error occurs while posting the message, the callback will be called with no arguments and chrome.extension.lastError will be set to the error message.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(object result) {...};
-
result
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
- JSON object with the response. Structure of the response varies depending on the method and is defined by the remote debugging protocol.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Events
onDetach
chrome.experimental.debugger.onDetach.addListener(function(Debuggee source) {...});
Undocumented.
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.
Listener parameters
-
source
(
optional
enumerated
Debuggee
array of
paramType
)
-
Undocumented.
- The debuggee that was detached.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Extra parameters to addListener
Listener returns
onEvent
chrome.experimental.debugger.onEvent.addListener(function(Debuggee source, string method, object params) {...});
Undocumented.
Fired whenever debugging target issues instrumentation event.
Listener parameters
-
source
(
optional
enumerated
Debuggee
array of
paramType
)
-
Undocumented.
- The debuggee that generated this event.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
method
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- Method name. Should be one of the notifications defined by the remote debugging protocol.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
params
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
- JSON object with the response. Structure of the response varies depending on the method and is defined by the remote debugging protocol.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Extra parameters to addListener
Listener returns
Types
Debuggee
paramName
(
optional
enumerated
Type
array of
object
)
Undocumented.
Debuggee identifier.
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
tabId
(
optional
enumerated
Type
array of
integer
)
-
Undocumented.
- The id of the tab which you intend to debug.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-