summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector-protocol/debugger/debugger-setEventListenerBreakpoint.html
blob: 91ca89f627d6e3b60f8506df4dbecdaca0a35267 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
<script>

function test()
{
    InspectorTest.sendCommand("Debugger.enable", {}, setEventListenerBreakpointWhenDOMDisabled);

    function finishIfError(message)
    {
        if (message.result)
            return;
        InspectorTest.log("FAIL: " + JSON.stringify(message));
        InspectorTest.completeTest();
    }

    function setEventListenerBreakpointWhenDOMDisabled(message)
    {
        finishIfError(message);
        InspectorTest.log("PASS: Debugger was enabled");
        InspectorTest.sendCommand("DOMDebugger.setEventListenerBreakpoint", {'eventName':'click'}, enableDOMAgent);
    }

    function enableDOMAgent(message)
    {
        InspectorTest.log("Error on attempt to set event listener breakpoint when DOM is disabled: " + JSON.stringify(message.error));
        InspectorTest.sendCommand("DOM.enable", {}, setEventListenerBreakpoint);
    }

    function setEventListenerBreakpoint(message)
    {
        finishIfError(message);
        InspectorTest.log("PASS: DOM was enabled");
        InspectorTest.sendCommand("DOMDebugger.setEventListenerBreakpoint", {'eventName':'click'}, disableDOMAgent);
    }


    function disableDOMAgent(message)
    {
        finishIfError(message);
        InspectorTest.log("PASS: Listener was set.");
        InspectorTest.sendCommand("DOM.disable", {}, disableDOMAgent2);
    }

    function disableDOMAgent2(message)
    {
        finishIfError(message);
        InspectorTest.log("PASS: DOM agent was disabled successfully.");
        InspectorTest.sendCommand("DOM.disable", {}, finish);
    }

    function finish(message)
    {
        if (!message.error) {
            InspectorTest.log("FAIL: we expected an error but it wasn't happen.");
            InspectorTest.completeTest();
            return;
        }

        InspectorTest.log("PASS: The second attempt to disable DOM agent failed as expected.");
        InspectorTest.completeTest();
    }
}
</script>
</head>
<body onLoad="runTest();">
</body>
</html>