net.rim.device.api.browser.field2.debug
Class BrowserFieldDebugger

java.lang.Object
  extended by net.rim.device.api.browser.field2.debug.BrowserFieldDebugger

public abstract class BrowserFieldDebugger
extends Object

This abstract class allows a developer to debug web content running within a BrowserField API application.

To use this functionality within your application, extends this class and override any subset of methods in order to capture various debug information. The default implementation of each method in this class is empty so overriding a method will have no unintended side-effects to your application. In order to register your debugger implemenation to recieve notifications, pass it to BrowserField.setDebugger().

Use caution when setting a debugger on your BrowserField instance as it can cause significant performance degradation.

Please note that if you are using your own implementation of BrowserFieldConnectionManager, then you must call notifyHttpTraffic() from your class in order for your BrowserFieldDebugger to be notified of HTTP traffic.

Since:
BlackBerry API 5.0.0

Field Summary
static int CONTENT_ARTWORK
          Content type value for image resources being sent to registerContent() method
static int CONTENT_CSS
          Content type value for CSS resources being sent to registerContent() method
static int CONTENT_HTML
          Content type value for HTML resources being sent to registerContent() method
static int CONTENT_JAVASCRIPT
          Content type value for JavaScript resources being sent to registerContent() method
static int CONTENT_OBJECT
          Content type value for Object resources being sent to registerContent() method
static int CONTENT_XHR
          Content type value for XMLHttpRequest resources being sent to registerContent() method
 
Constructor Summary
BrowserFieldDebugger()
           
 
Method Summary
 void handleStep(BrowserFieldDebugContext context)
          This method is invoked when the JavaScript engine has stepped to another line of code and suspended execution until it is programmatically resumed.
 void hitBreakpoint(BrowserFieldDebugContext context)
          This method is invoked when a breakpoint is hit and the JavaScript engine has suspended execution until it is programmatically resumed.
 void notifyCompileError(String scriptUrl, String errorMessage, String scriptSource, int lineNumber, int character, boolean inEval)
          This method will be invoked when a JavaScript compile error occurs.
 void notifyHttpTraffic(HttpConnection connection, Hashtable requestHeaders)
          This method is invoked for each successful HTTP connection made.
 void pageCompletedLoading(String pageUrl)
          This method is invoked when a page has completed loading
 void pageRequested(String url)
          This method is invoked for each new page that is requested
 void registerContent(int contentType, String url, byte[] content)
          This method is invoked when new content for a particular resource is received.
 void registerInlineScript(BrowserFieldScript script)
          This method is invoked for each internal or eval'd script that is successfully compiled
 void registerScript(BrowserFieldScript script)
          This method is invoked for each external script that is successfully loaded and compiled
 void reportException(BrowserFieldDebugContext context)
          This method is invoked when a JavaScript runtime exception occurs.
 void resourceLoadCompleted(String pageUrl, int contentType, String resourceUrl, long loadStart, long loadEnd, long numBytes)
          This method is invoked when a resource has completely loaded and will not be receiving new content
 void xmlHttpRequestAbort(int requestId)
          This method is invoked when an XMLHttpRequest (XHR) object request is aborted
 void xmlHttpRequestRequest(int requestId, String requestUrl, HttpHeaders headers, String method, String data)
          This method is invoked when an XMLHttpRequest (XHR) object request is initiated from JavaScript
 void xmlHttpRequestResponse(int requestId, String response, int statusCode, HttpHeaders headers)
          This method is invoked when a response for an XMLHttpRequest (XHR) object request is received
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

CONTENT_HTML

public static final int CONTENT_HTML
Content type value for HTML resources being sent to registerContent() method

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

CONTENT_JAVASCRIPT

public static final int CONTENT_JAVASCRIPT
Content type value for JavaScript resources being sent to registerContent() method

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

CONTENT_CSS

public static final int CONTENT_CSS
Content type value for CSS resources being sent to registerContent() method

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

CONTENT_ARTWORK

public static final int CONTENT_ARTWORK
Content type value for image resources being sent to registerContent() method

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

CONTENT_XHR

public static final int CONTENT_XHR
Content type value for XMLHttpRequest resources being sent to registerContent() method

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

CONTENT_OBJECT

public static final int CONTENT_OBJECT
Content type value for Object resources being sent to registerContent() method

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0


Constructor Detail

BrowserFieldDebugger

public BrowserFieldDebugger()
Since:
BlackBerry API 5.0.0


Method Detail

notifyCompileError

public void notifyCompileError(String scriptUrl,
                               String errorMessage,
                               String scriptSource,
                               int lineNumber,
                               int character,
                               boolean inEval)
This method will be invoked when a JavaScript compile error occurs.

