v8/test/debugger/regress/regress-crbug-760225.js
Benedikt Meurer f3774fdeff [debugger] Fix debug-evaluate for context-allocated this.
When `this` is context allocated inside a class constructor (strict mode
function), due to an arrow function, debug evaluate was unable to locate
the value. This is quick fix for the issue, which probably deserves a
more general rewrite at some later point in time (with more domain
expertise).

Bug: chromium:760225
Change-Id: I5208d8a202ad69439f60ada480599d0efcdc4ce4
Cq-Include-Trybots: luci.chromium.try:linux-rel,win7-rel
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1687412
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62532}
2019-07-05 12:14:35 +00:00

31 lines
656 B
JavaScript

// Copyright 2019 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
let thisValue;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
thisValue = exec_state.frame(0).evaluate('this').value();
}
};
Debug.setListener(listener);
class Foo {}
class Bar extends Foo {
constructor() {
super();
var b = () => this;
this.c = 'b'; // <-- Inspect 'this' (it will be undefined)
debugger;
}
}
new Bar();
Debug.setListener(null);
assertNotEquals(undefined, thisValue);