blob: 2a371b092893c3951544f922db0cb50d90235453 [file] [log] [blame]
joepeck@webkit.orgbb70ac62016-09-30 19:22:37 +00001<!DOCTYPE html>
mark.lam@apple.com2a4e56d2014-05-22 21:40:21 +00002<html>
3<head>
commit-queue@webkit.org0c88cda2015-08-06 21:17:03 +00004<script src="../../http/tests/inspector/resources/protocol-test.js"></script>
mark.lam@apple.com2a4e56d2014-05-22 21:40:21 +00005<script src="resources/exception.js"></script>
6<script>
7function test()
8{
joepeck@webkit.orgbb70ac62016-09-30 19:22:37 +00009 let expectPause = false;
10 let testIndex = 0;
11 let statementsWithUncaughtExceptions = [
mark.lam@apple.com2a4e56d2014-05-22 21:40:21 +000012 "({}).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.com2a4e56d2014-05-22 21:40:21 +000023 // Evaluate statement and expect to pause.
24 if (testIndex < statementsWithUncaughtExceptions.length) {
25 var statement = statementsWithUncaughtExceptions[testIndex++];
commit-queue@webkit.org6a3d0dc2015-08-11 18:28:31 +000026 InspectorProtocol.sendCommand("Runtime.evaluate", {expression: "setTimeout(function() { " + statement + " }, 0);"});
mark.lam@apple.com2a4e56d2014-05-22 21:40:21 +000027 return;
28 }
29
30 // Done evaluating statements to pause. Evaluate some more we do not expect to pause.
commit-queue@webkit.org6a3d0dc2015-08-11 18:28:31 +000031 ProtocolTest.log("PASS - paused for each uncaught exception");
32 ProtocolTest.completeTest();
mark.lam@apple.com2a4e56d2014-05-22 21:40:21 +000033 }
34
commit-queue@webkit.org6a3d0dc2015-08-11 18:28:31 +000035 InspectorProtocol.sendCommand("Debugger.enable", {});
joepeck@webkit.org349364ee2016-04-15 17:18:12 +000036 InspectorProtocol.sendCommand("Debugger.setBreakpointsActive", {active: true});
commit-queue@webkit.org6a3d0dc2015-08-11 18:28:31 +000037 InspectorProtocol.sendCommand("Debugger.setPauseOnExceptions", {state: "uncaught"}, function(responseObject) {
38 InspectorProtocol.checkForError(responseObject);
mark.lam@apple.com2a4e56d2014-05-22 21:40:21 +000039 expectPause = true;
40 triggerNextUncaughtException();
41 });
42
commit-queue@webkit.org6a3d0dc2015-08-11 18:28:31 +000043 InspectorProtocol.eventHandler["Debugger.paused"] = function(messageObject)
mark.lam@apple.com2a4e56d2014-05-22 21:40:21 +000044 {
45 if (!expectPause) {
commit-queue@webkit.org6a3d0dc2015-08-11 18:28:31 +000046 ProtocolTest.log("FAIL - debugger paused when we did not expect to");
47 ProtocolTest.completeTest();
mark.lam@apple.com2a4e56d2014-05-22 21:40:21 +000048 return;
49 }
50
joepeck@webkit.orgbb70ac62016-09-30 19:22:37 +000051 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.com2a4e56d2014-05-22 21:40:21 +000054 }
55
commit-queue@webkit.org6a3d0dc2015-08-11 18:28:31 +000056 InspectorProtocol.eventHandler["Debugger.resumed"] = function(messageObject)
mark.lam@apple.com2a4e56d2014-05-22 21:40:21 +000057 {
joepeck@webkit.orgbb70ac62016-09-30 19:22:37 +000058 ProtocolTest.log("[" + testIndex + "] Resumed");
59 triggerNextUncaughtException();
mark.lam@apple.com2a4e56d2014-05-22 21:40:21 +000060 }
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.orgbb70ac62016-09-30 19:22:37 +000066<p>Stepping after breaking on uncaught exceptions should not crash.</p>
mark.lam@apple.com2a4e56d2014-05-22 21:40:21 +000067</body>
68</html>