<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script src="resources/audit-utilities.js"></script>
<script>
function test()
{
    let suite = InspectorTest.Audit.createSuite("Audit.run.DOM");

    function evaluateStringForTest(func, args, prefix = "") {
        switch (func) {
        case "hasEventListeners":
            return `${prefix}WebInspectorAudit.DOM.${func}(${args.join(", ")})`;

        case "simulateUserInteraction":
            return `(() => { let result = undefined; ${prefix}WebInspectorAudit.DOM.${func}(${args.join(", ")}); return result; })()`;
        }

        return "'FAIL'";
    }

    const tests = [
        { func: "hasEventListeners", name: "None.General", args: [`document.querySelector("#noListeners")`] },
        { func: "hasEventListeners", name: "None.click", args: [`document.querySelector("#noListeners")`, `"click"`] },
        { func: "hasEventListeners", name: "None.FakeEvent", args: [`document.querySelector("#noListeners")`, `"FakeEvent"`] },
        { func: "hasEventListeners", name: "Attribute.General", args: [`document.querySelector("#attributeListener")`] },
        { func: "hasEventListeners", name: "Attribute.click", args: [`document.querySelector("#attributeListener")`, `"click"`] },
        { func: "hasEventListeners", name: "Attribute.FakeEvent", args: [`document.querySelector("#attributeListener")`, `"FakeEvent"`] },
        { func: "hasEventListeners", name: "JavaScript.General", args: [`document.querySelector("#javascriptListener")`] },
        { func: "hasEventListeners", name: "JavaScript.click", args: [`document.querySelector("#javascriptListener")`, `"click"`] },
        { func: "hasEventListeners", name: "JavaScript.FakeEvent", args: [`document.querySelector("#javascriptListener")`, `"FakeEvent"`] },
        { func: "hasEventListeners", name: "Builtin.General", args: [`document.querySelector("#builtinListener")`] },
        { func: "hasEventListeners", name: "Builtin.play", args: [`document.querySelector("#builtinListener")`, `"play"`] },
        { func: "hasEventListeners", name: "Builtin.FakeEvent", args: [`document.querySelector("#builtinListener")`, `"FakeEvent"`] },

        { func: "simulateUserInteraction", name: "UserGesture", args: [`() => { result = internals.isProcessingUserGesture(); }`] },
        { func: "simulateUserInteraction", name: "TransientActivation", args: [`() => { result = internals.hasTransientActivation(); }`] },
    ];

    for (let {func, name, args} of tests) {
        suite.addTestCase({
            name: "Audit.run.DOM." + func + (name ? "." + name : ""),
            async test() {
                let functionString = evaluateStringForTest(func, args);

                 await InspectorTest.Audit.setupAudit();

                InspectorTest.log(`Audit run \`${functionString}\`...`);
                let {result, wasThrown} = await AuditAgent.run(`function() { return ${functionString}; }`);
                InspectorTest.assert(!wasThrown, "Should not throw an exception.");
                if (!wasThrown)
                    InspectorTest.log("Result: " + result.value);
                else
                    InspectorTest.log(result.description);

                await InspectorTest.Audit.teardownAudit();
            },
        });
    }

    suite.addTestCase({
        name: "Audit.run.DOM.InvalidCopiedFunctionCall",
        description: "Check that WebInspectorAudit.DOM functions throw an error when called outside of an audit.",
        async test() {
            let functions = new Map;
            for (let test of tests)
                functions.set(test.func, test);

            await InspectorTest.Audit.setupAudit();
            InspectorTest.log(`Copying WebInspectorAudit to window...`);
            let {wasThrown} = await AuditAgent.run(`function() { window.CopiedWebInspectorAudit = WebInspectorAudit; }`);
            InspectorTest.assert(!wasThrown, "Should not throw an exception.");
            await InspectorTest.Audit.teardownAudit();

            for (let {func, args} of functions.values()) {
                InspectorTest.log(`Testing copied ${func}...`);
                await InspectorTest.expectException(async function() {
                    await InspectorTest.evaluateInPage(evaluateStringForTest(func, args, "window.Copied"));
                });
            }
        },
    });

    suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
    <p>Tests for the injected WebInspectorAudit.DOM functions.</p>
    <div id="noListeners"></div>
    <div id="attributeListener" onclick="void(0);"></div>
    <div id="javascriptListener"><script>document.querySelector("#javascriptListener").addEventListener("click", () => {});</script></div>
    <video id="builtinListener"></video>
</body>
</html>
