Remote Debugging JavaScript

Shaver and I have been talking about getting a decent mechanism for remote debugging a JavaScript session. I have been looking at JSSH. It’s a bit dated, but a great little Firefox/Mozilla extension that adds a huge amount of external flexibility, control and extensibility. The Watir-based web testing system for Firefox (called FireWatir) uses JSSH to control the current Firefox browsing session. The big downside to JSSH is that it has binary components, so you need to build it across platforms and Gecko versions. Yuck!

I have been working on a pure JavaScript version in my spare time, but I can throw that away now that ActiveState’s Shane Caraveo has released an early alpha (called SD Connect) of the same concept. Actually, Shane has a bit more than I had planned, but that doesn’t bother me. Comment’s on Shane’s post pointed me to the MozRepl project as well. I had heard of MozRepl a while ago and I’m kicking myself for forgetting about it.

My goals for remote debugging are a bit different than Shane’s, but there is plenty of overlap. I want to use remote JavaScript debugging to aid in Mozilla’s mobile browser development. I also want to use remote debugging for extension and XUL application development. I realize I may be the anomaly, but a Firebug-like component is _not_ my ideal debugger for chrome (application) JavaScript. For web content JavaScript, sure, but I have Heisenberg uncertainty issues with using a debugger that is itself in the system I am debugging. Therefore, I am very eager to start playing around with SD Connect and MozRepl.

Also, Yay for OpenKomodo spin-offs!

Extension Developers – about:addons Newsletter

Mozilla is starting a new newsletter, about:addons, strictly for add-on related development and hosting. A lot of changes were made to the way extensions are built and hosted during the last Firefox / Mozilla release cycle. Many changes and new features have been happening on AMO as well. It can be hard to keep track of the add-on related changes with all the other types of information coming out of Mozilla, on MDC or blogged on Planet Mozilla. With that in mind, it was decided that a dedicated newsletter could be the best way to get add-on information to add-on developers.

Deb Richardson started the about:mozilla newsletter about seven months ago and it has been a great way for community members to keep informed about news in the Mozilla ecosystem. We’d like to create the same kind of success with about:addons.

Dave Townsend covered some of the details in his post. Use the sign up page to subscribe. The newsletter is primarily an email-based service, but we will post it on DevNews weblog too.

We hope to get the first newsletter out sometime next week. We’ll post more information about submitting news as we get things nailed down. For now, feel free to leave comments about what you want to see.

Update: It seems MailChimp, the service we’re using, is down for maintenance. I was hoping the subscription functionality would not go down during the upgrade maintenance window, but it did. Everything should be back online Monday morning (5/19 9am EST). Sorry for the inconvenience.

Firefox 3 – Parental Controls

[Thanks to Jim Mathies, Firefox developer, for writing this post – with minor edits]

Firefox 3 will have some support for Parental Controls on Vista (see bug 355554). The download manager is now aware of situations where content gets blocked by proxies. Downloads that are blocked display correct UI message to indicate what happened.

A good example would be a right-click Save As on an image link that’s offensive. Something like that might get blocked by a proxy, so we handle that case correctly in the download manager.

As for the main browser area, inline display of offensive content tends to be handled by the proxies themselves, so that content downloaded by the browser will get replaced by some sort of “blocked message” content, or it’ll simply be displayed as a broken image. In general, we rely on proxy blocking in the main window right now. This is something we want to eliminate down the road by detecting blocked content before we issue the request and display our own message.

In preparation for that and for more general use, we now have an interface (nsIParentalControlsService) that interacts with the operating systems parental controls services, so extension developers and XULRunner apps can respect local parental controls restrictions.

Currently, we support querying of application level flags like file blocking, logging of blocked content, and requesting overrides for a single or list of URIs. We don’t yet support for querying whether a particular URI will be blocked, but we’ll be adding that soon. Until then, developers can rely on HTTP status results to detect blocked downloads.

Looking forward to Firefox 3.x, we’ll have better support for inline blocked content, and we’ll be adding checks of file blocking flags in other places, like the extension manager. We weren’t able to get that in this release because it required UI changes and parental control support was added pretty late in the release cycle.

[thanks Jim]

FUEL and Google SoC

Samer Ziadeh will be working on a Summer of Code project to enhance FUEL. He is looking at some feature requests found in bugzilla, bug 406974 and bug 409279 specifically. Samer has already done some work with FUEL. The past semester, he ported much of the code to work in Firefox 2. It wasn’t a perfect fit as Firefox 2 is missing some integral new functionality supported in Firefox 3. Without it, backporting to Firefox 2 became difficult.

Samer will be hanging out on IRC in #extdev, so be sure to give him some encouragement (and a feature request or two).

Do You Smell Something?

Oh yeah, it’s this crappy post from ReadWriteWeb on the new Google Maps Flash API. I have no problem with a Flash API for Google Maps. Power to the people! But I did have a massive gag reaction to the following fairy tale:

