Firefox 7 Posts Booleans as Integers

I have lost nearly all respect for the browser I once loved. Mozilla used to provide an exemplary browsing experience that surpassed that of all other browsers. Today Google Chrome is my browser of choice as Firefox continues on its downward spiral. Mozilla is doing nothing but playing catch up these days, trying desperately to be just like Chrome. The once stable browsing experience I used to enjoy with Firefox is now reminiscent of the IE browsing experiences of old. They stray from common standards "fixing" things that aren't even broken and releasing so many new versions so often that you might as well forget about downloading plugins or addons.

Now they've gone and made a change in Firefox 7 that is so very tiny yet so very annoying. Javascript Booleans are no longer POSTed as "true" or "false. Instead they are now posted as "1" or "0". It's the tiniest difference and it completely broke many of my applications utilizing AJAX. My server-side code often attempts to convert form strings into C# Boolean variables and everywhere that is happening I am now getting conversion exceptions because it can't turn the string "0" into a false. Convert.ToBoolean is perfectly happy converting "false", "true", 1, 0 to a Boolean, but unfortunately it does not handle string versions of the integers. This is very annoying. Now in every app I either have to modify the javascript:

$.ajax({ url: 'some url', data: { someBool: true }, type: 'post' });

I now have to use string values.

$.ajax({ url: 'some url', data: { someBool: 'true' }, type: 'post' });

Or I have to modify the server-side code to interpret string integers as Booleans.
This simple line:

bool myBool = Convert.ToBoolean(Request["someBool"]);  

Now has to be:

bool myBool;  
switch (Request["someBool"])  
{
    case "0":
        myBool = false;
        break;
    case "1":
        myBool = true;
        break;
    default:
        myBool = Convert.ToBoolean(Request["someBool"])
        break;
}

It is unfortunate that C# Convert.ToBoolean can't handle "0" but it's more unfortunate that Mozilla feels the need to fix things that were never broken. I think for the first time ever I actually favor Chrome and Safari as my top two favorite browsers. Firefox is no longer the sleek alternative to Internet Explorer. In fact, I think Firefox is actually more bloated than IE 9 these days. That's something I never thought I'd find myself saying. It runs slower than all the browsers I have installed.

Anyway, if you are developing a site and posting back Booleans just be aware that Firefox no longer intuitively handles these values and don't get confused when you code works in all browsers except Firefox 7.

Chev

Read more posts by this author.

comments powered by Disqus