summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector-protocol/debugger/access-obsolete-frame.html
blob: b4bb0e5c55a03b073a8f400354845a440a631a8c (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
70
71
72
73
74
75
76
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
<script>

function testFunction()
{
    debugger;
}

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

    InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedOne;

    InspectorTest.sendCommand("Runtime.evaluate", { "expression": "setTimeout(testFunction, 0)" });

    var obsoleteTopFrameId;

    function handleDebuggerPausedOne(messageObject)
    {
        InspectorTest.log("Paused on 'debugger;'");

        var topFrame = messageObject.params.callFrames[0];
        obsoleteTopFrameId = topFrame.callFrameId;

        InspectorTest.eventHandler["Debugger.paused"] = undefined;

        InspectorTest.sendCommand("Debugger.resume", { }, callbackResume);
    }

    function callbackResume(response)
    {
        InspectorTest.log("resume");
        InspectorTest.log("restartFrame");
        InspectorTest.sendCommand("Debugger.restartFrame", { callFrameId: obsoleteTopFrameId }, callbackRestartFrame);
    }

    function callbackRestartFrame(response)
    {
        logErrorResponse(response);
        InspectorTest.log("evaluateOnFrame");
        InspectorTest.sendCommand("Debugger.evaluateOnCallFrame", { callFrameId: obsoleteTopFrameId, expression: "0"} , callbackEvaluate);
    }

    function callbackEvaluate(response)
    {
        logErrorResponse(response);
        InspectorTest.log("setVariableValue");
        InspectorTest.sendCommand("Debugger.setVariableValue", { callFrameId: obsoleteTopFrameId, scopeNumber: 0, variableName: "a", newValue: { value: 0 } }, callbackSetVariableValue);
    }

    function callbackSetVariableValue(response)
    {
        logErrorResponse(response);
        InspectorTest.completeTest();
    }

    function logErrorResponse(response)
    {
        if (response.error) {
            if (response.error.message.indexOf("debugger is not on pause") != -1) {
                InspectorTest.log("PASS, error message as expected");
                return;
            }
        }
        InspectorTest.log("FAIL, unexpected error message");
        InspectorTest.log(JSON.stringify(response));
    }
}
</script>
</head>
<body onLoad="runTest();">
</body>
</html>