Sitepatching updates

tweaking the broken code until it works, one site at a time

browser.js for 10.5: the giant cleanup

During the last two weeks, browser.js has been tested against Opera 10.5, and the updates both on bug fixing and on handling broken code means an unprecedented number of patches are now due for removal. bigsmile

WARNING: This is probably the longest browser.js update post ever!

This post is evidence of remarkable progress on the bug fixing and site compatibility front. Whether we were talking plain bugs or errors due to Opera's handling of unexpected code or spec violations, Opera 10.5 contains the results of man-years of analysis and bug fixing, hopefully taking a great leap forward for site compatibility. (Unless Carakan, Vega and the rest of the new and exciting stuff brings a heap of NEW bugs that break websites, that is.. Time will show wink)


New patches



Added - pchome.net layout fix
Layout issue caused by a margin pushing floats out of their expected position. This is already fixed in core for 10.5.

Added - Y!Mail chat enter fix
This issue was reported in the fora and prompted by the first comment on the previous blog post I had a quick look. Turns out it was caused by a familiar problem..

Back when we implemented the much-requested rich text editing support, we weren't quite sure what scripts should be allowed to run inside a document with designMode enabled. (Before you ask - no, there was no spec for designMode back then. It's something browser vendors invented, and it's still plagued with crippling interoperability problems. HTML5 is going to handle at least some of it but I assume something as complex as rich text editing will remain underspecified for a while..)

