2016-10-02 21:22:49 +00:00
|
|
|
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start('Tests updating call frame scopes');
|
|
|
|
|
|
|
|
contextGroup.addScript(
|
2016-10-02 21:22:49 +00:00
|
|
|
`function TestFunction()
|
|
|
|
{
|
|
|
|
var a = 2;
|
|
|
|
debugger;
|
|
|
|
debugger;
|
|
|
|
}`);
|
|
|
|
|
|
|
|
var newVariableValue = 55;
|
|
|
|
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.enable();
|
2016-10-02 21:22:49 +00:00
|
|
|
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.oncePaused().then(handleDebuggerPaused);
|
2016-10-02 21:22:49 +00:00
|
|
|
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Runtime.evaluate({ "expression": "setTimeout(TestFunction, 0)" });
|
2016-10-02 21:22:49 +00:00
|
|
|
|
|
|
|
function handleDebuggerPaused(messageObject)
|
|
|
|
{
|
|
|
|
InspectorTest.log("Paused on 'debugger;'");
|
|
|
|
|
|
|
|
var topFrame = messageObject.params.callFrames[0];
|
|
|
|
var topFrameId = topFrame.callFrameId;
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.evaluateOnCallFrame({ "callFrameId": topFrameId, "expression": "a = " + newVariableValue }).then(callbackChangeValue);
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function callbackChangeValue(response)
|
|
|
|
{
|
|
|
|
InspectorTest.log("Variable value changed");
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.oncePaused().then(callbackGetBacktrace);
|
|
|
|
Protocol.Debugger.resume();
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function callbackGetBacktrace(response)
|
|
|
|
{
|
|
|
|
InspectorTest.log("Stacktrace re-read again");
|
|
|
|
var localScope = response.params.callFrames[0].scopeChain[0];
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Runtime.getProperties({ "objectId": localScope.object.objectId }).then(callbackGetProperties);
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|