v8/test/debugger/debug/debug-liveedit-replace-code.js
Alexey Kozyatinskiy 69d166fcef [debug] migrate all liveedit tests to use LiveEdit::PatchScript
After this CL all liveedit tests call the same LiveEdit::PatchScript
method. This method will be updated later.
As well some new liveedit cctests added, unfortunately part of them
do not work with current implementation.

R=dgozman@chromium.org,yangguo@chromium.org

Bug: v8:7862
Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;luci.chromium.try:linux_chromium_rel_ng;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I3521af12b0f95b39d13aaafb1d1cf60f3f642a97
Reviewed-on: https://chromium-review.googlesource.com/1108382
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53936}
2018-06-21 15:34:16 +00:00

32 lines
741 B
JavaScript

// Copyright 2017 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.
// Flags: --allow-natives-syntax
Debug = debug.Debug
var counter = 0;
var exception = null;
function f() {
if (++counter > 5) return;
debugger;
return counter;
};
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var original = 'debugger;';
var patch = 'debugger;\n';
%LiveEditPatchScript(f, Debug.scriptSource(f).replace(original, patch));
} catch (e) {
exception = e;
}
}
Debug.setListener(listener);
f();
Debug.setListener(null);
assertNull(exception);
assertEquals(6, counter);