Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / throw-from-array-sort.html
bloba78b742428889c48a68221e9d80b1efa0b660e3f
1 <p>This test verifies that an exception thrown during array sort immediately ends execution.</p>
2 <p>If the test passes, you'll see a pass message below.</p>
4 <pre id="console">FAIL: Exception did not propogate from array sort.</pre>
6 <script>
7 function log(s)
9 document.getElementById("console").innerHTML = s + "\n";
12 if (window.testRunner)
13 testRunner.dumpAsText();
15 var passed = true;
17 var array = [ 1, 2, 3 ];
18 var sortFunction = (function () {
19 var alreadyCalled = false;
20 return function (a, b)
22 if (alreadyCalled)
23 passed = false;
25 alreadyCalled = true;
26 throw 'threw';
28 })();
30 try {
31 array.sort(sortFunction);
32 } catch(e) {
33 var result = passed ? "PASS"
34 : "FAIL: sort function was called after an exception was thrown"
35 log (result);
37 </script>