joepeck@webkit.org | bb70ac6 | 2016-09-30 19:22:37 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 2 | <html> |
| 3 | <head> |
commit-queue@webkit.org | 0c88cda | 2015-08-06 21:17:03 +0000 | [diff] [blame] | 4 | <script src="../../http/tests/inspector/resources/protocol-test.js"></script> |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 5 | <script src="resources/exception.js"></script> |
| 6 | <script> |
| 7 | function test() |
| 8 | { |
joepeck@webkit.org | bb70ac6 | 2016-09-30 19:22:37 +0000 | [diff] [blame] | 9 | let expectPause = false; |
| 10 | let testIndex = 0; |
| 11 | let statementsWithUncaughtExceptions = [ |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 12 | "({}).a.b.c.d;", |
| 13 | "exceptionBasic();", |
| 14 | "exceptionDOM();", |
| 15 | "exceptionInHostFunction();", |
| 16 | "throwString();", |
| 17 | "throwParam({x:1});", |
| 18 | "throwParam(new Error('error message'));" |
| 19 | ]; |
| 20 | |
| 21 | function triggerNextUncaughtException() |
| 22 | { |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 23 | // Evaluate statement and expect to pause. |
| 24 | if (testIndex < statementsWithUncaughtExceptions.length) { |
| 25 | var statement = statementsWithUncaughtExceptions[testIndex++]; |
commit-queue@webkit.org | 6a3d0dc | 2015-08-11 18:28:31 +0000 | [diff] [blame] | 26 | InspectorProtocol.sendCommand("Runtime.evaluate", {expression: "setTimeout(function() { " + statement + " }, 0);"}); |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 27 | return; |
| 28 | } |
| 29 | |
| 30 | // Done evaluating statements to pause. Evaluate some more we do not expect to pause. |
commit-queue@webkit.org | 6a3d0dc | 2015-08-11 18:28:31 +0000 | [diff] [blame] | 31 | ProtocolTest.log("PASS - paused for each uncaught exception"); |
| 32 | ProtocolTest.completeTest(); |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 33 | } |
| 34 | |
commit-queue@webkit.org | 6a3d0dc | 2015-08-11 18:28:31 +0000 | [diff] [blame] | 35 | InspectorProtocol.sendCommand("Debugger.enable", {}); |
joepeck@webkit.org | 349364ee | 2016-04-15 17:18:12 +0000 | [diff] [blame] | 36 | InspectorProtocol.sendCommand("Debugger.setBreakpointsActive", {active: true}); |
commit-queue@webkit.org | 6a3d0dc | 2015-08-11 18:28:31 +0000 | [diff] [blame] | 37 | InspectorProtocol.sendCommand("Debugger.setPauseOnExceptions", {state: "uncaught"}, function(responseObject) { |
| 38 | InspectorProtocol.checkForError(responseObject); |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 39 | expectPause = true; |
| 40 | triggerNextUncaughtException(); |
| 41 | }); |
| 42 | |
commit-queue@webkit.org | 6a3d0dc | 2015-08-11 18:28:31 +0000 | [diff] [blame] | 43 | InspectorProtocol.eventHandler["Debugger.paused"] = function(messageObject) |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 44 | { |
| 45 | if (!expectPause) { |
commit-queue@webkit.org | 6a3d0dc | 2015-08-11 18:28:31 +0000 | [diff] [blame] | 46 | ProtocolTest.log("FAIL - debugger paused when we did not expect to"); |
| 47 | ProtocolTest.completeTest(); |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 48 | return; |
| 49 | } |
| 50 | |
joepeck@webkit.org | bb70ac6 | 2016-09-30 19:22:37 +0000 | [diff] [blame] | 51 | ProtocolTest.log("[" + testIndex + "] Testing statement '" + statementsWithUncaughtExceptions[testIndex - 1] + "'"); |
| 52 | ProtocolTest.log("[" + testIndex + "] Paused and about to step"); |
| 53 | InspectorProtocol.sendCommand("Debugger.stepOver", {}); |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 54 | } |
| 55 | |
commit-queue@webkit.org | 6a3d0dc | 2015-08-11 18:28:31 +0000 | [diff] [blame] | 56 | InspectorProtocol.eventHandler["Debugger.resumed"] = function(messageObject) |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 57 | { |
joepeck@webkit.org | bb70ac6 | 2016-09-30 19:22:37 +0000 | [diff] [blame] | 58 | ProtocolTest.log("[" + testIndex + "] Resumed"); |
| 59 | triggerNextUncaughtException(); |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 60 | } |
| 61 | } |
| 62 | </script> |
| 63 | </head> |
| 64 | <body onload="runTest()"> |
| 65 | <p>Regression test for https://bugs.webkit.org/show_bug.cgi?id=133182</p> |
joepeck@webkit.org | bb70ac6 | 2016-09-30 19:22:37 +0000 | [diff] [blame] | 66 | <p>Stepping after breaking on uncaught exceptions should not crash.</p> |
mark.lam@apple.com | 2a4e56d | 2014-05-22 21:40:21 +0000 | [diff] [blame] | 67 | </body> |
| 68 | </html> |