{"thread":{"id":"22370","subject":"[PATCH] gitweb.js: Workaround for IE8 bug","startedAt":"2010-01-24T18:05:23Z","lastAt":"2010-01-24T18:05:23Z","messageCount":1,"participants":["Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"132547","messageId":"20100124180226.14562.87666.stgit@localhost.localdomain","threadId":"22370","inReplyTo":null,"subject":"[PATCH] gitweb.js: Workaround for IE8 bug","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-01-24T18:05:23Z","receivedAt":"2010-01-24T18:05:23Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"In Internet Explorer 8 (IE8) the 'blame_incremental' view, which uses\nJavaScript to generate blame info using AJAX, sometimes hang at the\nbeginning (at 0%) of blaming, e.g. for larger files with long history\nlike git's own gitweb/gitweb.perl.\n\nThe error shown by JavaScript console is \"Unspecified error\" at char:2\nof the following line in gitweb/gitweb.js:\n\n  if (xhr.readyState === 3 && xhr.status !== 200) {\n\nDebugging it using IE8 JScript debuger shown that the error occurs\nwhen trying to access xhr.status (xhr is XMLHttpRequest object).\nWatch for xhr object shows 'Unspecified error.' as \"value\" of\nxhr.status, and trying to access xhr.status from console throws error.\n\nThis bug is some intermittent bug, depending on XMLHttpRequest timing,\nas it doesn't occur in all cases.  It is probably caused by the fact\nthat handleResponse is called from timer (pollTimer), to work around\nthe fact that some browsers call onreadystatechange handler only once\nfor each state change, and not like required for 'blame_incremental'\nas soon as new data is available from server.  It looks like xhr\nobject is not properly initialized; still it is a bug to throw an\nerror when accessing xhr.status (and not use 'null' or 'undefined' as\nvalue).\n\nWork around this bug in IE8 by using try-catch block when accessing\nxhr.status.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nIt is, if I remember correctly, resend.\n\nI don't have IE6 nor IE7 to check whether this bug is present also in\nolder versions of Internet Explorer...\n\n gitweb/gitweb.js |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.js b/gitweb/gitweb.js\nindex 2a25b7c..9c66928 100644\n--- a/gitweb/gitweb.js\n+++ b/gitweb/gitweb.js\n@@ -779,7 +779,12 @@ function handleResponse() {\n \t}\n \n \t// the server returned error\n-\tif (xhr.readyState === 3 && xhr.status !== 200) {\n+\t// try ... catch block is to work around bug in IE8\n+\ttry {\n+\t\tif (xhr.readyState === 3 && xhr.status !== 200) {\n+\t\t\treturn;\n+\t\t}\n+\t} catch (e) {\n \t\treturn;\n \t}\n \tif (xhr.readyState === 4 && xhr.status !== 200) {\n"}]}