Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Unified Diff: test/mjsunit/es6/debug-evaluate-arrow-function-receiver.js

Issue 1500933002: [debugger] fix debug-evaluate wrt shadowed context var. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/debug/debug-evaluate.cc ('K') | « src/objects.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/debug-evaluate-arrow-function-receiver.js
diff --git a/test/mjsunit/es6/debug-evaluate-arrow-function-receiver.js b/test/mjsunit/es6/debug-evaluate-arrow-function-receiver.js
new file mode 100644
index 0000000000000000000000000000000000000000..97befadce718c4e6149229b62ce38b247d17130a
--- /dev/null
+++ b/test/mjsunit/es6/debug-evaluate-arrow-function-receiver.js
@@ -0,0 +1,89 @@
+// 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.
+
+// Flags: --expose-debug-as debug
+
+// Test that debug-evaluate can find the correct this value for an
+// arrow function.
+
+Debug = debug.Debug
+
+var break_count = 0;
+var exception = null;
+
+function listener(event, exec_state, event_data, data) {
+ if (event != Debug.DebugEvent.Break) return;
+ try {
+ for (var i = 0; i < exec_state.frameCount() - 1; i++) {
+ var frame = exec_state.frame(0);
+ var this_value = frame.evaluate("this").value();
+ if (frame.sourceLineText().indexOf("undefined this") > 0) {
+ assertEquals(undefined, this_value);
+ } else {
+ assertEquals(receiver, this_value);
+ }
+ }
+ break_count++;
+ } catch (e) {
+ exception = e;
+ }
+}
+
+var receiver = {};
+
+// Context-allocated receiver.
+function f() {
+ assertEquals(receiver, this);
+ debugger;
+ return () => {
+ assertEquals(receiver, this);
+ debugger;
+ with ({}) {
+ return () => {
+ debugger;
+ try {
+ throw new Error();
+ } catch (e) {
+ return () => {
+ debugger;
+ return g.call(receiver);
+ };
+ }
+ };
+ }
+ };
+}
+
+// Stack-allocated receiver.
+function g() {
+ debugger;
+ return () => {
+ debugger; // undefined this.
+ with ({}) {
+ return () => {
+ debugger; // undefined this.
+ try {
+ throw new Error();
+ } catch (e) {
+ return () => {
+ debugger; // undefined this.
+ return f.call(receiver);
+ };
+ }
+ };
+ }
+ };
+}
+
+Debug.setListener(listener);
+
+var h = f.call(receiver);
+for (var i = 0; i < 20; i++) h = h();
+var h = g.call(receiver);
+for (var i = 0; i < 20; i++) h = h();
+
+Debug.setListener(null);
+
+assertEquals(54, break_count);
+assertNull(exception);
« src/debug/debug-evaluate.cc ('K') | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698