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 that accessing no longer valid call frames returns an error');
|
|
|
|
|
|
|
|
contextGroup.addScript(`
|
2016-10-02 21:22:49 +00:00
|
|
|
function testFunction()
|
|
|
|
{
|
|
|
|
debugger;
|
|
|
|
}
|
|
|
|
//# sourceURL=foo.js`);
|
|
|
|
|
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(handleDebuggerPausedOne);
|
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
|
|
|
|
|
|
|
var obsoleteTopFrameId;
|
|
|
|
|
|
|
|
function handleDebuggerPausedOne(messageObject)
|
|
|
|
{
|
|
|
|
InspectorTest.log("Paused on 'debugger;'");
|
|
|
|
|
|
|
|
var topFrame = messageObject.params.callFrames[0];
|
|
|
|
obsoleteTopFrameId = topFrame.callFrameId;
|
|
|
|
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.resume().then(callbackResume);
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function callbackResume(response)
|
|
|
|
{
|
|
|
|
InspectorTest.log("resume");
|
|
|
|
InspectorTest.log("restartFrame");
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.restartFrame({ callFrameId: obsoleteTopFrameId }).then(callbackRestartFrame);
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function callbackRestartFrame(response)
|
|
|
|
{
|
|
|
|
logErrorResponse(response);
|
|
|
|
InspectorTest.log("evaluateOnFrame");
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.evaluateOnCallFrame({ callFrameId: obsoleteTopFrameId, expression: "0"}).then(callbackEvaluate);
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function callbackEvaluate(response)
|
|
|
|
{
|
|
|
|
logErrorResponse(response);
|
|
|
|
InspectorTest.log("setVariableValue");
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.setVariableValue({ callFrameId: obsoleteTopFrameId, scopeNumber: 0, variableName: "a", newValue: { value: 0 } }).then(callbackSetVariableValue);
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function callbackSetVariableValue(response)
|
|
|
|
{
|
|
|
|
logErrorResponse(response);
|
|
|
|
InspectorTest.completeTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
function logErrorResponse(response)
|
|
|
|
{
|
|
|
|
if (response.error) {
|
|
|
|
if (response.error.message.indexOf("Can only perform operation while paused.") !== -1) {
|
|
|
|
InspectorTest.log("PASS, error message as expected");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
InspectorTest.log("FAIL, unexpected error message");
|
|
|
|
InspectorTest.log(JSON.stringify(response));
|
|
|
|
}
|