| <p>This page tests for a crash when throwing an exception from a callback provided | |
| to String.prototype.replace. | |
| </p> | |
| <p>If the test passes, you'll see a series of PASS messages below. | |
| </p> | |
| <pre id="console"></pre> | |
| <script> | |
| function log(s) | |
| { | |
| document.getElementById("console").appendChild(document.createTextNode(s + "\n")); | |
| } | |
| if (window.testRunner) | |
| testRunner.dumpAsText(); | |
| // these should not crash | |
| try { | |
| (function () { | |
| "aa".replace(/a/g, function() { | |
| var bogus; | |
| bogus.property; | |
| }); | |
| })(); | |
| } catch(e) { | |
| log ("PASS: You didn't crash."); | |
| } | |
| try { | |
| (function () { | |
| "aa".replace("a", function() { | |
| ({})(); | |
| }); | |
| })(); | |
| } catch(e) { | |
| log ("PASS: You didn't crash."); | |
| } | |
| // this should not continue execution after an exception | |
| var message = "PASS: String.prototype.replace did not continue executing after an exception was thrown."; | |
| try { | |
| (function () { | |
| var count = 0; | |
| "aa".replace(/a/g, function() { | |
| if (++count > 1) | |
| message = "FAIL: String.prototype.replace continued executing after an exception was thrown."; | |
| var bogus; | |
| bogus.property; | |
| }); | |
| })(); | |
| } catch(e) { | |
| try { | |
| (function x() { return 'blargh'.replace(/a/g, x) })() | |
| } catch(e) { | |
| log (message); | |
| } | |
| } | |
| </script> |