| 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/sh
    ow_bug.cgi?id=8519">Bug 8519.</a> | 
|  | 9     </p> | 
|  | 10     <pre id="console"></pre> | 
|  | 11     <script> | 
|  | 12         var expectedRecordCount = 10; | 
|  | 13         var recordCount = 0; | 
|  | 14         document.getElementById("console").addEventListener("DOMNodeInserted", f
    unction(e) { | 
|  | 15             if (++recordCount === expectedRecordCount && window.testRunner) | 
|  | 16                 testRunner.notifyDone(); | 
|  | 17         }, false); | 
|  | 18 | 
|  | 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 i
    n the setTimeout callback always happens after the error in this listener. | 
|  | 24                 setTimeout(function() { | 
|  | 25                     throw new Error("Error in " + isolatedWorld + " setTimeout c
    allback."); | 
|  | 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 " + lastUrl
    Component(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 + ")
    ('isolated world'); (" + throwExceptions + ")('isolated world')"); | 
|  | 61         } | 
|  | 62 | 
|  | 63         throwExceptions("main world"); | 
|  | 64     </script> | 
|  | 65 </body> | 
|  | 66 </html> | 
| OLD | NEW | 
|---|