4 <script src="../fast/js/resources/js-test-pre.js"></script>
6 if (window.layoutTestController)
7 layoutTestController.overridePreference("WebKitJavaEnabled", "1");
12 <p>Test that Java arrays work with generic JS array methods.</p>
13 <p>Also test that they work when passed as the second argument to apply(). This may or may not be correct behavior per LiveConnect spec.</p>
15 <div id="console"></div>
16 <applet CODE="SharedApplet.class" NAME="javaTest" WIDTH=150 HEIGHT=25 MAYSCRIPT></applet>
20 var array = document.javaTest.stringArray();
21 Array.prototype.sort.call(array);
22 shouldBe("array[0] + ''", "'One'");
23 shouldBe("array[1] + ''", "'Three'");
24 shouldBe("array[2] + ''", "'Two'");
27 array = document.javaTest.stringArray();
28 Array.prototype.sort.apply(array, []);
29 shouldBe("array[0] + ''", "'One'");
30 shouldBe("array[1] + ''", "'Three'");
31 shouldBe("array[2] + ''", "'Two'");
36 for (i = 0; i < arguments.length; ++i)
37 result += arguments[i];
41 debug("passing array as function arguments, potentially parser-optimized apply");
42 array = document.javaTest.stringArray();
43 shouldBe("concat.apply({}, array)", "'OneTwoThree'");
45 debug("passing array as function arguments, unoptimized apply");
46 array = document.javaTest.stringArray();
47 shouldBe('concat["apply"]({}, array)', "'OneTwoThree'");
49 shouldThrow("array.length = 5");
52 <script src="../fast/js/resources/js-test-post.js"></script>