diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 90658b8d79..c402d2ac4f 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -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, diff --git a/cli/tests/testdata/inspector/inspector3.js b/cli/tests/testdata/inspector/inspector3.js index b1b00b5a0b..8d605a2862 100644 --- a/cli/tests/testdata/inspector/inspector3.js +++ b/cli/tests/testdata/inspector/inspector3.js @@ -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; diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts index 2fdb23a405..97c429aab8 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -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"); +}); diff --git a/ext/console/02_console.js b/ext/console/02_console.js index 7554a88fc5..9a9ead5a13 100644 --- a/ext/console/02_console.js +++ b/ext/console/02_console.js @@ -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]; } } } diff --git a/ext/console/lib.deno_console.d.ts b/ext/console/lib.deno_console.d.ts index ef2dc1ccae..b168d1322d 100644 --- a/ext/console/lib.deno_console.d.ts +++ b/ext/console/lib.deno_console.d.ts @@ -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; }