Debugging Widgets using Java Console

All modern desktop browsers provide features to support developers debugging JavaScript. While the browsers don’t directly integrate true debugging support they usually support directing JavaScript error messages and logging statements to either a console display or popup messages. Mozilla Firefox supports this feature.

Consider the following trivial example of a web page with a JavaScript error. It calls the method document.writex() which does not exist.

<html>
<body>
<script language = "JavaScript">
document.write('Testing1<br/>\n');
document.writex('Testing2<br>\n');
</script>
Test Page
</body>
</html>

Go to Web > Settings > General and select the following option

• Java/ECMA Script

This option provides you support to enable/disable java script.

Enable

Enable Java Console Support

Disable

Disable Java Console Support

• Java/ECMA Script errors

This option provides you choices to display and log errors.

No Notification

Enable Java Console Support

Create Log file

It will create log file to the C:\Data folder of SDK

Show pop-up notes

It will show pop-up notes on the emulator screen

Log and pop-up notes

It will show pop-up notes and create logs to C:\Data folder of the SDK

Try to run the JavaScript example that has an error. Just like an ordinary browser, it will display error message based on your selected criteria from the web settings.

Below is the functional description of how this feature can be used.

  1. An option for JavaScript console is added to the Browser settings. There are three options for this setting: Disable, Prompt and Log.

    • When the Disable option is selected, the JavaScript console for browser / widgets are disabled.

    • When the Prompt option is selected, JavaScript errors and exceptions are presented in a popup dialog

    • When the Log option is selected, JavaScript errors and exceptions are logged into a text file that is placed in a user accessible area of the device’s file system. For example, C:\data

  2. JavaScript console supports console.log for logging messages to the console