Our testing back then indicated that other browsers stopped running scripts inside a document when designMode was enabled. Depending on the context, running scripts when a site doesn't expect you to can cause cross-site scripting exploits and similar security problems, so we made really sure we blocked script execution in editing mode. So far, so good... except that's not what the others are doing. Several broken sites later we realised that they still allow event listeners (like those added with document.addEventListener('keyup', ..) to run.

So because of this misunderstanding we don't send the event to Yahoo, and thus enter doesn't send your chat message. The patch works around that by making designMode sort of an alias for contentEditable, which does not disable scripts.

Added - Toshiba script hang fix
A while ago, I noticed a site setting innerHTML to a markup string with an OBJECT loading Flash content and immediately trying to access the Flash from the same script thread. At the time, this worked in Firefox but not Opera - we didn't initialize the Flash plugin until after the script finished.

So, we've had this bug hanging around saying we should initialize plugin objects immediately when innerHTML is set, and pause the script until the plugin is ready for scripting. Sounds simple? So I thought. Of course it wasn't.

At the Toshiba site, they have an OBJECT for IE and an EMBED fallback to load Flash. Both have the same ID. Further they also have a peculiar #topmovie:after { content: "."; } style instruction that affects the object. When JavaScript tries to interact with their Flash content, it hooks up with the wrong object - one that Opera is not going to initialize - and starts waiting until it's ready for scripting. And while that script is waiting, no other scripts may run - breaking most interaction with the site.

Updated patches



Changed - eBay white space to apply on more domain than .com
According to suggestions in comments on previous post - thanks, guys!

Changed Walla.co.il styling
Walla.co.il is improving their standards compliance, making patches obsolete.

Patches removed for 10.5



Removed - YouTube menu painting - site changed

Removed CORE-17333 - The constructor property of DOM nodes should not be object - this problem now fixed in core

Removed CORE-17460 - Constructor property of event should be Event interface - same as above

Removed CORE-3776 - generic patch for window.scrollX/Y - implemented these non-standard properties

Removed - expedia.com car rental list
The issue here was when to encode angle brackets to entities when a site reads innerHTML. Apparently browsers should not do so for certain attributes if the value starts with javascript:. If you want a complex demo of this issue, compare the output from this script in your preferred browsers. Tell me if you find two different browser engines doing exactly the same thing, because I haven't!

Removed CORE-25405 - unclickable tianya.cn links - due to missing OBJECT closing tag (this fix is not actually in 10.5 builds quite yet, but should get there soon)

Removed - ebay.fr hangs, select.remove() options - core fix now landing for the spec violation discussed in an earlier browser.js update post

Removed - em.com.cn menu disappears - because we didn't know what order other browsers fired mousemove and mouseout events in when you moved the mouse from one element to another..

Removed - Google Reader blank page on 'v' - a peculiar timing problem, I think Reader would try to navigate a popup before we were done loading about:blank.

Removed - picsearch.com/wimbledon.org/adf.ly loads blank
Ah. I've been going on about using feature detection rather than browser sniffing and demonstrated how sniffing can cause serious problems. All of a sudden, jQuery releases an update without browser sniffing and it turns out Opera has an unflattering core bug that breaks their feature detection and makes sites that use both FRAMESET and the new jQuery render nothing at all!

This rather unpleasant discovery depends on the fact that a form element is supposed to be associated with a FORM. A form, on the other hand, is supposed to live inside a document's BODY. A FRAMESET, on the other hand, will only be rendered if the browser hasn't seen any BODY at all..

So, when jQuery runs this somewhat opinionated snippet:

// Check to see if the browser returns elements by name when 
// querying by getElementById (and provide a workaround) 
var form = document.createElement("form"), 
id = "why_is_this_needed"; 
form.innerHTML = '<input name="foo">'; 
var root = document.documentElement; 
root.insertBefore( form, root.firstChild ); 
root.removeChild( form );

there was some logic inside Opera thinking: "oops, there's a form being created here, and we don't have a BODY, so let's make one up". Bizarrely, this code would trigger even if all you did was document.createElement('select') without inserting anything in the document! A "why_is_this_needed" moment indeed..

Of course, when we reached the FRAMESET tag Opera ignored it because it had created a BODY for that document already.

The patch has a certain odd beauty, overwriting createElement() to make sure elements are created inside a fake document until we've seen a real BODY or FRAMESET:
document.createElement=(function(createElement){
	var tmpDoc = document.implementation.createDocument('http://www.w3.org/1999/xhtml/', 'html', null);
	return function(tagName){
		if( ! document.body ){
			return createElement.call( tmpDoc, tagName );
		}else{
			document.createElement=createElement; // this hack is not necessary anymore
			return createElement.call(this, tagName);
		}
	}
})(document.createElement);


Surprisingly, it worked.

Removed - Y!Mail chat enter fix - yes, this patch is being added for 9.x and 10.00/.10 and obsoleted for 10.5 at the same time. We intend to get the core fix that allows certain event listeners in designMode into 10.5, though it's not in just yet.

Removed - Y!Mail XMLDocument usage - I'm not even sure if we fixed it or they did
Removed - Y!Mail send button opens attach dialog - Y!Mail had a huge, invisible INPUT type=file and used CSS clip() styling to "cut" away the parts that were above other buttons than "attach". Unfortunately, Opera sent mouse events even to content that was clipped away.

Removed - allrecipes.com byte order marks in JS files - as promised the Mojibake problem is being fixed in core.

Removed - amazon.com.cn menus disappear - same problem with mouse event order as em.com.cn. The patch was rather tricky to get right..

Removed - asahi.com never stops loading - one of Japan's most important news papers was inserting scripts both from timeouts and with document.write() and the mix confused Opera into a never-stops-loading state. We've had similar issues elsewhere - digg.com among other high-profile sites, so this core fix is much appreciated.

Removed - bbs.pcpop.com shows blank - caused by styling of nested forms (one of these things HTML4 didn't want to deal with)

Removed - cdon.com shopping cart empty - a convoluted layout issue with relative position and nested floats.

Removed CORE-21773 - china-pub.com window.event getter function's caller property is wrong - site used an "IE features emulation" script for non-IE browser, defining window.event among other things. Of course we support window.event already, but it was redefined with a getter function anyway, and within that function they tried to read the function's caller property and exposed a bug.

Removed DSK-246430 - digg.com NSL/no content - another of these "never stops loading due to peculiar script self-mutations" bugs

Removed - grainger.com document load - we realised we should stop supporting document.onload, and now the fix hits the road.

Removed CORE-10896 - google groups not 100% tall - long standing annoyance regarding nested tables with 100% height

Removed - ironmaiden.com disappearing menu - another mouse event order problem, exacerbated by the especially weird markup and scripting their menu uses.

Removed - Hotmail oncontextmenu - yes
Removed - Google maps oncontextmenu yes
Removed - nasdaq.com overlapping content - another layout problem regarding CSS positioning

Removed - news.sina.com.cn CDATA parsing - odd bug where the sheer size of a script element caused it to be split into two text chunks, and the CDATA escape stuff caused a syntax error.

Removed - photobucket disappearing menu - probably also a mouse event order issue

Removed - Picasaweb upload button too narrow - bug in calculations of the width of an element with overflow:hidden, now fixed.

Removed - portalaz.com.br disappearing menus - mouse event order issue

Removed - rent.toyota.co.jp window.open issue - similar to the Reader issue but different. I'm not sure if I ever understood this.

Removed - sfc.jp noscript content shows - styling NOSCRIPT elements with display:block turned out to be a bad idea when Opera defaulted to hiding them with a display:none smile

Removed - shutterfly.com Array splice on 0-length arrays - splicing an empty array didn't work very well in Opera.

Removed - status.renren.com missing comments - same as the CDOn bug

Removed - towerrecords.co.jp disappearing menu - mouse event order problem

Removed - weather.com disappearing menu - mouse event order problem

Removed - wikimapia.org oncontextmenu - yes

Removed - Google Finance missing stock details - a convoluted issue involving Google's script working around an Opera bug, and the workaround failing for the specific CSS Finance was using.

Removed - pchome.net broke margin - as stated at the top of the post, already fixed for 10.5

Removed - zhangmen.baidu.com textarea typing - we supported IE's document.selection object without full support for the IE selection APIs. This site (and some others) would detect document.selection and assume the entire API existed. In 10.5 we fix this by removing document.selection support.

Wow! party

patches of the week: allrecipes.com and eBay whitespaceReady to Wave?

Comments

Charles SchlossChas4 Monday, February 1, 2010 8:26:05 PM

Quite a list, you have been busy

Hallvord R. M. Steenhallvors Monday, February 1, 2010 8:34:14 PM

indeed! :-)

Charles SchlossChas4 Monday, February 1, 2010 8:49:41 PM

Any idea about yapping at hbo.com? Might be an easy hack not sure (till they fix it on their end)

FataL Monday, February 1, 2010 9:07:30 PM

Removed - YouTube menu painting - site changed

But will this issue get fixed in Core?

z@h3kZAHEK Monday, February 1, 2010 9:25:05 PM

up

Daniel HendrycksDanielHendrycks Monday, February 1, 2010 9:56:05 PM

Wow, that is good news.

rseiler Monday, February 1, 2010 10:02:35 PM

Any news on the vast array of MS forums? I just tried them in 10.5, and writing is still a problem.

Kyle Bakerkyleabaker Monday, February 1, 2010 10:23:55 PM

Wow! I'm impressed!

Alexanderxmenclassic Monday, February 1, 2010 10:25:17 PM

It's the new version now online? A Update is not actual a new browser.js.

d4rkn1ght Monday, February 1, 2010 10:38:06 PM

Great news! Opera keeps getting better and better! cool

ouzowtfouzoWTF Monday, February 1, 2010 11:08:24 PM

Great changes! But I can not get a browser.js with build 3218. Even the hints on http://www.opera.com/docs/browserjs/ does not seem to work!?

netwolf Monday, February 1, 2010 11:31:30 PM

Originally posted by ouzoWTF:

Great changes! But I can not get a browser.js with build 3218.


Same here on XP.

And yes, very good, congrats to being able to remove such a lot of patches smile

Hallvord R. M. Steenhallvors Monday, February 1, 2010 11:37:24 PM

Originally posted by FataL:

But will this issue get fixed in Core?



Yes.

Originally posted by xmenclassic:

It's the new version now online?



No, sorry that I wasn't clear. Tomorrow or so.

Will follow up other comments later, need sleep smile

MyOpera team, please fix this!fearphage Tuesday, February 2, 2010 8:10:41 AM

Thanks a lot Hallvord. I love to see core getting some much-needed love!

I have a question regarding browser.js and plugins. Why are there gears compatibility patches when gears doesn't work in Opera? I was going to file a bug that they should add gears.dll to the plugin-ignore list but I checked browser.js to find a patch for it. Is there some secret version of Opera that gears works in? I have to block gears.dll so I can use bespin. Feel free to correct me.

JavaScript

Uncaught exception: TypeError: 'google.gears.factory.create' is not a function
Error thrown at line 16, column 58540 in <anonymous function>() in https://bespin.mozilla.com/js/editor_all.js:
    var wp=google.gears.factory.create("beta.workerpool");
called from line 16, column 29044 in https://bespin.mozilla.com/js/editor_all.js:
    (function(){var _174=1;var _175=0;var _176=0;var _177=false;var _178=dojo.moduleUrl("bespin","bootstrap_worker.js");var _179=function(_17a){return _178+"#"+escape(_17a);};var _17b=function(uri){return unescape(uri.substr((_178+"#").length));};var _17d=typeof Worker=="undefined"?true:false;if(!_17d){try{var _17e=new Worker(dojo.moduleUrl("bespin.util","testWorker.js"));}catch(e){_17d=true;}}if(_17d){_17f();if(window.google&&google.gears){_177=true;var wp=google.gears.factory.create("beta.workerpool");var _181={};Worker=function(uri,_183){this.isGears=true;this.id=wp.createWorkerFromUrl(_178);_181[this.id]=this;};Worker.prototype={postMessage:function(data){wp.sendMessage(data,this.id);}};wp.onmessage=function(a,b,_187){var _188=_181[_187.sender];var cb=_188.onmessage;if(cb){cb.call(_188,{data:_187.body});}};_17d=false;}}dojo.declare("bespin.worker.WorkerFacade",null,{constructor:function(obj,_18b,libs){this.__obj__=obj;var _18d={};this.__callbacks__=_18d;this.__workerCount__=_18b||_174;this.__hasWorkers__=false;if(!_17d){this.__hasWorkers__=true;var _18e=this.createWorkerSource(obj,libs);var _18f=this.createWorkers(_18e);this.__workers__=_18f;}this.createFacade(obj);},__getWorker__:function(){var _190=_175++%this.__workerCount__;return this.__workers__[_190];},createWorkers:function(_191){var self=this;var _193=[];var cb=function(_195){var data=_195.data;if(typeof data=="string"){data=dojo.fromJson(data);}var _197=data.callIndex;var _198=self.__callbacks__[_197];delete self.__callbacks__[_197];if(_198){_198(data.returnValue);}};var _199=function(_19a,url){var _19c=this;bespin.get("server").request("GET",url,null,{onSuccess:function(src){_19c.postMessage("__IMPORT_SCRIPT__//"+_19a+"\n"+src);}});};for(var i=0;i<this.__workerCount__;i++){var _19f=new Worker(_178,_191);var _1a0=function(_1a1){var _1a2=_1a1.data;if(typeof _1a2=="string"){if(_1a2.indexOf("log=")==0){console.log("From Worker: "+_1a2.substr(4));return;}else{if(_1a2.indexOf("__IMPORT_SCRIPT__")==0){var json=_1a2.substr("__IMPORT_SCRIPT__".length);var _1a4=dojo.fromJson(json);_199.apply(this,_1a4);return;}else{_1a2=dojo.fromJson(_1a2);}}}if(_1a2.type=="subscribe"){(function(){var _1a5=_1a2.index;var name=_1a2.name;bespin.subscribe(name,function(_1a7){var ret={index:_1a5,name:name,event:_1a7};_19f.postMessage(_177?ret:dojo.toJson(ret));});})();}else{if(_1a2.type=="publish"){bespin.publish(_1a2.name,_1a2.event);}else{throw _1a2;cb.call(this,_1a1);}}};_19f.onmessage=_1a0;_191="// YOUcannotGuessMe\n"+_191;window.setTimeout(function(){_19f.postMessage(_191);},0);_193.push(_19f);}return _193;},createFacade:function(obj){var _1aa=this;for(var prop in obj){if(prop.charAt(0)!="_"){(function(){var val=obj[prop];var _1ad=prop;if(typeof val=="function"){_1aa[prop]=function(){var self=this;var _1af=_176++;var _1b0=Array.prototype.slice.call(arguments);if(this.__hasWorkers__){var data={callIndex:_1af,method:_1ad,paras:_1b0};if(!_177){data=dojo.toJson(data);}this.__getWorker__().postMessage(data);}else{var self=this;window.setTimeout(function(){var _1b2=self.__obj__[_1ad].apply(self.__obj__,_1b0);var _1b3=self.__callbacks__[_1af];delete self.__callbacks__[_1af];if(_1b3){_1b3(_1b2);}},0);}return {and:function(_1b4,_1b5,_1b6,_1b7){var func=arguments[arguments.length-1];if(_1b5 instanceof bespin.worker.Mutex){_1b5.start();func=function(){_1b7.apply(this,arguments);_1b5.stop();};}self.__callbacks__[_1af]=function(){_1b6=Array.prototype.slice.call(arguments).concat(_1b6);func.apply(_1b4,_1b6);};}};};}else{}})();}}},hasFunctions:function(obj){for(var i in obj){var val=obj[i];if(typeof val=="function"){return true;}if(val&&typeof val=="object"){if(this.hasFunctions(val)){return true;}}}return false;},serializeToPortableSource:function(obj){var self=this;var _1be=dojo.isArray(obj);var _1bf=_1be?"[\n":"{\n";for(var prop in obj){(function(){if(prop=="_constructor"){return;}var val=obj[prop];var _1c2=prop;var src="";if(typeof val=="function"){src=val.toString();}else{if(val&&typeof val=="object"&&self.hasFunctions(val)){src=self.serializeToPortableSource(val);}else{src=dojo.toJson(val);}}prop="\""+prop.replace(/"/g,"\\\"","g")+"\"";_1bf+=_1be?"":prop+": ";_1bf+=src+",\n";})();}_1bf+=_1be?"]\n":"}\n";return _1bf;},createWorkerSource:function(obj,libs){var con=function(msg){postMessage("log="+msg);};var _1c8="";if(libs){var _1c9=[];dojo.forEach(libs,function(lib){_1c9.push("'"+lib+"'");});_1c8+="importScripts("+_1c9.join(", ")+");\n";}_1c8+="var theObject = "+this.serializeToPortableSource(obj);return _1c8;}});dojo.declare("bespin.worker.Mutex",null,{constructor:function(name,_1cc){this.name=name;this.count=0;this.afterJobs=[];this.options=_1cc||{};},start:function(){this.count=this.count+1;},stop:function(){this.count=this.count-1;if(this.count==0){if(this.options.onlyLast){var last=this.afterJobs[this.afterJobs.length-1];if(last){last();}}else{for(var i=0;i<this.afterJobs.length;++i){var job=this.afterJobs[i];job();}}this.afterJobs=[];}},after:function(_1d0,func){this.afterJobs.push(function(){func.call(_1d0);});}});function _17f(){if(window.google&&google.gears){return;}var _1d2=null;if(typeof GearsFactory!="undefined"){_1d2=new GearsFactory();}else{try{_1d2=new ActiveXObject("Gears.Factory");if(_1d2.getBuildInfo().indexOf("ie_mobile")!=-1){_1d2.privateSetGlobalObject(this);}}catch(e){if(navigator.mimeTypes["application/x-googlegears"]){_1d2=document.createElement("object");_1d2.style.display="none";_1d2.width=0;_1d2.height=0;_1d2.type="application/x-googlegears";document.documentElement.appendChild(_1d2);}}}if(!_1d2){return;}if(!window.google){google={};}if(!google.gears){google.gears={factory:_1d2};}};})();

Galileo Tuesday, February 2, 2010 8:12:25 AM

Thank you for the fix of yahoo chat bigsmile. It is a big list, 10.5 will look fantastic smile

Ola P. Kleivenolak Tuesday, February 2, 2010 10:22:42 AM

@Fearphage

the "secret" version is Opera Mobile/Windows. It has been in browser.js for development purposes (internal test builds sharing desktop's browser.js), but with Gears being abandoned it may be time to do what you suggest.

Ola P. Kleivenolak Tuesday, February 2, 2010 2:50:09 PM

Files are live.

Galileo Tuesday, February 2, 2010 3:40:06 PM

up Downloaded..and confirmed that the yahoo chat sends the text with Enter. Some issues after the patch, the cursor isn't focused inside the text field after you hit enter, work around is to use Tab and smilies from the menu appear as blank or instead of the smilie you get the text "Blank page". If you type the smilie it works ok.

lucideer Tuesday, February 2, 2010 6:33:31 PM

Originally posted by hallvors:

Removed CORE-3776 - generic patch for window.scrollX/Y - implemented these non-standard properties


Are these due for standardisation?

Hallvord R. M. Steenhallvors Tuesday, February 2, 2010 8:15:24 PM

Originally posted by lucideer:

Are these due for standardisation?



Good question, don't know.

MyOpera team, please fix this!fearphage Wednesday, February 3, 2010 6:31:10 AM

Originally posted by Ola P. Kleiven:

the "secret" version is Opera Mobile/Windows. It has been in browser.js for development purposes (internal test builds sharing desktop's browser.js), but with Gears being abandoned it may be time to do what you suggest.

So is it a bug/error that the desktop client has bits of gears? I think the desktop client needs to block the gears.dll. It causes problems on sites like bespin that see the namespace and assume that it's functional. I have filed this as DSK-278636.

Hallvord R. M. Steenhallvors Wednesday, February 3, 2010 12:26:03 PM

Originally posted by fearphage:

So is it a bug/error that the desktop client has bits of gears?


Yes, it's sort of a bug to keep that patch in Desktop's browser.js, so I've disabled it for Desktop now. Thanks smile

Ola P. Kleivenolak Wednesday, February 3, 2010 12:35:39 PM

The "bits" are only the standard NPAPI plug-in loading mechanism, so it would be solved by blocking the dll.

MyOpera team, please fix this!fearphage Wednesday, February 3, 2010 3:52:34 PM

Originally posted by Ola P. Kleiven:

The "bits" are only the standard NPAPI plug-in loading mechanism, so it would be solved by blocking the dll.

Sounds like a great idea! (That's what DSK-278636 says)

So the ebay issue should be fixed? I just hit a page and still got the huge whitespace. Do I need to manually do something here?

netwolf Wednesday, February 3, 2010 4:21:59 PM

Originally posted by MyOpera team, please fix this!:

So the ebay issue should be fixed? I just hit a page and still got the huge whitespace.


Same here.

MyOpera team, please fix this!fearphage Wednesday, February 3, 2010 6:15:50 PM

Manually request an update (Help > Check for updates). It will update browser.js. That fixed it for me... although the page loaded broken and then fixes itself. (Watch the scrollbar to see it.)

netwolf Wednesday, February 3, 2010 8:03:17 PM

Originally posted by MyOpera team, please fix this!:

Manually request an update (Help > Check for updates). It will update browser.js. That fixed it for me... although the page loaded broken and then fixes itself. (Watch the scrollbar to see it.)


I already had the latest browser.js when I tried it, and noticed that it was first displayed incorrectly, then corrected, but it didn't do it anymore with all pages after login.

Alexanderxmenclassic Thursday, February 4, 2010 11:54:54 AM

Originally posted by Hallvord:

Removed - Google Reader blank page on 'v' - a peculiar timing problem, I think Reader would try to navigate a popup before we were done loading about:blank.


I have think with the new browser.js can i full load the Google Reader site, but the site load failed. It's load the head, but not the content the feeds and in the error console is also a JS error.
I have also write the bug DSK-278040.

What is our state with the last Opera snapshot and the new browser.js?

Thank you
Alexander

Ola P. Kleivenolak Thursday, February 4, 2010 12:38:47 PM

@Alexander

That was an unreleated bug in Carakan, fixed internally.

netwolf Thursday, February 4, 2010 1:00:57 PM

There are still keyboard navigation problems with Yahoo.de and latest Opera snapshot/latest browser.js.
E.g. you cannot use the down key to select the 2nd/3rd (autocompleted) email address in the 'To' field.
Also navigation using the Tab key is broken, and there's a strange border with a blue dotted line around the typed message which doesn't appear with other browsers.
(reported the keyb.nav. issues for the first time about a year ago, but I guess now is the right time to repeat it...)

Hallvord R. M. Steenhallvors Monday, February 8, 2010 2:50:36 PM

Originally posted by rseiler:

Any news on the vast array of MS forums? I just tried them in 10.5, and writing is still a problem.



Timely reminder of an important bug, thanks. I've hopefully kicked the problem further towards a real fix, and will consider a site patch. (It feels like a pretty complicated issue - if they get it fixed for 10.5 final, our developers deserve a beer )

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.