A substantial portion of the web’s creativity can be found in the Flash developer community. Adobe’s AIR platform is one of the hottest development environments in the consumer market today and is being deployed with increasing frequency in the enterprise as well. Live Google Maps in Flash are likely to be used in even more creative ways than the existing javascript API has been. Javascript can be used in AIR but it’s rarely used as attractively as Flash often is.

It doesn’t end there, although my ability to keep food down did:

Throw some Flash Google Maps into the mix and things are liable to really get interesting.

  • Are you kidding me? Hey, I’m glad Flash is open, but I have no love for an alternate Web.
  • More creative ways than the JS APIs? Haven’t seen any creative uses of JS have you?
  • One of the hottest development environments? For making Twitter clones?

The rest of the post is great!

Extension Developers – Your Final MaxVersion Update

Extension Developers! Yeah, You!

AMO has flipped the switch to support MaxVersion “3.0.*” so make those final version updates now. Firefox 3 RC1 is releasing very, very soon. Yes, “3.0.*” is the final MaxVersion you’ll need for Firefox 3, so don’t delay.

Copied for your reading pleasure:

What this means for you as an add-on author is that after you test with the Firefox 3 release candidates, you can use the Developer Tools section on AMO to bump your version number without having to upload a new version of your add-on.

For completeness, if you want to support Firefox (and none of the alpha’s, betas and pre-releases), here are the recommended version ranges (minVersion – maxVersion) to use:

  • Firefox 2: 2.0 – 2.0.0.*
  • Firefox 3: 3.0 – 3.0.* (Note: that with Firefox 3, it’s a three part version number)

Yay! for the end of update madness! Now go and do it!

Firefox 3 – Offline App Demo – Part 2

Last year (wow, that long ago?) I made a simple demo to show Firefox 3 offline capabilities. A lot has changed between then and now. Firefox 3 offline capabilities changed significantly to align better with WHATWG offline specification. The biggest changes involve dropping support for our own <link rel="offline"> mechanism and supporting WHATWG manifests and application cache. The specification gives some details on how it works. There is an MDC article on using offline resources in Firefox 3.

Since so much has changed, I decided to update the demo application. Here is the overview of the application, updated where needed:

A Simple Demo – Task Helper

The application is a simple task list system. The current functionality includes:

  • Add tasks – Enter text in field and press ‘Add’
  • Complete tasks – Mark completed tasks and press ‘Complete’
  • Remove tasks – Mark tasks and press ‘Remove’
  • Data is stored as JSON and XHR is used to interact with server (PHP)

offline demo app

Nothing fancy. However, the application is “offline-aware”, meaning:

  • Application resources (HTML & JS) are listed in the offline cache manifest. This manifest must be served as “text/cache-manifest” and follow the manifest rules.
  • Before interacting with server, online status is checked. If online, use XHR. If offline, use DOMStorage.
  • Online/Offline status is monitored using events. When the application switches from offline to online, data is resync’ed with the server.

There is really nothing fancy about the offline stuff either, but putting it all together does make for a neat application. Using the latest Firefox 3 (beta 5 or nightly), you should be able to:

  • Use the application while online.
  • Go offline using the “Work Offline” menu. The event log should show that the app went offline.
  • Continue to use the application while offline.
  • Restart browser.
  • Switch to offline (or have no network connection).
  • Enter URL to app (or use a bookmark).
  • Start using app with data from last session.
  • Switch to online. The event log should show that the app is back online and has updated the server with any offline changes.

Try it: Task Helper
Source code:

Note: The data is stored in a simple, shared JSON file on the server, managed with a simple PHP file and reset every hour. No fancy databases with multiple session support.

A Little XPCOM Magic – JavaScript Callbacks

XPCOM is, currently, a core Mozilla technology. Developers use XPCOM for a variety of reasons, many of which result in XPCOM components being accessed from JavaScript. XPCOM uses IDL to describe interfaces. This can make XPCOM components a bit rigid and not feel right in JavaScript. Recent support for optional parameters in IDL has helped a little. Another helpful concept is using JavaScript functions in place of an IDL callback interface. For example:

[scriptable, uuid(...)]
interface StringParserObserver {
  void onWord(string word);

[scriptable, uuid(...)]
interface StringParser {
  void parse(string data);
  void addObserver(StringParserObserver observer);

In order to use this interface from JavaScript, you would have to implement the StringParserObserver using JavaScript. A nicer approach would be to allow someone to pass in a JavaScript function to use as the callback. The good news is you can! Better news is that it is a one line change to your IDL!

Just add the “function” attribute to the interface and XPCOM will handle the rest.

[scriptable,function, uuid(...)]
interface StringParserObserver {
  void onWord(string word);

There is a new MDC article with more details here.