Crossfire 0.3a4 Protocol Reference

From FirebugWiki

Revision as of 18:09, 14 March 2011 by Mrennie (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Crossfire Protocol Reference

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

If crossfire was started as a server it will reply with an acknowledgement that matches CrossfireHandshake\r\n.

New in 0.3a2

The server acknowledgement matches CrossfireHandshake\r\n\r\n.

New in 0.3a3

The server acknowledgement will include an additional line that is a comma-separated list that indicates the Tools available to the server. Such as CrossfireHandshake\r\n dom,inspector,net\r\n.

A client may request certain tools to be activated upon connection by specifying them after the handshake in the same fashion.

New in 0.3a5

Breakpoint objects are changing shape.

Previously they were an object looking like:

{
  "handle": 1,
  "type": "line",
  "line":3,
  "target": "http://www.google.ca",
  "enabled": false,
 
}

In 0.3a5 they will take the form:

{
  "handle":1,
  "type":"line",
  "location":{"url":"http://www.google.ca","line":3},
  "condition":null,
  "enabled":false
}

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 CRLF (\r\n). Packets are terminated by a CRLF (\r\n) after the body.

Example:

Content-Length:69
\r\n
{
  "context_id":null,
  "type":"request",
  "seq":1,
  "command":"listcontexts"
}\r\n


Version 0.3 adds an extra CRLF (\r\n) between the headers area and the content to be more like HTTP:

Example:

Content-Length:69
\r\n\r\n
{
  "context_id":null,
  "type":"request",
  "seq":1,
  "command":"listcontexts"
}\r\n

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"

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_length the entire length of the packet content between the curly braces (including the curly braces)
command the name of the request. A complete listing of requests that can be used in <command> are available in the Commands section.
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
arguments_list the 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

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_length the entire length of the packet content between the curly braces (including the curly braces)
command the name of the original request
context_id the id of the context this response came from
packet_sequence the packet sequence number
request_sequence the request sequence number
body_object JSON object containing additional data about the response
running if Crossfire is in a running state
success if 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

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>}
\r\n

Arguments

content_length the entire length of the packet content between the curly braces (including the curly braces)
event the name of the event. A complete listing of events that can appear in <event> are available in the Events section.
context_id the id of the context this event came from
packet_sequence the packet sequence number
data_object JSON 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/"
         }
}
\r\n

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.

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>}
                       }
             }
}

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()"
               }
}

boolean

A boolean is represented as:

{
  "myboolean":{
                "type":"boolean",
                "value":<true_or_false>
              }
}

number

A number is represented as:

{
  "mynumber":{
               "type":"number",
               "value":<number>
             }
}

string

A string is represented as:

{
  "mystring":{
               "type":"string",
               "value":"string_value"
             }
}

undefined

An undefined value is represented as:

{
  "myfunction":"undefined"
}

null

A null value is represented as:

{
  "mystring":null
}

Commands

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\n

Arguments

content_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
from_frame an optional argument that indicates what frame to start the backtrace from. If this is not specified, zero is assumed.
to_frame an optional argument that indicates what frame to end the backtrace at. If this is not specified, the total frame count is assumed.
include_scopes an 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: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:9268
\r\n\r\n
{
  "type":"response",
  "command":"backtrace",
  "context_id":"xf0.3::8265383",
  "seq":6,
  "request_seq":5,
  "body":{
           "context_id":"xf0.3::8265383",
           "fromFrame":0,
           "toFrame":0,
           "totalFrames":1,
           "line":19,
           "scopes":[{"index":0,"frameIndex":0,"object":{"type":"ref","handle":18}}]},
           "frames":[{
                      "index":0,
                      "func":"anonymous",
                      "script":"http://www.mozilla.org/script/1.0/jquery-1.3.2.min.js",
                      "locals":{"type":"object","value":{},"this":{"type":"object","value":{"addEventListener":{"type":"function","handle":4},...}}}
                    }],
         },
  "running":false,
  "success":true,
}

changebreakpoint

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":"changebreakpoint",
  "context_id":<context_id>,
  "seq":<packet_sequence>,
  "arguments":{"breakpoint":<breakpoint>}
}
\r\n

Arguments

content_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
breakpoint a required argument that specifies the handle of the breakpoint to change

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":{"breakpoint":7},
}
\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":{},
  "running":true,
  "success":false
}

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":{
                "target":<target>,
                "line":<line>
              }
}
\r\n

Arguments

content_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
target a required argument that specifies the URL of the script to clear the breakpoint from
line a required argument that specifies the line to clear the breakpoint from in the given target

Example Request

An example of the request you send:

Content-Length:194
\r\n\r\n
{
  "type":"request",
  "command":"clearbreakpoint",
  "context_id":"xf0.3::6179868",
  "seq":9,
  "arguments":{
                "target":"http://www.mozilla.com/includes/yui/2.5.1/animation/animation-min.js", 
                "line":8
              },
}
\r\n

Example Response

An example of the response you receive:

Content-Length:187
\r\n\r\n
{
  "command":"clearbreakpoint",
  "context_id":"xf0.3::6179868",
  "type":"response",
  "seq":13,
  "request_seq":9,
  "body":{
           "context_id":"xf0.3::6179868",
           "breakpoint":18
         },
  "running":true,
  "success":true
}

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_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
stepaction an optional argument in crossfire 0.3 and greater, required for 0.2a* and lower. The value can be one of in, next, or out. 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
}

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_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
expression a required argument that specifies the expression to evaluate
frame a 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
         }
}

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\n

