upload webkit/tizen 2.0_beta source.
[framework/web/webkit-efl.git] / LayoutTests / java / array-sort.html
1 <html>
2 <head>
3 <meta charset="utf-8">
4 <script src="../fast/js/resources/js-test-pre.js"></script>
5 <script>
6 if (window.layoutTestController)
7     layoutTestController.overridePreference("WebKitJavaEnabled", "1");
8 </script>
9 </head>
10 <body>
11
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>
14
15 <div id="console"></div>
16 <applet CODE="SharedApplet.class" NAME="javaTest" WIDTH=150 HEIGHT=25 MAYSCRIPT></applet>
17 <script>
18
19 debug("call");
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'");
25
26 debug("apply");
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'");
32
33 function concat()
34 {
35     var result = "";
36     for (i = 0; i < arguments.length; ++i)
37         result += arguments[i];
38     return result;
39 }
40
41 debug("passing array as function arguments, potentially parser-optimized apply");
42 array = document.javaTest.stringArray();
43 shouldBe("concat.apply({}, array)", "'OneTwoThree'");
44
45 debug("passing array as function arguments, unoptimized apply");
46 array = document.javaTest.stringArray();
47 shouldBe('concat["apply"]({}, array)', "'OneTwoThree'");
48
49 shouldThrow("array.length = 5");
50
51 </script>
52 <script src="../fast/js/resources/js-test-post.js"></script>
53 </body>
54 </html>