how to break Youtube

Nearly three years ago, I noticed a site doing something like this:

div.getElementsByTagName('object')[0].SetVariable('foo', 'bar');

This worked in Firefox but not in Opera. In Opera the SetVariable() function was not yet defined by Flash when Opera got to that line – Flash was not finished initializing. Firefox basically paused the script on setting innerHTML until the Flash plugin was ready for scripting, while Opera didn't.

Hence this bug report:
CORE-6411 setting innerHTML should block until any added plugin instances are initialised
Reporter: Hallvord R. M. Steen Created: 2007-05-11 12:29

Perhaps it didn't sound that hard to fix back then, at first glance. I certainly submitted it with a certain optimism, thinking I had found an underlying issue for a cluster of related bug reports.

But that bug snowballed into several regressions and follow-up bugs and culminated with breaking Youtube on Wednesday..

How? Fixing that bug implied figuring out new logic for when the plugin object was ready for scripting, and implementing waiting for this state or pausing/resuming scripts in several places. We've had a number of problems with the JS engine hanging or throwing exceptions in certain scenarios afterwards. Not being able to switch videos on CNN, not being able to click links on And when Youtube released this code (where b points to an OBJECT or EMBED with a Flash movie):

if(b&&"GetVariable"in b) 

…it became painfully obvious that we had not tested using the "in" operator on plugin objects, because simply using "in" put the plugin object into a state where calling GetVariable() would fail. Ouch. A very bad bug – the sort of thing IE tends to do, not Opera 😦 .

So, my bug report broke Youtube three years later, then we did an emergency browser.js patch, and just after that our Open The Web/Developer relations team helped Youtube launch a workaround. Voila, a happy ending πŸ™‚ . Let's send thanks to Youtube devs, Developer relations – and let's wish the Opera developer who is keeping himself busy with the current rewrite of the plugin scripting code good luck and well crafted tests..

5 thoughts on “how to break Youtube

  1. I take it then that the author (Snap?) of the temporary workaround was incorrect in his analysis that this was related to Youtube adblocker-thwarting strategies?

  2. Yes, if my colleague KΓ₯re's analysis is correct (he dug down to the code quoted above) it's a perfectly valid JS statement in their Flash version detection that fails, and it's definitely an Opera bug. It's sort of interesting that it only happens with Carakan – with the old Futhark ECMAScript engine another internal event would kick the plugin scripting state back into a scriptable mode. I guess that other internal event was optimised away to make Carakan faster πŸ˜‰ and this bug was exposed as a side effect..

  3. Biswajit Maity frm India West Bengal writes:Opera Mini 4.2 is quit good but Opera Mini 5 is excellent well done team Opera

Leave a Reply

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

You are commenting using your 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