summaryrefslogtreecommitdiff
path: root/deps/v8/test/inspector/debugger/access-obsolete-frame.js
blob: 9d498e041dd5a59041b1e3688d8df908b6257144 (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
// 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.

let {session, contextGroup, Protocol} = InspectorTest.start('Tests that accessing no longer valid call frames returns an error');

contextGroup.addScript(`
function testFunction()
{
  debugger;
}
//# sourceURL=foo.js`);

Protocol.Debugger.enable();

Protocol.Debugger.oncePaused().then(handleDebuggerPausedOne);

Protocol.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;

  Protocol.Debugger.resume().then(callbackResume);
}

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

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

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

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));
}