| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c6d5af5 commit 8881c0b
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,7 +33,6 @@ function installConsoleExtensions(commandLineApi) { | |||
| 33 | 33 | ||
| 34 | 34 | // Wrap a console implemented by Node.js with features from the VM inspector | |
| 35 | 35 | function wrapConsole(consoleFromNode, consoleFromVM) { | |
| 36 | - const config = {}; | ||
| 37 | 36 | const { consoleCall } = internalBinding('inspector'); | |
| 38 | 37 | for (const key of Object.keys(consoleFromVM)) { | |
| 39 | 38 | // If global console has the same method as inspector console, | |
@@ -42,8 +41,7 @@ function wrapConsole(consoleFromNode, consoleFromVM) { | |||
| 42 | 41 | if (consoleFromNode.hasOwnProperty(key)) { | |
| 43 | 42 | consoleFromNode[key] = consoleCall.bind(consoleFromNode, | |
| 44 | 43 | consoleFromVM[key], | |
| 45 | - consoleFromNode[key], | ||
| 46 | - config); | ||
| 44 | + consoleFromNode[key]); | ||
| 47 | 45 | } else { | |
| 48 | 46 | // Add additional console APIs from the inspector | |
| 49 | 47 | consoleFromNode[key] = consoleFromVM[key]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -404,6 +404,16 @@ inline void Environment::TryLoadAddon( | |||
| 404 | 404 | } | |
| 405 | 405 | } | |
| 406 | 406 | ||
| 407 | + #if HAVE_INSPECTOR | ||
| 408 | + inline bool Environment::is_in_inspector_console_call() const { | ||
| 409 | + return is_in_inspector_console_call_; | ||
| 410 | + } | ||
| 411 | + | ||
| 412 | + inline void Environment::set_is_in_inspector_console_call(bool value) { | ||
| 413 | + is_in_inspector_console_call_ = value; | ||
| 414 | + } | ||
| 415 | + #endif | ||
| 416 | + | ||
| 407 | 417 | inline Environment::AsyncHooks* Environment::async_hooks() { | |
| 408 | 418 | return &async_hooks_; | |
| 409 | 419 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -874,6 +874,9 @@ class Environment { | |||
| 874 | 874 | inline inspector::Agent* inspector_agent() const { | |
| 875 | 875 | return inspector_agent_.get(); | |
| 876 | 876 | } | |
| 877 | + | ||
| 878 | + inline bool is_in_inspector_console_call() const; | ||
| 879 | + inline void set_is_in_inspector_console_call(bool value); | ||
| 877 | 880 | #endif | |
| 878 | 881 | ||
| 879 | 882 | typedef ListHead<HandleWrap, &HandleWrap::handle_wrap_queue_> HandleWrapQueue; | |
@@ -1043,6 +1046,7 @@ class Environment { | |||
| 1043 | 1046 | ||
| 1044 | 1047 | #if HAVE_INSPECTOR | |
| 1045 | 1048 | std::unique_ptr<inspector::Agent> inspector_agent_; | |
| 1049 | + bool is_in_inspector_console_call_ = false; | ||
| 1046 | 1050 | #endif | |
| 1047 | 1051 | ||
| 1048 | 1052 | // handle_wrap_queue_ and req_wrap_queue_ needs to be at a fixed offset from | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -149,31 +149,22 @@ void InspectorConsoleCall(const FunctionCallbackInfo<Value>& info) { | |||
| 149 | 149 | Environment* env = Environment::GetCurrent(info); | |
| 150 | 150 | Isolate* isolate = env->isolate(); | |
| 151 | 151 | Local<Context> context = isolate->GetCurrentContext(); | |
| 152 | - CHECK_LT(2, info.Length()); | ||
| 153 | - SlicedArguments call_args(info, /* start */ 3); | ||
| 152 | + CHECK_GE(info.Length(), 2); | ||
| 153 | + SlicedArguments call_args(info, /* start */ 2); | ||
| 154 | 154 | if (InspectorEnabled(env)) { | |
| 155 | 155 | Local<Value> inspector_method = info[0]; | |
| 156 | 156 | CHECK(inspector_method->IsFunction()); | |
| 157 | - Local<Value> config_value = info[2]; | ||
| 158 | - CHECK(config_value->IsObject()); | ||
| 159 | - Local<Object> config_object = config_value.As<Object>(); | ||
| 160 | - Local<String> in_call_key = FIXED_ONE_BYTE_STRING(isolate, "in_call"); | ||
| 161 | - bool has_in_call; | ||
| 162 | - if (!config_object->Has(context, in_call_key).To(&has_in_call)) | ||
| 163 | - return; | ||
| 164 | - if (!has_in_call) { | ||
| 165 | - if (config_object->Set(context, | ||
| 166 | - in_call_key, | ||
| 167 | - v8::True(isolate)).IsNothing() || | ||
| 157 | + if (!env->is_in_inspector_console_call()) { | ||
| 158 | + env->set_is_in_inspector_console_call(true); | ||
| 159 | + MaybeLocal<Value> ret = | ||
| 168 | 160 | inspector_method.As<Function>()->Call(context, | |
| 169 | 161 | info.Holder(), | |
| 170 | 162 | call_args.length(), | |
| 171 | - call_args.out()).IsEmpty()) { | ||
| 163 | + call_args.out()); | ||
| 164 | + env->set_is_in_inspector_console_call(false); | ||
| 165 | + if (ret.IsEmpty()) | ||
| 172 | 166 | return; | |
| 173 | - } | ||
| 174 | 167 | } | |
| 175 | - if (config_object->Delete(context, in_call_key).IsNothing()) | ||
| 176 | - return; | ||
| 177 | 168 | } | |
| 178 | 169 | ||
| 179 | 170 | Local<Value> node_method = info[1]; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments