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

Side by Side Diff: LayoutTests/fast/events/window-onerror-for-isolated-world-1.html

Issue 19962008: Rewrite the 'window.onerror' tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: *facepalm* 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 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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698