blob: 3d4f675daf8e567589c26aa995f9bfd9a3cc1187 [file] [log] [blame]
<p>This page tests function calls whose argument expressions overwrite the callee.</p>
<p>If the test passes, you'll see PASS messages below.
</p>
<pre id="console"></pre>
<script>
function log(s)
{
document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
}
function shouldBe(aDescription, a, b)
{
if (a === b) {
log("PASS: " + aDescription + " should be " + b + " and is.");
} else {
log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
}
}
function test1(callback, x) {
try {
return callback.apply(this, [ callback = x ]);
} catch(e) {
return e;
}
};
function test2(callback, x) {
try {
return callback(callback = x);
} catch(e) {
return e;
}
};
(function () {
if (window.testRunner)
testRunner.dumpAsText();
var callback = function callback(x) {
return x;
};
shouldBe("test1(callback, 1)", test1(callback, 1), 1);
shouldBe("test2(callback, 1)", test2(callback, 1), 1);
})();
</script>