Ticket #3429 (closed feature: duplicate)
Problems with lib\openlayers.js in Firefox
|Reported by:||jdege||Owned by:|
Someone accidentally configured our test server to load the openlayers files individually. (The programmers usually load the individual files on their development machines, to make stepping through it in the debugger easier, but we are supposed to be loading the singleFile on the test and production servers).
In any case, one of the testers noticed a problem. We have a fairly complicated ASP.NET page, involving update panels, partial postbacks, embedded controls that are making periodic ajax calls, etc., and an OpenLayers map. When the page was loaded in the normal manner, everything worked fine. But if the page was refreshed – as in the user hit the browser’s “Reload” button, when the page returned the map wouldn’t draw completely. But only in Firefox. In IE8, IE9, Opera, and Chrome, after a page refresh everything worked fine. In Firefox 4.0.1 and in Firefox 5, after a page refresh, the map would be munged.
The degree of mungedness would differ, from one attempt to another. Sometimes no map would draw, sometimes the map layers would draw, but all of the controls would be missing. It was inconsistent.
I was able to reproduce this, on my dev machine, and examine the munged map in the DOM explorer. If the controls were missing, they were simply missing. It’s not that the controls’ divs were in the DOM, but the images weren’t drawing. The controls’ divs weren’t in the DOM.
In every attempt, after a page refresh three or four of the files loaded by lib\OpenLayers.js would be dropped, and which they were would change. And this only after a page refresh, and never on initial load, or after a normal postback.
So I went looking at the code in lib\OpenLayers.js. After the jsfiles array is constructed, the code that actually emits the script tags has two alternative methods. If the browser is “MSIE” or “Safari”, the script tags are constructed as text, and emitted via document.write(). For all other browsers, the script tags are created as DOM objects via document.createElement(“script”), and appended to the head via appendChild().
Firefox had been using the DOM object method. I edited the file so that FireFox would use the document.write() method, that IE was using, and the issue went away. All of the files loaded successfully.
To me, this looks like a bug in FireFox. It seems to have a problem with that many script elements being added via appendChild(), after a page refresh.
It also looks like a fairly minor issue – nobody with any sense is going to use the lib\OpenLayers.js in a production configuration.
But it is an issue.