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 isolated 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 = 10; | |
14 var recordCount = 0; | |
15 document.getElementById("console").addEventListener("DOMNodeInserted", function(
e) { | |
16 if (++recordCount === expectedRecordCount && window.testRunner) | |
17 testRunner.notifyDone(); | |
18 }, false); | |
19 | |
20 var throwExceptions = function(isolatedWorld) | |
21 { | |
22 window.addEventListener("load", function(e) { | |
23 // Do the following call from load listener to make sure error in the se
tTimeout callback always happens after the error in this listener. | |
24 setTimeout(function() { | |
25 throw new Error("Error in " + isolatedWorld + " setTimeout callback.
"); | |
26 }, 0); | |
27 throw new Error("Error in " + isolatedWorld + " load handler."); | |
28 }, false); | |
29 | |
30 throw new Error("Error in "+ isolatedWorld + " inline script."); | |
31 }; | |
32 | |
33 var errorHandlers = function(isolatedWorld) | |
34 { | |
35 function lastUrlComponent(url) { | |
36 return url ? url.match( /[^\/]+\/?$/ )[0] : url; | |
37 } | |
38 | |
39 function log(msg) { | |
40 var record = document.createElement("div"); | |
41 record.innerHTML = msg; | |
42 document.getElementById("console").appendChild(record); | |
43 } | |
44 | |
45 window.onerror = function(msg, url, line) { | |
46 log(isolatedWorld + " window.onerror: " + msg + " at " + lastUrlComponen
t(url) + ":" + line, "*"); | |
47 return true; | |
48 } | |
49 | |
50 window.addEventListener("error", function(e) { | |
51 var url = lastUrlComponent(e.filename); | |
52 log(isolatedWorld + " error event listener: " + e.message + " at " + url
+ ":" + e.lineno, "*"); | |
53 e.preventDefault(); | |
54 }, false); | |
55 }; | |
56 | |
57 if (window.testRunner) { | |
58 testRunner.dumpAsText(); | |
59 testRunner.waitUntilDone(); | |
60 testRunner.evaluateScriptInIsolatedWorld(1, "(" + errorHandlers + ")('isolat
ed world'); (" + throwExceptions + ")('isolated world')"); | |
61 } | |
62 | |
63 throwExceptions("main world"); | |
64 | |
65 </script> | |
66 </body> | |
67 </html> | |
OLD | NEW |