Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1006)

Side by Side Diff: LayoutTests/fast/events/window-onerror-isolatedworld-02.html

Issue 19962008: Rewrite the 'window.onerror' tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: tests. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 <script>
11 var expectedRecordCount = 10;
12 var recordCount = 0;
13 document.getElementById("console").addEventListener("DOMNodeInserted", f unction(e) {
14 if (++recordCount === expectedRecordCount && window.testRunner)
15 testRunner.notifyDone();
16 }, false);
17
18
19 var throwExceptions = function(isolatedWorld)
20 {
21 window.addEventListener("load", function(e) {
22 // Do the following call from load listener to make sure error i n the setTimeout callback always happens after the error in this listener.
23 setTimeout(function() {
24 throw new Error("Error in " + isolatedWorld + " setTimeout c allback.");
25 }, 0);
26 throw new Error("Error in " + isolatedWorld + " load handler.");
27 }, false);
28
29 throw new Error("Error in "+ isolatedWorld + " inline script.");
30 };
31
32 var errorHandlers = function(isolatedWorld)
33 {
34 function lastUrlComponent(url) {
35 return url ? url.match( /[^\/]+\/?$/ )[0] : url;
36 }
37
38 function log(msg) {
39 var record = document.createElement("div");
40 record.innerHTML = msg;
41 document.getElementById("console").appendChild(record);
42 }
43
44 window.onerror = function(msg, url, line) {
45 log(isolatedWorld + " window.onerror: " + msg + " at " + lastUrl Component(url) + ":" + line, "*");
46 return true;
47 }
48
49 window.addEventListener("error", function(e) {
50 var url = lastUrlComponent(e.filename);
51 log(isolatedWorld + " error event listener: " + e.message + " at " + url + ":" + e.lineno, "*");
52 e.preventDefault();
53 }, false);
54 };
55
56 if (window.testRunner) {
57 testRunner.dumpAsText();
58 testRunner.waitUntilDone();
59 testRunner.evaluateScriptInIsolatedWorld(1, "(" + errorHandlers + ") ('isolated world'); (" + throwExceptions + ")('isolated world')");
60 }
61
62 throwExceptions("main world");
63 </script>
64 </body>
65 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698