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

Unified Diff: test/debugger/debug/debug-evaluate-readonly.js

Issue 2622863003: [debugger] infrastructure for side-effect-free debug-evaluate. (Closed)
Patch Set: Created 3 years, 11 months 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/x64/macro-assembler-x64.cc ('K') | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/debugger/debug/debug-evaluate-readonly.js
diff --git a/test/debugger/debug/debug-evaluate-readonly.js b/test/debugger/debug/debug-evaluate-readonly.js
new file mode 100644
index 0000000000000000000000000000000000000000..4fd1652142a7120d790748f7ddc1b343a4f3b675
--- /dev/null
+++ b/test/debugger/debug/debug-evaluate-readonly.js
@@ -0,0 +1,65 @@
+// 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: --ignition --readonly-debug-evaluate
+
+Debug = debug.Debug
+
+var exception = null;
+let a = 1;
+var object = { property : 2,
+ get getter() { return 3; }
+ };
+var string1 = { toString() { return "x"; } };
+var string2 = { toString() { print("x"); return "x"; } };
+var array = [4, 5];
+
+function set_a() { a = 2; }
+
+function get_a() { return a; }
+
+function listener(event, exec_state, event_data, data) {
+ if (event != Debug.DebugEvent.Break) return;
+ try {
+ // Simple test.
+ assertEquals(3, exec_state.frame(0).evaluate("1 + 2").value());
+ // Context load.
+ assertEquals(1, exec_state.frame(0).evaluate("a").value());
+ // Global and named property load.
+ assertEquals(2, exec_state.frame(0).evaluate("object.property").value());
+ // Load via read-only getter.
+ assertEquals(3, exec_state.frame(0).evaluate("object.getter").value());
+ // Implicit call to read-only toString.
+ assertEquals("xy", exec_state.frame(0).evaluate("string1 + 'y'").value());
+ // Keyed property load.
+ assertEquals(5, exec_state.frame(0).evaluate("array[1]").value());
+ // Call to read-only function.
+ assertEquals(1, exec_state.frame(0).evaluate("get_a()").value());
+ // Call to read-only function within try-catch.
+ assertEquals(1, exec_state.frame(0).evaluate("try { get_a() } catch (e) {}").value());
+ // Test that non-read-only code fails.
+ assertThrows(() => exec_state.frame(0).evaluate("exception = 1"), EvalError);
+ // Test that calling a non-read-only function fails.
+ assertThrows(() => exec_state.frame(0).evaluate("set_a()"), EvalError);
+ // Test that implicit call to a non-read-only function fails.
+ assertThrows(() => exec_state.frame(0).evaluate("string2 + 'y'"), EvalError);
+ // Test that try-catch does not catch the EvalError.
+ assertThrows(() => exec_state.frame(0).evaluate("try { set_a() } catch (e) {}"), EvalError);
+ } catch (e) {
+ exception = e;
+ print(e, e.stack);
+ };
+};
+
+// Add the debug event listener.
+Debug.setListener(listener);
+
+function f() {
+ debugger;
+};
+
+f();
+
+assertNull(exception);
+assertEquals(1, a);
« src/x64/macro-assembler-x64.cc ('K') | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698