| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE HTML> | |
| 2 <html> | |
| 3 <head> | |
| 4 </head> | |
| 5 <body> | |
| 6 <p>Test that window.onerror and "error" event listeners from main world are | |
| 7 invoked for uncaught exceptions in scripts running in isolate worlds as | |
| 8 well as for exceptions in the main world.<a href="https://bugs.webkit.org/show_b
ug.cgi?id=8519">Bug 8519.</a> | |
| 9 </p> | |
| 10 <div id="console"></div> | |
| 11 <script> | |
| 12 | |
| 13 var expectedRecordCount = 12; | |
| 14 var recordCount = 0; | |
| 15 document.getElementById("console").addEventListener("DOMNodeInserted", function(
e) { | |
| 16 recordCount++; | |
| 17 if (recordCount === expectedRecordCount && window.testRunner) | |
| 18 testRunner.notifyDone(); | |
| 19 }, false); | |
| 20 | |
| 21 function log(msg) { | |
| 22 var record = document.createElement("div"); | |
| 23 record.innerHTML = msg; | |
| 24 document.getElementById("console").appendChild(record); | |
| 25 } | |
| 26 | |
| 27 function lastUrlComponent(url) { | |
| 28 return url ? url.match( /[^\/]+\/?$/ )[0] : url; | |
| 29 } | |
| 30 | |
| 31 window.onerror = function(msg, url, line) | |
| 32 { | |
| 33 log("Main world window.onerror: " + msg + " at " + lastUrlComponent(url) + "
:" + line); | |
| 34 return true; | |
| 35 } | |
| 36 | |
| 37 window.addEventListener("error", function(e) | |
| 38 { | |
| 39 var url = lastUrlComponent(e.filename); | |
| 40 log("Main world error event listener: " + e.message + " at " + url + ":" + e
.lineno); | |
| 41 e.preventDefault(); | |
| 42 }, false); | |
| 43 | |
| 44 var exceptions = function(isolatedWorld) | |
| 45 { | |
| 46 window.addEventListener("load", function(e) { | |
| 47 // Do the following call from load listener to make sure error in the se
tTimeout callback always happens after the error in this listener. | |
| 48 setTimeout(function() { | |
| 49 throw new Error("Error in " + isolatedWorld + " setTimeout callback.
"); | |
| 50 }, 0); | |
| 51 throw new Error("Error in " + isolatedWorld + " load handler."); | |
| 52 }, false); | |
| 53 | |
| 54 | |
| 55 throw new Error("Error in "+ isolatedWorld + " inline script."); | |
| 56 } | |
| 57 | |
| 58 if (window.testRunner) { | |
| 59 testRunner.dumpAsText(); | |
| 60 testRunner.waitUntilDone(); | |
| 61 testRunner.evaluateScriptInIsolatedWorld(1, "(" + exceptions + ")('isolated
world')"); | |
| 62 } | |
| 63 | |
| 64 exceptions("main world"); | |
| 65 | |
| 66 </script> | |
| 67 </body> | |
| 68 </html> | |
| OLD | NEW |