Crossfire 0.3a6 Protocol Reference
From FirebugWiki
[edit] Crossfire Protocol Reference
[edit] Handshake
Once a connection has been established with a remote host, Crossfire will wait until it receives a UTF-8 string which matches CrossfireHandshake\r\n\r\n
If crossfire was started as a server it will reply with an acknowledgement that matches CrossfireHandshake\r\n\r\n.
[edit] Packet Format
Crossfire packets contain a content-length header with key
Content-Length followed by a colon (:),
and the number of characters (in decimal) contained in the message body.
The body of the packet is a UTF-8 string containing a JSON-formatted message.
Packet headers and body are separated by a double CRLF (\r\n\r\n).
Packets are terminated by a CRLF (\r\n) after the body.
Example:
Content-Length:69 \r\n\r\n { "context_id":null, "type":"request", "seq":1, "command":"listcontexts" }\r\n
[edit] JSON Message Format
Message bodies are JSON-formatted strings which contain at a minimum, the context ID, sequence number, and packet type.
- context_id
- String that identifies which JavaScript context the packet applies to. For a Web page, this may be the URL of the page.
- seq
- sequence number (integer)
- type
- packet type; one of
"request","response", or"event"
[edit] Request Packets
A request packet includes a command name and an arguments object containing any arguments specific to the command.
All request packets have the general form:
Content-Length:<length> \r\n\r\n { "type":"request", "command":<command>, "context_id":<context_id> "seq":<packet_sequence>, "arguments":{<argument_list>} }
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) commandthe name of the request. A complete listing of requests that can be used in <command>are available in the Commands section.context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number arguments_listthe list of arguments to pass in with the request
Example:
Content-Length:219 \r\n\r\n { "type":"request", "command":"setbreakpoint", "context_id":"http://localhost:8080/test.html", "seq":21, "arguments": { "position":0, "enabled":true, "target":"http://localhost:8080/test/some_javascript.js", "line":9, "ignoreCount":0, "type":"line" } } \r\n
[edit] Response Packets
A response packet will contain the sequence number of the original request and the name of the command, as well as the body of the response and booleans indicating the running status and whether the request was successful.All response packets are of the form:
Content-Length:<length> \r\n\r\n { "type":"response", "command":<command>, "seq":<packet_sequence>, "request_seq":<request_sequence>, "body":<body_object>, "running":<is_running>, "success":<success_status>, }
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) commandthe name of the original request context_idthe id of the context this response came from packet_sequencethe packet sequence number request_sequencethe request sequence number body_objectJSON object containing additional data about the response runningif Crossfire is in a running state successif the request was successful or not
Example:
Content-Length:80 \r\n\r\n { "type":"response", "command":"listcontexts", "seq":2, "request_seq":1, "running":true, "success":true, "body":{ "contexts":["http://localhost:8080/test.html"] } } \r\n
[edit] Event Packets
Event packets contain the name of the event and a 'data' object which may contain more information related to the event.All event packets are of the form:
Content-Length:<content_length> \r\n\r\n { "type":"event", "event":<event>, "context_id":<context_id>, "seq":<packet_sequence>, "data":{<data_object>} }Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) eventthe name of the event. A complete listing of events that can appear in <event>are available in the Events section.context_idthe id of the context this event came from packet_sequencethe packet sequence number data_objectJSON object containing additional data about the event
Example
Content-Length:122 \r\n\r\n { "type":"event", "event":"onContextCreated", "context_id":"xf0.1a::9931113", "seq":5, "data":{ "href":"http://www.google.ca/" } }
[edit] Types
Commands like frame, backtrace, scope, lookup will contain serialized Javascript values and objects in the body of the response. The JSON structure for these objects will always contain a type field, and either a value field with a JSON value or, in the case of object or function types, a handle field which can be used to obtain the actual value by using the lookup command.
[edit] object
An object is represented as a handle of the form:
{ "myobject":{ "type":"object", "handle":<number> } }
In versions of Crossfire less than 0.3a2 the type of an object was ref, like the following:
{ "myobject":{ "type":"ref", "handle":<number> } }
Objects can also be nested within other objects. For example in the case of backtrace request, you will receive
a response with variables split up as locals and 'this'.
Nested objects will always appear as a value entry in the object, like the following:
{ "myobject":{ "type":"object", "value":{ "mynestedobj":{"type":"object","handle":<number>} } } }
[edit] function
A function is represented as a handle of the form:
{ "myfunction":{ "type":"function", "handle":<number> } }
In versions of Crossfire less than 0.3a2 a function was represented as:
{ "myfunction":{ "type":"function", "value":"function()" } }
[edit] boolean
A boolean is represented as:
{ "myboolean":{ "type":"boolean", "value":<true_or_false> } }
[edit] number
A number is represented as:
{ "mynumber":{ "type":"number", "value":<number> } }
[edit] string
A string is represented as:
{ "mystring":{ "type":"string", "value":"string_value" } }
[edit] undefined
An undefined value is represented as:
{ "myfunction":"undefined" }
[edit] null
A null value is represented as:
{ "mystring":null }
[edit] Commands
[edit] backtrace
Returns a backtrace (stacktrace) of frames.The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"backtrace", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "fromFrame":<from_frame>, "toFrame":<to_frame>, "includeScopes":<include_scopes> } } \r\nArguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number from_framean optional argument that indicates what frame to start the backtrace from. If not specified, zero is assumed. to_framean optional argument that indicates what frame to end the backtrace at. If not specified or larger than the total frame count, the total frame count is assumed. include_scopesan optional argument that indicates that the scopes for the frames should also be returned in the response. If not specified true is assumed.
Example Request
An example of the request you send:
Content-Length:128 \r\n { "type":"request", "command":"backtrace", "context_id":"xf0.1a::9931113", "seq":6, "arguments":{ "fromFrame":0, "includeScopes":true } } \r\n
Example Response
An example of the response you receive:
Content-Length:6325 \r\n\r\n { "type":"response", "command":"backtrace", "context_id":"xf0.3::4303985", "seq":50, "request_seq":49, "body": { "fromFrame":0, "toFrame":1, "frames":[{ "index":0, "func":"onload", "script":"http://www.google.ca//event/seq/1", "locals":{"type":"object", "value":{}}, "line":2, "scopes":[{"index":0,"frameIndex":0,"object":{"type":"object","handle":348}}] }], }, "running":false, "success":true }
[edit] changebreakpoint
Return the breakpoint object with the specified id.This request has been updated in Crossfire version 0.3a6, please see the migration guide entry for details.
The form of the packet is:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"changebreakpoint", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "handle":<breakpoint> "enabled":<enabled> "condition":<condition> } } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe optional id of the context this request is targeted for. If omitted Crossfire will try to change all breakpoints that match the given location in all contexts packet_sequencethe packet sequence number handlea required argument that specifies the handle of the breakpoint to change enabledan optional argument that specifies if the breakpoint should be enabled or not conditionan optional argument that specifies a condition that should be set on the breakpoint, specifying nullwill remove an existing condition
Example Request
An example of the request you send:
Content-Length:115 \r\n\r\n { "type":"request", "command":"changebreakpoint", "context_id":"xf0.3::1021597", "seq":21, "arguments":{ "handle":7, "enabled":true, "condition":"y == 6" } } \r\n
Example Response
An example of the response you receive:
Content-Length:115 \r\n\r\n { "type":"response", "command":"changebreakpoint", "seq":22, "request_seq":21, "body":{ "breakpoint": { "handle":7, "type":"line", "enabled":true, "condition":"y == 6", "location":{ "line":2, "url":"http://www.google.ca//event/seq/1" } } }, "running":true, "success":true }
[edit] clearbreakpoint
Remove the breakpoint object with the specified id.This request has been updated in Crossfire version 0.3a5, please see the migration guide entry for details.
The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request" "command":"clearbreakpoint", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "handle":<breakpoint>, } } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number handlea required argument that specifies the handle of the breakpoint to clear
Example Request
An example of the request you send:
Content-Length:109 \r\n\r\n { "type":"request", "command":"clearbreakpoint", "context_id":"xf0.3::6179868", "seq":7, "arguments":{ "handle":1 }, } \r\n
Example Response
An example of the response you receive:
Content-Length:229 \r\n\r\n { "command":"clearbreakpoint", "type":"response", "seq":8, "request_seq":7, "body":{ "breakpoint":{ "handle":1, "type":"line", "enabled":true, "location":{ "line":2, "url":"http://www.google.ca//event/seq/1" }, } }, "running":true, "success":true }
[edit] continue
Continue execution of javascript if suspended, if no stepaction is passed, simply resumes execution.The form of the packet is:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"continue", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{"stepaction":[in, next, out]} } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number stepactionan optional argument in crossfire 0.3 and greater, required for 0.2a* and lower. The value can be one of in,next, orout. Passing in an unknown kind of stepaction will result in the context being resumed with no step performed.
Example Request
An example of the request you send:
Content-Length:78 \r\n\r\n { "type":"request", "command":"continue", "context_id":"xf0.3::2777681", "seq":87 } \r\n
Example Response
An example of the response you receive:
Content-Length:105 \r\n\r\n { "type":"response", "command":"continue", "seq":8, "request_seq":7, "running":false, "success":true }
[edit] evaluate
Evaluates a JavaScript expression, either in the global scope, or optionally in a given frame if it exists.The form of the packet is:
Content-Length:<content_length> \r\n\r\n { "command":"evaluate", "type":"request", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "expression":<expression>, "frame":<frame> } } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number expressiona required argument that specifies the expression to evaluate framea required argument that specifies the index of the stackframe to perform the evaluation on, where zero is the top stack frame
Example Request
An example of the request you send:
Content-Length:123 \r\n\r\n { "command":"evaluate", "type":"request", "context_id":"xf0.3::3442767", "seq":20, "arguments":{ "expression":"2*4-1", "frame":0 } } \r\n
Example Response
An example of the response you receive:
Content-Length:177 \r\n\r\n { "command":"evaluate", "type":"response", "context_id":"xf0.3::3442767", "seq":21, "request_seq":20, "running":false, "success":true, "body":{ "context_id":"xf0.3::3442767", "result":7 } }
[edit] frame
Returns a frame.The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"frame", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "frame":<frame>, "includeScopes":<include_scopes> } } \r\nArguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number framea required argument that specifies the index of the frame to look up include_scopesan optional argument that indicates that the scopes for the frames should also be returned in the response.
Example Request
An example of the request you send:
Content-Length:120 \r\n\r\n { "type":"request", "command":"frame", "context_id":"xf0.3::7322351", "seq":33, "arguments":{ "frame":0, "includeScopes":true }, } \r\n
Example Response
An example of the response you receive:
Content-Length:6764 \r\n\r\n { "type":"response", "command":"frame", "context_id":"xf0.3::7322351", "seq":34, "request_seq":33, "body":{ "context_id":"xf0.3::7322351", "index":0, "line":19, "func":"anonymous", "script":"http://www.mozilla.com/js/jquery/jquery.min.js", "locals":{"type":"object","value":{},"this":{"type":"object","value":{"classList":{"type":"object","handle":13}}}}, "scopes":[{"index":0,"frameIndex":0,"object":{"type":"object","handle":"14"}}] }, "running":false, "success":true }
[edit] getbreakpoint
Return the breakpoint object with the specified id.This request has been updated in Crossfire version 0.3a5, please see the migration guide entry for details.
The form of the packet is:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"getbreakpoint", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "handle":<breakpoint> } } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number handlea required argument that specifies the handle of the breakpoint to look up
Example Request
An example of the request you send:
Content-Length:112 \r\n\r\n { "type":"request", "command":"getbreakpoint", "context_id":"xf0.3::1021597", "seq":16, "arguments":{ "handle":5 } } \r\n
Example Response
An example of the response you receive:
Content-Length:224 \r\n\r\n { "type":"response", "command":"getbreakpoint", "seq":17, "request_seq":16, "body":{ "handle":5, "type":"line", "enabled":true, "location": { "line":2, "url":"http://www.google.ca//event/seq/1" } }, "running":true, "success":true }
[edit] getbreakpoints
Return all the breakpoints in this context.This request has been updated in Crossfire version 0.3a6, please see the migration guide entry for details.
The form of the packet is:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"getbreakpoints", "context_id":<context_id>, "seq":<packet_sequence>, } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe optional id of the context this request is targeted for. If omitted all contexts known to Firebug are consulted to find breakpoints packet_sequencethe packet sequence number
Example Request
An example of the request you send:
Content-Length:84 \r\n\r\n { "type":"request", "command":"getbreakpoints", "context_id":"xf0.3::6179868", "seq":12, } \r\n
Example Response
An example of the response you receive:
Content-Length:1366 \r\n\r\n { "type":"response", "command":"getbreakpoints", "seq":46, "request_seq":45, "body":{ "breakpoints":[{ "handle":7, "type":"line", "location":{ "line":2, "url":"http://www.google.ca//event/seq/1" }, "enabled":true }] }, "running":true, "success":true }
[edit] inspect
Tells Firebug to enter 'inspect' mode on the given node.The form of the packet is:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"inspect", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "xpath":<xpath> "selector":<selector> } } \r\nArguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number xpathan optional argument specifying the xpath to the node to inspect. selectoran optional argument specifying the selector of the node to inspect
One of
xpathorselectormust be specified. If both are specified,xpathis used.
Example Request
An example of the request you send:
Content-Length:128 \r\n\r\n { "type":"request", "command":"inspect", "context_id":"xf0.3::815372", "seq":51, "arguments":{ "xpath":"/html[1]/body[1]/span[1]" } } \r\n
Example Response
An example of the response you receive:
Content-Length:307 \r\n\r\n { "type":"response", "command":"inspect", "seq":53, "request_seq":51, "body":{ "xpath":"/html[1]/body[1]/span[1]", }, "running":false, "success":true }
[edit] listcontexts
Returns a list of context id's. This command does not require acontext_idfield.The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"listcontexts", "seq":<packet_sequence> } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) packet_sequencethe packet sequence number
Example Request
An example of the request you send:
Content-Length:51 \r\n\r\n { "type":"request", "command":"listcontexts", "seq":8 } \r\n
Example Response
An example of the response you receive:
Content-Length:222 \r\n\r\n { "type":"response", "command":"listcontexts", "seq":9, "request_seq":8, "body":{ "contexts":[{"context_id":"xf0.3::379685","href":"http://www.mozilla.com/en-US/firefox/central/","current":false}] }, "running":true, "success":true }
[edit] lookup
Looks up an object by its handle.The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"lookup", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "handle":<handle> "includeSource":<include_source> }, } \r\nArguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number handlea required argument that indicates what object to look up include_sourcean optional argument that indicates you want to return the source for the object (if any). Only available in Crossfire 0.3a2 or greater
Example Request
An example of the request you send:
Content-Length:257 \r\n\r\n { "type":"request", "command":"lookup", "context_id":"xf0.3::8265385", "seq":46, "arguments":{"handle":10,"includeSource":true}, } \r\n
Example Response
An example of the response you receive:
Content-Length:320 \r\n\r\n { "type":"response", "command":"lookup", "context_id":"xf0.3::3775561", "seq":10, "request_seq":9, "body":{ "type":"function", "value":{ "constructor":{"type":"function","handle":88}, "proto":{"type":"object","handle":89} }, "context_id":"xf0.3::3775561", "source":"function Object() {[native code]}" }, "running":false, "success":true, }
[edit] scope
Returns a particular scope for the specified frame.The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"scope", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "number":<scope_number>, "frameNumber":<frame_number> } } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number scope_numbera required argument thats indicates which scope to get from the scopes listing. If scope_numberis 0, the global scope is returned. Ifscope_numberis NaN or outside the range of scopes no scope information is returned.frame_numbera required argument thats indicates which frame to get the scope from.
Example Request
An example of the request you send:
Content-Length:116 \r\n\r\n { "type":"request", "command":"scope", "context_id":"xf0.3::6179868", "seq":20, "arguments":{ "number":0, "frameNumber":0 } } \r\n
Example Response
An example of the response you receive:
Content-Length:226 \r\n\r\n { "type":"response", "command":"scope", "context_id":"xf0.3::6179868", "seq":21, "request_seq":20, "body":{ "context_id":"xf0.3::6179868", "index":0, "frameIndex":0, "object":{"type":"ref","handle":"19"} }, "running":false, "success":true }
[edit] scopes
Returns all the scopes for a frame.The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"scopes", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "frameNumber":<frame_number> } } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number frame_numbera required argument thats indicates which frame to get the scopes from.
Example Request
An example of the request you send:
Content-Length:106 \r\n\r\n { "type":"request", "command":"scopes", "context_id":"xf0.3::6179868", "seq":16, "arguments":{"frameNumber":0} } \r\n
Example Response
An example of the response you receive:
Content-Length:282 \r\n\r\n { "type":"response", "command":"scopes", "context_id":"xf0.3::6179868", "seq":17, "request_seq":16, "body":{ "context_id":"xf0.3::6179868", "fromScope":0, "toScope":0, "totalScopes":1, "scopes":[{ "index":0, "frameIndex":0, "object":{"type":"ref","handle":"19"} }] }, "running":false, "success":true }
[edit] script
Retrieve a single scriptThe packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request" "command":"script", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "includeSource":<include_source>, "url":<script_url> } } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number include_sourcea required argument that indicates if the source for the requested script should be returned in the response script_urla required argument that indicates where to get the script from
Example Request
An example of the request you send:
Content-Length:188 \r\n\r\n { "type":"request" "command":"script", "context_id":"xf0.3::2777681", "seq":84, "arguments":{ "includeSource":true, "url":"http://www.mozilla.org/script/1.0/jquery-ui-1.7.2.custom.min.js" } } \r\nExample Response
An example of the response you receive:
Content-Length:19783 \r\n\r\n { "type":"response", "command":"script", "context_id":"xf0.3::2777681", "seq":85, "request_seq":84, "body":{ "context_id":"xf0.3::2777681", "script":{ "id":"http://www.mozilla.org/script/1.0/jquery-ui-1.7.2.custom.min.js", "lineOffset":0, "columnOffset":0, "sourceStart":"/*\u000a","sourceLength":19, "lineCount":19, "compilationType":"top-level", "source":"..." } }, "running":true, "success":true, }
[edit] scripts
Retrieve all known scripts in a context.The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"scripts", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "includeSource":<include_source> } } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number include_sourcea required argument that indicates if source should be returned for each of the scripts that are returned
Example Request
An example of the request you send:
Content-Length:112 \r\n\r\n { "type":"request", "command":"scripts", "context_id":"xf0.3::3788274", "seq":52, "arguments":{ "includeSource":true } } \r\n
Example Response
An example of the response you receive:
Content-Length:78967 \r\n\r\n { "type":"response", "command":"scripts", "context_id":"xf0.3::3788274", "request_seq":52, "seq":53, "body":{ "context_id":"xf0.3::3788274", "scripts":[{"script":{ "id":"http://www.mozilla.org/", "lineOffset":0, "columnOffset":0, "sourceStart":"<!DOCTYPE html>\u000a", "sourceLength":298, "lineCount":298, "compilationType":"URLOnly", "source":"..."} }}, {"script": {...}} ] }, "running":true, "success":true, }
[edit] setbreakpoint
Set a breakpoint and return its id.This request has been updated in Crossfire version 0.3a6, please see the migration guide entry for details.
The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request" "command":"setbreakpoint", "context_id":<context_id>, "seq":<packet_sequence>, "arguments":{ "location":{}, "type":<type>, "enabled":<enabled>, "condition":<condition> } } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe optional id of the context this request is targeted for. If omitted, Crossfire will attempt to set the breakpoint in all sources that match the given location from the request. packet_sequencethe packet sequence number locationa required argument that specifies the locale to place them breakpoint in, for example the URL of the script and the line within that script typean optional argument that specifies the kind of breakpoint to create, if omitted, "line" is assumed enabledan optional argument that specifies if the breakpoint should be enabled by default, if omitted, trueis assumedconditionan optional argument that specifies the condition to use to determine if the breakpoint should suspend
Example Request
An example of the request you send:
Content-Length:196 \r\n\r\n { "type":"request", "command":"setbreakpoint", "context_id":"xf0.3::2531266", "seq":42, "arguments":{ "enabled":true, "type":"line" "condition":null, "location":{ "line":2, "url":"http:\/\/www.google.ca\/\/event\/seq\/1" } } } \r\n
Example Response
An example of the response you receive:
Content-Length:230 \r\n\r\n { "seq":44, "type":"response", "command":"setbreakpoint", "request_seq":42, "body":{ "breakpoint":{ "handle":7, "type":"line", "enabled":true, "location":{ "line":2, "url":"http://www.google.ca//event/seq/1" } } }, "running":false, "success":true }
[edit] source
Returns the source for every script currently known to Firebug in the given context.The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"source", "context_id":<context_id>, "seq":<packet_sequence> } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number
Example Request
An example of the request you send:
Content-Length:76 \r\n\r\n { "type":"request", "command":"source", "context_id":"xf0.3::7322351", "seq":38 } \r\n
Example Response
An example of the response you receive:
Content-Length:227887 \r\n\r\n { "type":"response", "command":"source", "context_id":"xf0.3::7322351", "seq":39, "request_seq":38, "body":{ "context_id":"xf0.3::7322351", "scripts":[{ "script":{ "id":"http://www.mozilla.com/js/util.js", "lineOffset":0, "columnOffset":0, "sourceStart":"// Borrowed from addons.mozilla.org - thanks :)\u000a", "sourceLength":154, "lineCount":154, "compilationType":"top-level", "source":"//" } }] }, "running":false, "success":true }
[edit] suspend
Try to suspend any currently running JavaScript.The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"suspend", "context_id":<context_id>, "seq":<packet_sequence>, } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) context_idthe id of the context this request is targeted for packet_sequencethe packet sequence number
Example Request
An example of the request you send:
Content-Length:77 \r\n { "type":"request", "command":"suspend", "context_id":"xf0.1a::9931113", "seq":5, } \r\n
Example Response
An example of the response you receive:
Content-Length:105 \r\n\r\n { "type":"response", "command":"suspend", "seq":93, "request_seq":92, "running":true, "success":true }
[edit] version
Returns the Crossfire protocol version. This command does not require acontext_idfield.The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"version", "seq":<packet_sequence> } \r\n
Arguments
content_lengththe entire length of the packet content between the curly braces (including the curly braces) packet_sequencethe packet sequence number
Example Request
An example of the request you send:
Content-Length:47 \r\n\r\n { "type":"request" "command":"version", "seq":10 } \r\nExample Response
An example of the response you will receive:
Content-Length:120 \r\n\r\n { "type":"response", "command":"version", "seq":11, "request_seq":10, "body":{"version":"0.3"}, "running":true, "success":true }
[edit] updatecontext
Load a new URL into an existing context. If no context is specified, opens a new tab and loads the given URL.
This event has been added in Crossfire version 0.3a5, please see the migration guide entry for details.
The packet has the following form:
Content-Length:<content_length> \r\n\r\n { "type":"request", "command":"updatecontext", "seq":<packet_sequence> } \r\n
Arguments
hrefA new URL to load
Example Request
An example of the request you send:
Content-Length:47 \r\n\r\n { "type":"request" "command":"updatecontext", "seq": 22, "context_id":"xf0.1a::9931113", "arguments": { "href": "http://collinsmichaelg.com" } } \r\nExample Response
An example of the response you will receive:
Content-Length:120 \r\n\r\n { "type":"response", "command":"updatecontext", "seq":23, "request_seq":22, "body":{}, "running":true, "success":true }
[edit] Events
[edit] onBreak
Firebug has suspended ("broken") in a script.
Content-Length:197 \r\n\r\n { "type":"event", "event":"onBreak", "context_id":"xf0.3::8127621", "body":{ "line":22, "url":"http://www.google.ca/extern_js/f/CgJlbhICY2ErMFo4ACwrMA44ACwrMDA4ASwrMBg4ACyAAgSQAh4/18z1LT5kRl4.js" }, }Event Data
linethe line number in the specified URL that Firebug suspended on urlthe URL of the script that Firebug suspended on
[edit] onConsoleDebug
Fired when debug information is written to the console orconsole.debug()is used.
Content-Length:118 \r\n\r\n { "type":"event", "event":"onConsoleDebug", "context_id":"xf0.3::815374", "seq":116, "data":["I am a console debug entry"] }Event Data
datathe debug information written to the console
[edit] onConsoleError
Fired when an error is written to the console orconsole.error()is used.
Event Data
datathe error information and stack written to the console
[edit] onConsoleInfo
Fired when information is written to the console orconsole.info()is used.
Content-Length:100 \r\n\r\n { "type":"event", "event":"onConsoleInfo", "context_id":"xf0.3::815374", "seq":123, "data":["I am info"] }Event Data
datathe log information written to the console
[edit] onConsoleLog
Fired when a log entry is written to the console orconsole.log()is used.
Content-Length:106 \r\n\r\n { "type":"event", "event":"onConsoleLog", "context_id":"xf0.3::815374", "seq":106, "data":["I am a log entry"] }Event Data
datathe log information written to the console
[edit] onConsoleWarn
Fired when a warning is written to the console orconsole.warn()is used.
Content-Length:105 \r\n\r\n { "type":"event", "event":"onConsoleWarn", "context_id":"xf0.3::815374", "seq":100, "data":["I am a warning"] }Event Data
datathe warning written to the console
[edit] onContextCreated
Fired when a new context is created in Firebug (ex: A new tab was opened and firebug was activated).
Content-Length:142 \r\n\r\n { "type":"event", "event":"onContextCreated", "context_id":"xf0.3::558234", "body":{ "href":"http://www.mozilla.com/en-US/firefox/central/" }, }Event Data
hrefthe URL of the page that has been loaded (activated)
[edit] onContextChanged
Fired when the browser is loaded and a context is switched to without having been loaded
Content-Length:181 \r\n\r\n { "type":"event" "event":"onContextChanged", "context_id":"xf0.3::8127619", "body":{ "new_href":"http://www.google.ca/advanced_search?hl=en", "href":"http://www.ubuntulinux.org/" }, }
Event Data
new_hrefthe URL of the context that was switched to hrefthe URL of the context that was switched from
[edit] onContextDestroyed
Fired when a Firebug has destroyed a context (ex: Deactivate firebug has been pressed on a tab)
Content-Length:75 \r\n\r\n { "type":"event", "event":"onContextDestroyed", "context_id":"xf0.3::8127624", }Event Data
There is no additional data for this event. The context that has been destroyed is the one specified in the
context_idparameter.
[edit] onContextLoaded
A new context (page) has been loaded. Typically this event is sent after a new tab is opened.
Content-Length:141 \r\n\r\n { "type":"event", "event":"onContextLoaded", "context_id":"xf0.3::558234", "body":{ "href":"http://www.mozilla.com/en-US/firefox/central/" }, }Event Data
hrefthe URL of the context that was loaded
[edit] onInspectNode
Fired when Firebug is in 'Inspect Mode' and DOM elements are inspected. The event contains the path to the DOM element being inspected at the time the even was fired.
Content-Length:186 \r\n\r\n { "type":"event", "event":"onInspectNode", "context_id":"xf0.3::7640266", "seq":66, "data":{ "node":"/html[1]/body[1]/div[1]/div[4]/div[1]/div[1]/div[2]/div[2]/div[7]/div[1]/span[2]/span[1]" } }Event Data
nodethe complete unique path to the element being inspected in the DOM.
[edit] onResume
Fired when a context is resumed (after being suspended)
Content-Length:75 \r\n\r\n { "type":"event", "event":"onResume", "context_id":"xf0.3::8127621", }Event Data
There is no additional event data. The context that has been resumed in the one specified in the
context_idparameter.
[edit] onScript
Fired when a new script is compiled.This event has been updated in Crossfire version 0.3a5, please see the migration guide entry for details.
Content-Length:631 \r\n\r\n { "seq":10, "type":"event", "event":"onScript", "context_id":"xf0.3::2531266", "data":{ "script": { "id":"http://www.google.ca/advanced_search?hl=en", "lineOffset":0, "columnOffset":0, "sourceStart":"(function()\u000a", "sourceLength":311, "lineCount":311, "compilationType":"top-level" } } }Event Data
scriptthe object describing the script that was loaded ida String identifier for the script - never null lineOffseta Number representing the line offset of the script - never less than 0 columnOffseta Number representing the column offset of the script - never less than 0 sourceStarta String representing the first line of source in the script - never null sourceLengtha Number representing the entire length of the source of the script - never less than 0 lineCounta Number representing the total number of lines of source in the script - never less than 0 compilationTypea String describing the kind of the script - see sourceFile.js for complete listing of types
[edit] onToggleBreakpoint
Fired when a breakpoint is created or removed.This event has been updated in Crossfire version 0.3a5, please see the migration guide entry for details.
Content-Length:150 \r\n\r\n { "seq":26, "type":"event", "event":"onToggleBreakpoint", "context_id":"xf0.3::2531266", "data":{ "handle":4, "set":false, "location":{ "line":2, "url":"http://www.google.ca//event/seq/1" } } }Event Data
locationthe Object describing the location of the breakpoint that was toggled settrue if the breakpoint was created (toggled on) false if the breakpoint was removed (toggled off)
[edit] onToggleDOMBreakpoint
Fired when an HTML breakpoint is enabled or disabledThis event has been updated in Crossfire version 0.3a5, please see the migration guide entry for details.
Content-Length:135 \r\n\r\n { "seq":27, "type":"event", "event":"onToggleDOMBreakpoint", "context_id":"xf0.3::2531266", "data":{ "handle":5, "type":1, "location":{ "xpath":"/html/head/title", } } }Event Data
locationthe Object describing the location of the breakpoint that was toggled settrue if the breakpoint was created (toggled on) false if the breakpoint was removed (toggled off)