Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / script-tests / dfg-cross-global-object-inline-new-array-literal-with-variables.js
blobfe75cb80d25f111630dc703bdfb8522ea96f3edf
1 description(
2 "This tests that function inlining in the DFG JIT doesn't get confused about the global object to use for array allocation."
3 );
5 window.jsTestIsAsync = true;
7 function foo(x) {
8 return [x, x + 1, x * 2];
11 Array.prototype.thingy = 24;
13 function done(value) {
14 var expected = (24 + 3) * 200 + 19900 + 20100 + 39800;
15 if (value == expected)
16 testPassed("done() called with " + expected);
17 else
18 testFailed("done() called with " + value + ", but expected " + expected);
19 finishJSTest();
22 function doit() {
23 document.getElementById("frameparent").innerHTML = "";
24 document.getElementById("frameparent").innerHTML = "<iframe id='testframe'>";
25 var testFrame = document.getElementById("testframe");
26 testFrame.contentDocument.open();
28 code = "<!DOCTYPE html>\n<head></head><body><script type=\"text/javascript\">\n";
29 code += "Array.prototype.thingy = 42;\n";
30 code += "function bar(x) {\n";
31 code += " return window.parent.foo(x);\n";
32 code += "}\n";
33 code += "var result = 0;\n";
34 code += "for (var i = 0; i < 200; ++i) {\n";
35 code += " var theArray = bar(i);\n";
36 code += " result += theArray.thingy + theArray.length + theArray[0] + theArray[1] + theArray[2];\n";
37 code += "}\n";
38 code += "window.parent.done(result);\n";
39 code += "</script></body></html>";
41 testFrame.contentDocument.write(code);
42 testFrame.contentDocument.close();
45 window.setTimeout(doit, 10);