<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script src="resources/break-on-exception-tests.js"></script>
<script>
TestPage.allowUncaughtExceptions = true;

function test()
{
    WebInspector.debuggerManager.allUncaughtExceptionsBreakpoint.disabled = false;

    let suite = InspectorTest.createAsyncSuite("BreakOnUncaughtException");

    function addTestCase({name, description, expression}) {
        suite.addTestCase({
            name, description,
            test(resolve, reject) {
                InspectorTest.evaluateInPage(expression);
                WebInspector.debuggerManager.singleFireEventListener(WebInspector.DebuggerManager.Event.Paused, (event) => {
                    let targetData = WebInspector.debuggerManager.dataForTarget(WebInspector.debuggerManager.activeCallFrame.target);
                    InspectorTest.expectThat(targetData.pauseReason === "exception", "Should pause for exception.");
                    let callFrame = WebInspector.debuggerManager.activeCallFrame;
                    let name = callFrame.functionName || "<anonymous>";
                    let location = callFrame.sourceCodeLocation;
                    let line = location.lineNumber + 1;
                    let column = location.columnNumber + 1;
                    InspectorTest.log(`PAUSE AT ${name}:${line}:${column}`);
                    WebInspector.debuggerManager.resume().then(resolve, reject);
                });
            }
        });
    }

    addTestCase({
        name: "BreakOnUncaughtException.UncaughtExceptionBasic",
        description: "Break on an uncaught exception thrown in a function.",
        expression: "setTimeout(doThrow)",
    });

    addTestCase({
        name: "BreakOnUncaughtException.UncaughtExceptionInFinally",
        description: "Break on an uncaught exception thrown in a finally block.",
        expression: "setTimeout(testFinally)",
    });

    addTestCase({
        name: "BreakOnUncaughtException.UncaughtExceptionThruNativeCode",
        description: "Break on an uncaught exception thrown thru native code (Map.prototype.forEach).",
        expression: "setTimeout(testThrowingThruNativeCode)",
    });

    suite.addTestCase({
        name: "BreakOnUncaughtException.CaughtException",
        description: "No break on a caught exception.",
        test(resolve, reject) {
            InspectorTest.evaluateInPage(`setTimeout(() => {
                testCatch();
                TestPage.dispatchEventToFrontend("AfterTestFunction");
            })`);

            let listener = WebInspector.debuggerManager.singleFireEventListener(WebInspector.DebuggerManager.Event.Paused, (event) => {
                InspectorTest.fail("Should not have paused.");
                WebInspector.debuggerManager.resume();
                reject();
            });

            InspectorTest.singleFireEventListener("AfterTestFunction", (event) => {
                InspectorTest.pass("Should not pause, exception was caught.");
                WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.Paused, listener);
                resolve();
            });
        }
    });

    suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Checking pause locations when pausing on uncaught exceptions.</p>
</body>
</html>
