v8/test/debugger/debug/debug-liveedit-stepin.js
jgruber 4fb4f3408c [debug-wrapper] LiveEdit, frame.restart(), breakpoints
This adds access to the LiveEdit API object, frame.restart(), and
various breakpoint setters. The LiveEdit API still depends on the JS
debugging context and blocks its removal; but it should be removed
once LiveEdit is rewritten in the midterm.

BUG=v8:5530

Review-Url: https://codereview.chromium.org/2503293002
Cr-Commit-Position: refs/heads/master@{#41062}
2016-11-17 08:43:59 +00:00

75 lines
1.8 KiB
JavaScript

// Copyright 2015 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.
Debug = debug.Debug
function BestEditor() {
return 'Emacs';
}
var exception = null;
var results = [];
var log = []
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var source_line = event_data.sourceLineText();
log.push(source_line);
if (source_line.indexOf("return") >= 0) {
switch (results.length) {
case 0:
break;
case 1:
Replace(BestEditor, "Emacs", "Eclipse");
break;
case 2:
Replace(BestEditor, "Eclipse", "Vim");
break;
default:
assertUnreachable();
}
}
exec_state.prepareStep(Debug.StepAction.StepIn);
} catch (e) {
exception = e;
}
};
function Replace(fun, original, patch) {
var script = Debug.findScript(fun);
if (fun.toString().indexOf(original) < 0) return;
var patch_pos = script.source.indexOf(original);
var change_log = [];
Debug.LiveEdit.TestApi.ApplySingleChunkPatch(script, patch_pos, original.length, patch, change_log);
}
Debug.setListener(listener);
debugger;
results.push(BestEditor());
results.push(BestEditor());
results.push(BestEditor());
Debug.setListener(null);
assertNull(exception);
assertEquals(["Emacs", "Eclipse", "Vim"], results);
print(JSON.stringify(log, 1));
assertEquals([
"debugger;",
"results.push(BestEditor());",
" return 'Emacs';","}",
"results.push(BestEditor());",
"results.push(BestEditor());",
" return 'Emacs';",
" return 'Eclipse';","}",
"results.push(BestEditor());",
"results.push(BestEditor());",
" return 'Eclipse';",
" return 'Vim';",
"}","results.push(BestEditor());",
"Debug.setListener(null);"
], log);