Categories: Mozilla Development

“View Source” broken on trunk

A bug of interest for me this week was bug 552636. Here’s how I went about trying finding out what was broken:

  1. I examined the infamous bug 469302 which Stappel claimed was back. From its patch, it was easy to see that viewSource.js could easily be the culprit yet again. This was my first look at viewSource.js :).
  2. Next, I looked its Hg annotations. The only changeset that looked suspicious to me was dao@33423. It looked like Dao had replaced getBrowser().webNavigation.sessionHistory with gBrowser.sessionHistory which seemed incorrect since he had replaced other instances of getBrowser().webNavigation with getWebNavigation(). So my idea was to switch this to getWebNavigation().sessionHistory. I made my changes, reran make, and voila!! Nothing changed, bug still present, moon still shining.
  3. My next thought was that perhaps I could get some insight from the bug Dao was working on that created this changeset (it gets me every time that the changeset hash is a link but has no special formatting to make it stand out on this page). This led me to bug 517755 and consequently, to the MDC browser and nsIWebNavigation – MDC pages. It wasn’t long afterwards that I concluded that this changeset most likely wasn’t the culprit (and that I needed to learn what the heck smart getters are all about).
  4. As a PHP developer, print_r and logging usually comes in handy every once in a while. Being new to Firefox chrome code however, I had no idea how to capture some debugging info (which is probably why I went around digging in changesets after finding the possible approximate bug location instead of getting some helpful information from the running code). I tried removing the try-catch block – nothing showed up on the console, and inserting lots of services.log(…) lines (or something like that straight out of MXR) around the “suspicious” code – nothing showed up on the console.
  5. That was when I found Debugging a XULRunner Application – MDC. Perhaps the most important piece of info was to set the javascript.options.showInConsole pref, and in came Components.utils.reportError(typeof(arg)) and Components.utils.reportError(arg). That was when I discovered that typeof(arg) was now “function” and not “object” as viewSource expected, as reflected in the patch I attached to bug 552636. arg itself turned out to be “[object XPCNativeWrapper [xpconnect wrapped nsISupports]]”.

One of the fun things about tracking bugzilla is just how keenly people monitor some of these bugs. It was not long afterwards that Josh Mathews pointed out that the culprit had been bug 553407 all along! Now it’s time to dissect that patch and see exactly what this whole XPCNativeWrapper business is all about.

Article info



Leave a Reply

Your email address will not be published. Required fields are marked *