Menu

#989 parseFloat("40em") returns NaN instead of 40

closed
None
5
2012-10-21
2009-11-25
Amit Manjhi
No

parseFloat("40em") returns 40 in FF35 but returns NaN with HtmlUnit.

Discussion

  • Amit Manjhi

    Amit Manjhi - 2009-11-25

    The patch test file as a git patch (including inline):

    --- a/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/GlobalFunctionsTest.java
    +++ b/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/GlobalFunctionsTest.java
    @@ -48,6 +48,23 @@ public class GlobalFunctionsTest extends WebDriverTestCase {

         loadPageWithAlerts(html);
     }
    
    • /**
    • */
    • @Test
    • @Alerts("40")
    • public void parseFloatEm() throws Exception {
    • final String html
    • = "<html><head>foo<script>\n"
      • "function doTest() {\n"
      • " alert(parseFloat('\n 40em '));\n"
      • "}\n"
      • "</script></head><body onload="doTest()">\n"
      • "</body></html>";
        +
    • loadPageWithAlerts(html);
    • }

      /**
      * Test for the methods with the same expectations for all browsers.

     
  • Amit Manjhi

    Amit Manjhi - 2009-11-25

    The patch file for the tests

     
  • Amit Manjhi

    Amit Manjhi - 2009-11-25

    Attached the patch file for the tests and removing the SetWidth.zip file.

     
  • Marc Guillemot

    Marc Guillemot - 2009-11-27

    Clearly a Rhino bug. I've submitted a patch for it:
    https://bugzilla.mozilla.org/show_bug.cgi?id=531436
    It should be quickly applied by Rhino folks as it is obvious, then I'll update our Rhino fork.

     
  • Marc Guillemot

    Marc Guillemot - 2010-01-07

    Now fixed in SVN. Thanks for the tiny example.

     

Log in to post a comment.