Arguments

content_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
frame a required argument that specifies the index of the frame to look up
include_scopes an 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
}

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":{"breakpoint":<breakpoint>}
}
\r\n

Arguments

content_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
breakpoint a 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":{"breakpoint":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",
           "line":7,
           "target":"http://www.mozilla.com/includes/yui/2.5.1/animation/animation-min.js"
         },
  "running":true,
  "success":true
}

getbreakpoints

Return all the breakpoints in this context.
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":"getbreakpoints",
  "context_id":<context_id>,
  "seq":<packet_sequence>,
}
\r\n

Arguments

content_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the 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:312
\r\n\r\n
{
  "type":"response",
  "command":"getbreakpoints",
  "context_id":"xf0.3::6179868",
  "seq":13,
  "request_seq":12,
  "body":{
           "context_id":"xf0.3::6179868",
           "breakpoints":[{
                            "handle":27,
                            "type":"line",
                            "line":7,
                            "target":"http://www.mozilla.com/includes/yui/2.5.1/yahoo-dom-event/yahoo-dom-event.js"
                         }]
         },
  "running":true,
  "success":true
}

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\n

Arguments

content_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
xpath an optional argument specifying the xpath to the node to inspect.
selector an optional argument specifying the selector of the node to inspect

One of xpath or selector must be specified. If both are specified, xpath is 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
}

listcontexts

Returns a list of context id's. This command does not require a context_id field.
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_length the entire length of the packet content between the curly braces (including the curly braces)
packet_sequence the 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
}

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\n

Arguments

content_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
handle a required argument that indicates what object to look up
include_source an 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,
}

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_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
scope_number a required argument thats indicates which scope to get from the scopes listing. If scope_number is 0, the global scope is returned. If scope_number is NaN or outside the range of scopes no scope information is returned.
frame_number a 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
}

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_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
frame_number a 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
}

script

Retrieve a single script
The 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_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
include_source a required argument that indicates if the source for the requested script should be returned in the response
script_url a 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\n

Example 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,
 
}

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_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
include_source a 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,
}

setbreakpoint

Set a breakpoint and return its 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":"setbreakpoint",
  "context_id":<context_id>,
  "seq":<packet_sequence>,
  "arguments":{
                "target":<target>,
                "line":<line>
              }
}
\r\n

Arguments

content_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the packet sequence number
target a required argument that specifies the URL of the script to set the breakpoint in
line a required argument that specifies the line to set the breakpoint on in the given target

Example Request

An example of the request you send:

Content-Length:192
\r\n\r\n
{
  "type":"request"
  "command":"setbreakpoint",
  "context_id":"xf0.3::6179868",
  "seq":5,
  "arguments":{
                "target":"http://www.mozilla.com/includes/yui/2.5.1/animation/animation-min.js",
                "line":8
              }
}
\r\n

Example Response

An example of the response you receive:

Content-Length:298
\r\n\r\n
{
  "type":"response",
  "command":"setbreakpoint",
  "context_id":"xf0.3::6179868",
  "seq":9,
  "request_seq":5,
  "body":{
           "context_id":"xf0.3::6179868",
           "breakpoint":{
                          "handle":22,
                          "type":"line",
                          "line":8,
                          "target":"http://www.mozilla.com/includes/yui/2.5.1/animation/animation-min.js"
                        }
          },
  "running":true,
  "success":true,
}

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_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the 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
}

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_length the entire length of the packet content between the curly braces (including the curly braces)
context_id the id of the context this request is targeted for
packet_sequence the 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
}

version

Returns the Crossfire protocol version. This command does not require a context_id field.
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_length the entire length of the packet content between the curly braces (including the curly braces)
packet_sequence the 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\n

Example 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
}

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

href A 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\n

Example 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
}

Events

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

line the line number in the specified URL that Firebug suspended on
url the URL of the script that Firebug suspended on

onConsoleDebug

Fired when debug information is written to the console or console.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

data the debug information written to the console

onConsoleError

Fired when an error is written to the console or console.error() is used.
 

Event Data

data the error information and stack written to the console

onConsoleInfo

Fired when information is written to the console or console.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

data the log information written to the console

onConsoleLog

Fired when a log entry is written to the console or console.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

data the log information written to the console

onConsoleWarn

Fired when a warning is written to the console or console.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

data the warning written to the console

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

href the URL of the page that has been loaded (activated)

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_href the URL of the context that was switched to
href the URL of the context that was switched from

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_id parameter.

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

href the URL of the context that was loaded

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

node the complete unique path to the element being inspected in the DOM.

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_id parameter.

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:192
\r\n\r\n
{
  "type":"event",
  "event":"onScript",
  "context_id":"xf0.3::8127620",
  "body":{
           "context_href":"http://www.google.ca/advanced_search?hl=en/4",
           "href":"http://www.google.ca/advanced_search?hl=en"
         }
}

Event Data

context_href the URL of the script
href the URL of the context that encloses the script

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:153
\r\n\r\n
{
  "type":"event",
  "event":"onToggleBreakpoint",
  "context_id":"xf0.3::7640268",
  "seq":20,
  "data":{
           "url":"http://localhost:8080/js/e4.js",
           "line":19,
           "set":true
         }
}

Event Data

url the URL of the script the breakpoint was toggled in
line the line number the breakpoint was toggled on
set true if the breakpoint was created (toggled on) false if the breakpoint was removed (toggled off)
Personal tools