Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / window-onerror-isolatedworld-01.html
blob31b0893008c6fbb8d54fe4775f28d75e0e392dbd
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script>
5 window.jsTestIsAsync = true;
6 window.isOnErrorTest = true;
7 </script>
8 <script src="../../resources/js-test.js"></script>
9 <script src="resources/onerror-test.js"></script>
10 </head>
11 <body>
12 <script>
13 description('Test that window.onerror and "error" event listeners from main world are not invoked for uncaught exceptions in scripts running in isolate worlds, but only for exceptions in the main world.');
15 var onerrorsHandled = 0;
16 function onErrorCallback(errorsHandled) {
17 onerrorsHandled++;
18 if (onerrorsHandled > 3)
19 testFailed("Only main-world exceptions should be caught by onerror handlers.");
21 // FIXME: This should be 6 once we correctly handle 'error' event dispatch for worlds: crbug.com/225513
22 if (errorsHandled === 9)
23 finishJSTest();
26 var errorEventsHandled = 0;
27 function errorEventCallback(errorsHandled) {
28 errorEventsHandled++;
29 if (errorEventsHandled > 3) {
30 // FIXME: This currently fails. We need to correctly handle 'error' event dispatch for worlds: crbug.com/225513
31 testFailed("Only main-world exceptions should be caught by ErrorEvent listeners.");
34 // FIXME: This should be 6 once we correctly handle 'error' event dispatch for worlds: crbug.com/225513
35 if (errorsHandled === 9)
36 finishJSTest();
39 dumpOnErrorArgumentValuesAndReturn(true, onErrorCallback);
40 dumpErrorEventAndPreventDefault(errorEventCallback);
42 var exceptions = function(worldType)
44 window.addEventListener("load", function(e) {
45 // Do the following call from load listener to make sure error in the setTimeout callback always happens after the error in this listener.
46 setTimeout(function() {
47 throw new Error("Error in " + worldType + " world setTimeout callback.");
48 }, 0);
49 throw new Error("Error in " + worldType + " world load handler.");
50 }, false);
52 throw new Error("Error in " + worldType + " world inline script.");
55 if (window.testRunner)
56 testRunner.evaluateScriptInIsolatedWorld(1, "(" + exceptions + ")('isolated')");
58 exceptions("main");
60 </script>
61 </body>
62 </html>