Fix for https://sourceforge.net/p/htmlunit/bugs/1599/ according to http://www.ecma-international.org/ecma-262/5.1/#sec-15.10.4.1