tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / fast / js / script-tests / cross-global-object-inline-global-var.js
1 description(
2 "This tests that function inlining in the DFG JIT doesn't get confused by different global objects."
3 );
4
5 if (window.layoutTestController)
6     layoutTestController.waitUntilDone();
7
8 var b = 321;
9
10 function foo(a) {
11     return a + b;
12 }
13
14 shouldBe("foo(3)", "324");
15
16 function done(value) {
17     var expected = 5770500;
18     if (value == expected)
19         testPassed("done() called with " + expected);
20     else
21         testFailed("done() is " + value + " and should be " + expected + ".");
22     layoutTestController.notifyDone();
23 }
24
25 function doit() {
26     document.getElementById("frameparent").innerHTML = "";
27     document.getElementById("frameparent").innerHTML = "<iframe id='testframe'>";
28     var testFrame = document.getElementById("testframe");
29     testFrame.contentDocument.open();
30     
31     code = "<!DOCTYPE html>\n<head></head><body><script type=\"text/javascript\">\n";
32     
33     // Make sure that we get as many variables as the parent.
34     for (var i = 0; i < 100; ++i)
35         code += "var b" + i + " = " +i + ";\n";
36     
37     code += "result = 0;\n" +
38         "function bar(a) {\n" +
39         "    var foo = window.parent.foo;\n" +
40         "    return ";
41     
42     for (var i = 0; i < 100; ++i)
43         code += "b" + i + " + ";
44     
45     code += "foo(a);\n" +
46         "}\n" +
47         "for (var i = 0; i < 1000; ++i) {\n" +
48         "    result += bar(i);\n" +
49         "}\n" +
50         "window.parent.done(result);\n" +
51         "</script></body></html>"
52     
53     testFrame.contentDocument.write(code);
54     testFrame.contentDocument.close();
55 }
56
57 window.setTimeout(doit, 10);
58