Parameters:
scriptUrl - the URL of the script
errorMessage - the compile error message
scriptSource - the source of the code that failed to compile
lineNumber - the line number from the source where the failure occurred
character - the character number from the source where the failure occurred
inEval - specifies whether or not this compile error occurred in an eval() method call
Since:
BlackBerry API 5.0.0

notifyHttpTraffic

public void notifyHttpTraffic(HttpConnection connection,
                              Hashtable requestHeaders)
This method is invoked for each successful HTTP connection made. This includes responses which may have error HTTP response codes.

Parameters:
connection - the HTTPConnection object containing information about the request/response
requestHeaders - the HTTP headers used to make the initial request (response headers can be obtained from the HTTPConnection object)
Since:
BlackBerry API 5.0.0

pageRequested

public void pageRequested(String url)
This method is invoked for each new page that is requested

Parameters:
url - the URL of the newly requested page
Since:
BlackBerry API 5.0.0

registerScript

public void registerScript(BrowserFieldScript script)
This method is invoked for each external script that is successfully loaded and compiled

Parameters:
script - the object containing script information and functionality to interact with that script (e.g. to set breakpoints)
Since:
BlackBerry API 5.0.0

registerInlineScript

public void registerInlineScript(BrowserFieldScript script)
This method is invoked for each internal or eval'd script that is successfully compiled

Parameters:
script - the object containing script information and functionality to interact with that script (e.g. to set breakpoints)
Since:
BlackBerry API 5.0.0

registerContent

public void registerContent(int contentType,
                            String url,
                            byte[] content)
This method is invoked when new content for a particular resource is received. This method may be called multiple times for a single resource.

Parameters:
contentType - the type of the content being received
url - the url of the resource to which this content belongs
content - a byte array of newly received content
Since:
BlackBerry API 5.0.0

resourceLoadCompleted

public void resourceLoadCompleted(String pageUrl,
                                  int contentType,
                                  String resourceUrl,
                                  long loadStart,
                                  long loadEnd,
                                  long numBytes)
This method is invoked when a resource has completely loaded and will not be receiving new content

Parameters:
pageUrl - the URL of the page for which this resource belongs
contentType -
resourceUrl - the URL of the resource
loadStart - a timestamp of when this resource began loading
loadEnd - a timestamp of when this resource finished loading
numBytes - the size of this resource in bytes
Since:
BlackBerry API 5.0.0

xmlHttpRequestRequest

public void xmlHttpRequestRequest(int requestId,
                                  String requestUrl,
                                  HttpHeaders headers,
                                  String method,
                                  String data)
This method is invoked when an XMLHttpRequest (XHR) object request is initiated from JavaScript

Parameters:
requestId - the unique identifier belonging to this request
requestUrl - the URL of the request
headers - the HTTP headers used to make the initial XHR request
method - the HTTP request method used (GET, POST, PUT ect)
data - the data sent in the body of the request
Since:
BlackBerry API 5.0.0

xmlHttpRequestAbort

public void xmlHttpRequestAbort(int requestId)
This method is invoked when an XMLHttpRequest (XHR) object request is aborted

Parameters:
requestId - the unique identifier belonging to this request
Since:
BlackBerry API 5.0.0

xmlHttpRequestResponse

public void xmlHttpRequestResponse(int requestId,
                                   String response,
                                   int statusCode,
                                   HttpHeaders headers)
This method is invoked when a response for an XMLHttpRequest (XHR) object request is received

Parameters:
requestId - the unique identifier belonging to this request
response - the response data recieved
statusCode - the status of the response (AKA response code where 200 == OK)
headers - the HTTP response headers received
Since:
BlackBerry API 5.0.0

pageCompletedLoading

public void pageCompletedLoading(String pageUrl)
This method is invoked when a page has completed loading

Parameters:
url - the URL of the completed page
Since:
BlackBerry API 5.0.0

reportException

public void reportException(BrowserFieldDebugContext context)
This method is invoked when a JavaScript runtime exception occurs. When this happens the JavaScript engine has suspended execution until it is programmatically resumed.

In order to resume the JavaScript engine, context.resume/stepOver/stepInto/stepOut() must be invoked.

Parameters:
context - the object containing information pertaining to the exception and the script running at the time of the exception
Since:
BlackBerry API 5.0.0

hitBreakpoint

public void hitBreakpoint(BrowserFieldDebugContext context)
This method is invoked when a breakpoint is hit and the JavaScript engine has suspended execution until it is programmatically resumed.

In order to resume the JavaScript engine, context.resume/stepOver/stepInto/stepOut() must be invoked.

Since:
BlackBerry API 5.0.0

handleStep

public void handleStep(BrowserFieldDebugContext context)
This method is invoked when the JavaScript engine has stepped to another line of code and suspended execution until it is programmatically resumed.

In order to resume the JavaScript engine, context.resume/stepOver/stepInto/stepOut() must be invoked.

Since:
BlackBerry API 5.0.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.