From: <asa...@us...> - 2013-09-27 20:57:14
|
Revision: 8520 http://sourceforge.net/p/htmlunit/code/8520 Author: asashour Date: 2013-09-27 20:57:12 +0000 (Fri, 27 Sep 2013) Log Message: ----------- JavaScript: array.sort() to use Arrays.LegacyMergeSort with Java 7. Issue 1511 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeArrayTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-09-27 10:03:32 UTC (rev 8519) +++ trunk/htmlunit/src/changes/changes.xml 2013-09-27 20:57:12 UTC (rev 8520) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="fix" dev="asashour" issue="1511"> + JavaScript: array.sort() to use Arrays.LegacyMergeSort with Java 7. + </action> <action type="add" dev="mguillem"> JavaScript: support click method on any element for FF10+ too. </action> Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeArrayTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeArrayTest.java 2013-09-27 10:03:32 UTC (rev 8519) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeArrayTest.java 2013-09-27 20:57:12 UTC (rev 8520) @@ -144,4 +144,33 @@ loadPageWithAlerts2(html); } + /** + * Test for "Comparison method violates its general contract!". + * @throws Exception if the test fails + */ + @Test + public void comparisonMethodViolatesContract() throws Exception { + final String html + = "<html><head><title>foo</title><script>\n" + + "var results = [1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1," + + " -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1," + + " 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 0, -1, -1, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0," + + " 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1," + + " 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];\n" + + "var index = 0;" + + "function test() {\n" + + " var arr = new Array(37);\n" + + " for (var x = 0; x < arr.length; x++) {\n" + + " arr[x] = new Object();\n" + + " }\n" + + " arr.sort(function (a, b) {\n" + + " return results[index++];\n" + + " });\n" + + "}\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + } |