blob: 0dc52e067c901b186997d21c9a70bcc8e6a877f9 [file] [log] [blame]
<p>This test verifies that an exception thrown during array sort immediately ends execution.</p>
<p>If the test passes, you'll see a pass message below.</p>
<pre id="console">FAIL: Exception did not propagate from array sort.</pre>
<script>
function log(s)
{
document.getElementById("console").innerHTML = s + "\n";
}
if (window.testRunner)
testRunner.dumpAsText();
var passed = true;
var array = [ 1, 2, 3 ];
var sortFunction = (function () {
var alreadyCalled = false;
return function (a, b)
{
if (alreadyCalled)
passed = false;
alreadyCalled = true;
throw 'threw';
};
})();
try {
array.sort(sortFunction);
} catch(e) {
var result = passed ? "PASS"
: "FAIL: sort function was called after an exception was thrown"
log (result);
}
</script>