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

Unified Diff: test/debugger/test-api.js

Issue 2513343004: [debug-wrapper] Migrate suspended generator scope test (Closed)
Patch Set: Rebase Created 4 years, 1 month 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
Index: test/debugger/test-api.js
diff --git a/test/debugger/test-api.js b/test/debugger/test-api.js
index 069f81796d74e411a169b10ac60ebbed79471bac..07f8275307ab61cc6fea33f63a2d6f65bf970532 100644
--- a/test/debugger/test-api.js
+++ b/test/debugger/test-api.js
@@ -292,6 +292,50 @@ class DebugWrapper {
this.takeReplyChecked(msgid);
}
+ generatorScopeCount(gen) {
+ return %GetGeneratorScopeCount(gen);
+ }
+
+ generatorScope(gen, index) {
+ // These indexes correspond definitions in debug-scopes.h.
+ const kScopeDetailsTypeIndex = 0;
+ const kScopeDetailsObjectIndex = 1;
+
+ const details = %GetGeneratorScopeDetails(gen, index);
+
+ function scopeObjectProperties() {
+ const obj = details[kScopeDetailsObjectIndex];
+ return Object.keys(obj).map((k, v) => v);
+ }
+
+ function setScopeVariableValue(name, value) {
+ const res = %SetScopeVariableValue(gen, null, null, index, name, value);
+ if (!res) throw new Error("Failed to set variable value");
+ }
+
+ const scopeObject =
+ { value : () => details[kScopeDetailsObjectIndex],
+ property : (prop) => details[kScopeDetailsObjectIndex][prop],
+ properties : scopeObjectProperties,
+ propertyNames : () => Object.keys(details[kScopeDetailsObjectIndex])
+ .map((key, _) => key),
+ };
+ return { scopeType : () => details[kScopeDetailsTypeIndex],
+ scopeIndex : () => index,
+ scopeObject : () => scopeObject,
+ setVariableValue : setScopeVariableValue,
+ }
+ }
+
+ generatorScopes(gen) {
+ const count = %GetGeneratorScopeCount(gen);
+ const scopes = [];
+ for (let i = 0; i < count; i++) {
+ scopes.push(this.generatorScope(gen, i));
+ }
+ return scopes;
+ }
+
get LiveEdit() {
const debugContext = %GetDebugContext();
return debugContext.Debug.LiveEdit;
« no previous file with comments | « test/debugger/debug/debug-scopes-suspended-generators.js ('k') | test/mjsunit/debug-scopes-suspended-generators.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698