1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

fix(inspector): ensure console methods provided by inspector are available (#16724)

This commit is contained in:
Bartek Iwańczuk 2022-11-22 02:17:14 +01:00 committed by GitHub
parent 5c7dc904fb
commit 1ec357faf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 1 deletions

View file

@ -4126,7 +4126,7 @@ mod tests {
assert!(result.is_ok());
let response: CompletionInfo =
serde_json::from_value(result.unwrap()).unwrap();
assert_eq!(response.entries.len(), 19);
assert_eq!(response.entries.len(), 22);
let result = request(
&mut runtime,
state_snapshot,

View file

@ -1,4 +1,10 @@
// deno-lint-ignore-file
// check that console methods provided by V8 are available in the inspector
console.timeStamp("foo");
console.profile("foo");
console.profileEnd("foo");
for (let i = 0; i < 128; i++) {
console.log(i);
debugger;

View file

@ -336,6 +336,9 @@ Deno.test(function consoleTestStringifyCircular() {
groupEnd: [Function: groupEnd],
clear: [Function: clear],
trace: [Function: trace],
profile: [Function: profile],
profileEnd: [Function: profileEnd],
timeStamp: [Function: timeStamp],
indentLevel: 0,
[Symbol(isConsoleInstance)]: true
}`,
@ -2103,3 +2106,9 @@ Deno.test(async function inspectAggregateError() {
);
}
});
Deno.test(function inspectorMethods() {
console.timeStamp("test");
console.profile("test");
console.profileEnd("test");
});

View file

@ -2239,6 +2239,12 @@
this.error(err.stack);
};
// These methods are noops, but when the inspector is connected, they
// call into V8.
profile = (_label) => {};
profileEnd = (_label) => {};
timeStamp = (_label) => {};
static [SymbolHasInstance](instance) {
return instance[isConsoleInstance];
}
@ -2332,6 +2338,9 @@
consoleFromV8[key],
consoleFromDeno[key],
);
} else {
// Add additional console APIs from the inspector
consoleFromDeno[key] = consoleFromV8[key];
}
}
}

View file

@ -26,4 +26,13 @@ declare interface Console {
timeLog(label?: string, ...data: any[]): void;
trace(...data: any[]): void;
warn(...data: any[]): void;
/** This method is a noop, unless used in inspector */
timeStamp(label?: string): void;
/** This method is a noop, unless used in inspector */
profile(label?: string): void;
/** This method is a noop, unless used in inspector */
profileEnd(label?: string): void;
}