summaryrefslogtreecommitdiff
path: root/src/inspector_agent.cc
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-01-15 21:57:29 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2019-01-23 20:23:23 +0800
commitd3806f9f3cded6bce9831f5d8ff88372ba7e5861 (patch)
tree0ee4ee76357220d88fd44c2bf3f782e34b5cd957 /src/inspector_agent.cc
parenta93c825d7843e72d3e534939639f49ce8e26b16b (diff)
downloadnode-new-d3806f9f3cded6bce9831f5d8ff88372ba7e5861.tar.gz
console: refactor inspector console extension installation
- Instead of creating the console extensions eagerly during bootstrap and storing them on an object, wrap the code into a function to be called during `installAdditionalCommandLineAPI` only when the extensions are actually needed, which may not even happen if the user do not use the console in an inspector session, and does not need to happen during bootstrap unconditionally. - Simplify the console methods wrapping and move the `consoleFromVM` storage to `internal/util/inspector.js` PR-URL: https://github.com/nodejs/node/pull/25450 Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'src/inspector_agent.cc')
-rw-r--r--src/inspector_agent.cc16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc
index a53c58337e..dcc256b7f7 100644
--- a/src/inspector_agent.cc
+++ b/src/inspector_agent.cc
@@ -32,7 +32,6 @@ namespace {
using node::FatalError;
-using v8::Array;
using v8::Context;
using v8::Function;
using v8::HandleScope;
@@ -493,16 +492,11 @@ class NodeInspectorClient : public V8InspectorClient {
void installAdditionalCommandLineAPI(Local<Context> context,
Local<Object> target) override {
- Local<Object> console_api = env_->inspector_console_api_object();
- CHECK(!console_api.IsEmpty());
-
- Local<Array> properties =
- console_api->GetOwnPropertyNames(context).ToLocalChecked();
- for (uint32_t i = 0; i < properties->Length(); ++i) {
- Local<Value> key = properties->Get(context, i).ToLocalChecked();
- target->Set(context,
- key,
- console_api->Get(context, key).ToLocalChecked()).FromJust();
+ Local<Function> installer = env_->inspector_console_extension_installer();
+ if (!installer.IsEmpty()) {
+ Local<Value> argv[] = {target};
+ // If there is an exception, proceed in JS land
+ USE(installer->Call(context, target, arraysize(argv), argv));
}
}