1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p>Test for
<a href=
"http://bugs.webkit.org/show_bug.cgi?id=41862">bug
41862</a>:
8 XPath substring function is broken when passing NaN as the position parameter.
</p>
9 <div id=
"console"></div>
12 shouldBe("document.evaluate(\"substring('12345', number(\'NaN\'))\", document, null, XPathResult.STRING_TYPE, null).stringValue", "''");
13 shouldBe("document.evaluate(\"substring('12345', number(\'NaN\'), 3)\", document, null, XPathResult.STRING_TYPE, null).stringValue", "''");
15 <!-- -2147483645 represents MIN_INT
-3 which when passed through the original substring
function before the fix
for 41862 landed caused an overflow and wrap to
2. That meant that
this case was effectively calling
substring('12345', MIN_INT
, 2) and returning
12, rather than the empty string which the NaN should have triggered
.. -->
16 shouldBe("document.evaluate(\"substring('12345', number(\'NaN\'), -2147483645)\", document, null, XPathResult.STRING_TYPE, null).stringValue", "''");
18 shouldBe("document.evaluate(\"substring('12345', number(\'NaN\'), number(\'NaN\'))\", document, null, XPathResult.STRING_TYPE, null).stringValue", "''");