Blog

Nokia WRT, Aptana, Firefox and cross site javascripts

I wanted to share 2 tips when developing Nokia Web Run-time apps (WRT) using Aptana studio and the Nokia plugin.

Your preview browser in Aptana matters

One thing I was puzzled is that I couldn’t get widget.preferenceForKey to work on my Aptana (running on a MAC). It seems that there is a problem with widget.preferenceForKey when Safari is configured as the preview app in Aptana Studio -> preferences -> Web Runtime – > preview. It just returns undefined when getting the preference for any key. I switched to Firefox and it solved the problem. Alas, it created a new problem. See next item.

Cross site scripting with Firefox when debugging you app on the Emulator

Unlike Safari, Firefox does not allow cross site scripts and when trying to execute an AJAX call from the widget you get “Access to restricted URI denied”  code: “1012″ error in your Aptana console.

The way to solve it is to add the following statement before you AJAX calls: netscape.security.PrivilegeManager.enablePrivilege(”UniversalBrowserRead”); when running the app in the emulator and removing it from the code before deploying the app on a real phone.

You also need to set ’signed.applets.codebase_principal_support’ to true in about:config, then your script will pass all domain security checks. Don’t forget to remove the line when you’re finished testing.

2 people like this post.

Leave a Reply