Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / string-replace-exception-crash.html
blobbc1886626250168897667b2f50979174828834c0
1 <p>This page tests for a crash when throwing an exception from a callback provided
2 to String.prototype.replace.
3 </p>
5 <p>If the test passes, you'll see a series of PASS messages below.
6 </p>
8 <pre id="console"></pre>
10 <script>
11 function log(s)
13 document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
16 if (window.testRunner)
17 testRunner.dumpAsText();
19 // these should not crash
21 try {
22 (function () {
23 "aa".replace(/a/g, function() {
24 var bogus;
25 bogus.property;
26 });
27 })();
28 } catch(e) {
29 log ("PASS: You didn't crash.");
32 try {
33 (function () {
34 "aa".replace("a", function() {
35 ({})();
36 });
37 })();
38 } catch(e) {
39 log ("PASS: You didn't crash.");
42 // this should not continue execution after an exception
44 var message = "PASS: String.prototype.replace did not continue executing after an exception was thrown.";
45 try {
46 (function () {
47 var count = 0;
48 "aa".replace(/a/g, function() {
49 if (++count > 1)
50 message = "FAIL: String.prototype.replace continued executing after an exception was thrown.";
52 var bogus;
53 bogus.property;
54 });
55 })();
56 } catch(e) {
57 try {
58 (function x() { return 'blargh'.replace(/a/g, x) })()
59 } catch(e) {
60 log (message);
64 </script>