Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / nested-function-scope.html
blob32674ca4b480c4d4db8f7ae8f9647bd257aa8da3
1 <p>This page tests issues of scope with nested functions.</p>
2 <pre id="console"></pre>
4 <script>
5 function log(s)
7 document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
10 function shouldBe(evalA, a, b)
12 if (evalA === b) {
13 log("PASS: " + a + " should be " + b + " and is.");
14 } else {
15 log("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".");
19 if (window.testRunner)
20 testRunner.dumpAsText();
22 log("Before parsing f:");
23 log("-----");
24 shouldBe(typeof f, "typeof f", "function");
25 shouldBe(typeof f.f1, "typeof f.f1", "undefined");
27 function f(x)
29 function f1() {
30 log("\nIn call to f:");
31 log("-----");
32 shouldBe(typeof f, "typeof f", "function");
33 shouldBe(typeof f1, "typeof f1", "function");
34 shouldBe(typeof f.f1, "typeof f.f1", "undefined");
35 shouldBe(typeof x, "typeof x", "number");
36 shouldBe(typeof y, "typeof y", "undefined");
39 f1();
41 f.y = 1;
43 log("\nAfter parsing f, but before calling f:");
44 log("-----");
45 shouldBe(typeof f, "typeof f", "function");
46 shouldBe(typeof f.f1, "typeof f.f1", "undefined");
48 f(1);
49 </script>