Writing software, the wrong way

Wednesday, February 27, 2008

Using Venkman to combat terrorism and save freedom

Venkman has been a big help during this release, and it something that I want to share. I have been avoiding using a javascript for a while, and that's mainly because I opted to use alert() and dump() instead. But after a while, they both suck and can make debugging incredibly frustrating especially if you have to restart firefox each time to go one step ahead.

Introduction
It's been out since 0.9 folks!


Install
Grab the extension

Setting it up
  • Under Debug menu, make sure "Exclude Browser Files" is not checked.
  • Under the File menu, check "Save Break/Watch Settings on Exit".

Setting Breakpoints
This is reasonably simple. On the left are your files. Here I am debugging ProxyEnable.js.

Below it are the functions within that file. Double-clicking on the filename brings up the source code on the right.
  1. Place your breakpoints. The dashes near the left side of the source are where you can put your breakpoints. Here I am putting a breakpoint just before the if-statement.
  2. Exit venkman (this will close firefox)
  3. Relaunch firefox with -venkman argument. For example :
    /path/to/firefox -venkman --no-remote -profile /path/to/profile

Once you restart, venkman starts first and catches any breakpoints.

This is ideal when you can't use browser chrome to initiate the javascript, for example, js code that is executed on startup.

Fun
Once the debugger breaks, you have access to all the variables. So you can start investigating the problem much more effectively than with dump. You use the black window at the bottom as an interactive javascript shell.


Navigation
The buttons at the top let you go to the next line, go deeper into js functions, or continue. Try them out.


Now Code
No more excuses.

Saturday, February 23, 2008

x86_64 woes

I now have an amd64 (Sempron) desktop and an emt64 (Core 2 Duo) laptop and fully 64-bit and Y2K38 ready, which I am quickly finding out that it doesn't get it's share of love.

For example, Firefox/Thunderbird nightlies and OpenOffice don't have x86_64 builds. Now, if you have a 32-bit OS on a x86_64 architecture, it's ok and you can emulate. But if your running x86_64 without 32-bit libraries, your in trouble.

Fortunately, my desktop is equipped with Ubuntu, and the greatest package manager, ever.
All you should need to do is :

sudo apt-get install ia32-libs
sudo apt-get install ia32-gtk


This runs prism with a few warnings about an unsupported locale or something. Which is a lot better than compiling it from source.

My laptop however uses BlueWhite64, and I by slackwarian code (this is a complete lie), must compile everything from source. Unfortunately, here I don't have any of the 32-bit libs. So that's a lot of compiling. I wonder if it's even worth it. I'm fairly tempted to just skip it and download the i386 packages. But that would be taking the ubuntu way out, and I'm likely to get lynched by people like me.

Monday, February 18, 2008

Dynamic Proxy Settings

There were three things I was planning on doing for the previous release that didn't get finished, and something extra that I didn't plan on doing and probably won't be done (priorities and such) but interesting to know that it exists.

  • Proxy Settings using group policy

  • Disable changing the proxy settings

  • Create some Javascript Wrappers around the XPCOM components for locating/reading registry keys


Proxy Settings using Group Policy
This was something that almost everyone that commented said was an important policy to them. I think I only once had to ever use a proxy (I wanted to watch a John Stewart clip from a website then wouldn't let me in, so I had to proxy to an American server to view it). Regardless, if it's the most popular request, I'll do what I can.
I have it working for http:// sites. Still need to make changes for the other protocols. Mossop also taught me a lesson that <preferences> requires a <prefwindow>. That's going to be a problem when you have to use <overlay>'s instead of a prefWindow, so I had to use an nsIPrefBranch instead. On the lighter side, I can refactor and finally have an excuse to use FUEL.

Disable changing the proxy settings
nsIPrefBranch supports locking preferences so that the user cannot change them in about:config or in the UI (it will grey out the settings).

Unfortunately, you can only lock the default value. Which kinda sucks at the moment. The other two alternatives is to make the option of changing your proxy greyed out or hidden. IE7 has it's own tab for connection which completely disappears with the right policy enabled. Since Firefox's proxy settings is located in the same UI tab as offline storage, it is probably best for us to disable the button. To avoid allowing people to change the settings via about:config, we would have a policy to disable about:config access (get back to me on this, I don't have an answer on how we can do that yet).

Javascript Wrappers around the XPCOM components for locating/reading registry keys
I started doing some work on doing some JS wrappers around registry keys, since I dislike the current implementation to a certain degree. I won't go into details, because it's more of a preference then anything else.

I'll end with an amusing quotation.
And _please_ file bugs when you hit problems like this. I flunked long-distance widebeam telepathy in college, so I'm no good at just guessing that you're running into problems...
-- Boris Zbarsky

Wednesday, February 6, 2008

Generic IE policies in Firefox

This is something neat that I cannot take credit for. I just put it in a tree-friendly extension. I got the source onto an svn repository for people to play around with :

svn://cdot.senecac.on.ca/ff-ad

I put up some slightly more detailed steps into the wiki on how to set up Firefox. In the meantime, some explanation of what IE settings means for Firefox.

IE has several policies that Firefox can use, for example you can disable tabs and the help menu. Below we have the example of turning off the help menu

Ignore the bit about IE for a moment.

If you open up Firefox, you get the predicted results

Which is ok. If you look elsewhere, you'll see that not all the help functionality is disabled.

Which is something that still needs to be fixed. I also found some javascript errors that I would like to fix as well.

But the problem now is the overwhelming amount of policies in place. Mike's blog should help me out a fair bit with this, as he has got some response. More updates as this goes along.

==UPDATE==
So I was a little bit wrong. If you read the entire IE policy, it doesn't explicitly say that all help functionality will be turned off. To make a liar out of me, you can go into Options and click on the question mark at the top-right corner and help will popup. Just the help menu is disabled it seems (and F1).