Tracking down finnair.com’s missing i

I guess Finnair is the household's favourite airline. I don't think I've used any other carrier during the last three years or so – we don't travel that much, so we're not talking many flights overall. However, it was rather annoying to find its website broken last time I wanted to look up some prices:

Finnair site auto-complete menu broken, error in console

After selecting a local site, the auto-complete menu to choose departure and destination cities from never populates. What's worse: the site doesn't accept anything you type in by hand! If you haven't made a menu selection, you get an error message! I'm sure that does wonders for their overall accessibility and section 508 compliance..

The error message complains that they refer to a variable "i" that doesn't exist. Somewhat wrapped, the code looks like this:

a.Autocompleter.Cache=function(c){
	var f={};
	var d=0;
	function h(k,j){
		if(!c.matchCase){
			k=k.toLowerCase();
		}
		if(!k.startsWith(j)&&k.indexOf(" "+j)===-1&&k.indexOf("("+j)===-1){
			return false;
		}
		return i==0||c.matchContains;
	}

The problem is the reference to i in the return statement. There is no variable "i" defined nearby, indeed not in the entire script file. That "i==0" looks like some dead code that isn't meant to be there anymore. But it works in other browsers, no?

If I load the page in Firefox and type javascript:alert(window.i) into the address bar it says "1", so in Firefox the site does somewhere create a global variable named i. The question is where?

Firebug can't – as far as I know – break when a variable is initialized or changed. As always, Fiddler comes to the rescue – setting a "HTTP breakpoint" after response and re-loading the site in Firefox lets me add some simple debug code:
Fiddler screen in breakpoint mode, debug code highlighted

window.__defineSetter__ ('i', function(){ try{ undefined() ; }catch(e){ console.log(e) ; } })

When I click Fiddler's "run to completion" button, an error message appears in Firebug's console pointing to this function:

function isFirefoxWMPPluginInstalled(){
	var plugs=navigator.plugins;
	for(i=0;
	i<plugs.length;
	i++){

which given its name is naturally called after some browser sniffing, here:

type:$.browser.mozilla&&isFirefoxWMPPluginInstalled()?"application/x-ms-wmp":"application/x-mplayer2"

So this works in other browsers by pure luck – because JavaScript scoping rules are such that when you don't use "var" keyword to declare variables, they will be global, and Fnnar's code contains numerous loops that use "i" as a counter and don't use var. If such a loop happens to run before you try booking, the site will work for you. As if we needed any more evidence that JavaScript scoping rules suck..

If we're going to site patch this error in browser.js, the patch would be simply var i;. At 6 characters, I'm fairly sure it would be the shortest site patch ever. Meanwhile, we'll contact them and hope Fnnar will get their "i"s back in order.

And I sure hope they deploy better software for their autopilot than their autocomplete…

Advertisements

15 thoughts on “Tracking down finnair.com’s missing i

  1. I hope "Fnnar" was a play on the lack of "i"'s. Great catch Hallvord! The only thing I can complain about is that Dragonfly isn't good enough to use for this situation…yet. 😉

  2. firebug does have conditional breakpoints which is not exactly what you want. But you could have set some lines to break when typeof(i) != 'undefined'

  3. Originally posted by fearphage:

    firebug does have conditional breakpoints which is not exactly what you want. But you could have set some lines to break when typeof(i) != 'undefined'

    Now translate that to Dragonfly. 😉 …when we get the same capabilities (as easily).

  4. When Dragonfly is good enough to break on the code that Opera doesn't run but if ran would have created the same state as some other browser, I'll be pretty impressed! ;)and yes, I should have tried to clarify the Fnnar pun :p

  5. (and I *hate* finding problems while I'm actually trying to *use* the web. Why does the airline industry churn out such crappy websites? 😦 )

  6. Originally posted by hallvors:

    Why does the airline industry churn out such crappy websites?

    Bank, grocery/department store, insurance/medical and university sites are all like that. It sucks. (Of course, you already know that more than most)

  7. Browsing the web and a site breaks and being the one that has to try to fix it must be fun ;)Also United Arlines sends cr@p to Opera (logging onto the united millage plus is a bit messed up) I think I am sent to the mobile version of the site on some parts of the site 😦

  8. Originally posted by Hallvord R. M. Steen:

    I *hate* finding problems while I'm actually trying to *use* the web

    Time to up that market share perhaps…

  9. hehe, Phred. Was it to company ownership that you were referring by that last comment?I think that you'd have to have a pretty substantial percentage ownership of a company before they would listen to you speaking as a shareholder.Hallvord, I agree that encountering poorly coded e-commerce websites is a frustrating experience, especially when you are actually wanting to do business (by buying goods or services via the site) and aren't just browsing to satisfy curiosity.

  10. Hallvord, I think that removing the letters from Finnair was obvious enough without you having to say that that is what you were doing. Doing what you did adds to the enjoyment level for readers of your blog. Language can be fun. Your blog entry was an example of that. If you had said something like "For the purpose of this blog, to emphasise the misplaced i, I will remove it from the name of the national airline" then the fun side of what you did would mostly have been lost. (I enjoy reading your blog.)

  11. MediaWrox writes:Thank you. I have filled the bug report to the current developers.Antti @ http://www.mediawrox.comps. Accessibility and 508 etc fails are mainly missing because of WebSphere Portal Server 5.1. ps. The autocomplete script loading cities is added after I ended client side development in march 2009

  12. Originally posted by BridgeBuilderKiwi:

    I think that you'd have to have a pretty substantial percentage ownership of a company before they would listen to you speaking as a shareholder

    Phred doesn't need to own anything, he's a user speaking from his heart and we'd be pretty dumb if we didn't listen to him.(If he also told us how we could have, say, 10% of the desktop web browsing market by next December the statement would have been even more worth listening to though :))Originally posted by anonymous:

    I have filled the bug report to the current developers.

    Thanks for doing so! I keep trying to plan 2010 and it's complicated enough without ad-hoc debugging 😉

  13. Yes, listening is usually a good idea, Hallvord.I must have interpreted Phred's statement incorrectly.Maybe I had doubted my understanding and subsequently chose to ask Phred the question.When I first read his statement about market share, I had thought that he might have been talking about purchasing shares in Finnair, and then contacting them as a shareholder.I don't know how I managed to get the concept of market share mixed up like that. :)Happy 2010

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s