summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector-protocol/debugger/updateCallFrameScopes.html
blob: 3cfe8a162151dab2a5dbc417aa06afcc01c5f9fe (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
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
<script>

function TestFunction()
{
    var a = 2;
    debugger;
}

function test()
{
    var newVariableValue = 55;
    
    InspectorTest.sendCommand("Debugger.enable", {});

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

    InspectorTest.sendCommand("Runtime.evaluate", { "expression": "setTimeout(TestFunction, 0)" });
    
    function handleDebuggerPaused(messageObject)
    {
        InspectorTest.log("Paused on 'debugger;'");
        InspectorTest.eventHandler["Debugger.paused"] = undefined;
        
        var topFrame = messageObject.params.callFrames[0];
        var topFrameId = topFrame.callFrameId;
        InspectorTest.sendCommand("Debugger.evaluateOnCallFrame", { "callFrameId": topFrameId, "expression": "a = " + newVariableValue }, callbackChangeValue);
    }
    
    function callbackChangeValue(response)
    {
        InspectorTest.log("Variable value changed");
        InspectorTest.sendCommand("Debugger.getBacktrace", { }, callbackGetBacktrace);
    }

    function callbackGetBacktrace(response)
    {
        InspectorTest.log("Stacktrace re-read again");
        var localScope = response.result.callFrames[0].scopeChain[0];
        InspectorTest.sendCommand("Runtime.getProperties", { "objectId": localScope.object.objectId }, callbackGetProperties);
    }

    function callbackGetProperties(response)
    {
        InspectorTest.log("Scope variables downloaded anew");
        var varNamedA;
        var propertyList = response.result.result;
        for (var i = 0; i < propertyList.length; i++) {
            if (propertyList[i].name === "a") {
                varNamedA = propertyList[i];
                break;
            }
        }
        if (varNamedA) {
            var actualValue = varNamedA.value.value;
            InspectorTest.log("New variable is " + actualValue + ", expected is " + newVariableValue + ", old was: 2");
            InspectorTest.log(actualValue == newVariableValue ? "SUCCESS" : "FAIL");
        } else { 
            InspectorTest.log("Failed to find variable in scope");
        }
        InspectorTest.completeTest();
    }
}
</script>
</head>
<body onLoad="runTest();">
</body>
</html>