OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/inspector/v8-console.h" | 5 #include "src/inspector/v8-console.h" |
6 | 6 |
7 #include "src/base/macros.h" | 7 #include "src/base/macros.h" |
8 #include "src/inspector/injected-script.h" | 8 #include "src/inspector/injected-script.h" |
9 #include "src/inspector/inspected-context.h" | 9 #include "src/inspector/inspected-context.h" |
10 #include "src/inspector/string-util.h" | 10 #include "src/inspector/string-util.h" |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 V8Console::timelineCallback); | 707 V8Console::timelineCallback); |
708 createBoundFunctionProperty(context, console, "timelineEnd", | 708 createBoundFunctionProperty(context, console, "timelineEnd", |
709 V8Console::timelineEndCallback); | 709 V8Console::timelineEndCallback); |
710 createBoundFunctionProperty(context, console, "time", | 710 createBoundFunctionProperty(context, console, "time", |
711 V8Console::timeCallback); | 711 V8Console::timeCallback); |
712 createBoundFunctionProperty(context, console, "timeEnd", | 712 createBoundFunctionProperty(context, console, "timeEnd", |
713 V8Console::timeEndCallback); | 713 V8Console::timeEndCallback); |
714 createBoundFunctionProperty(context, console, "timeStamp", | 714 createBoundFunctionProperty(context, console, "timeStamp", |
715 V8Console::timeStampCallback); | 715 V8Console::timeStampCallback); |
716 | 716 |
| 717 const char* jsConsoleAssert = |
| 718 "(function(){\n" |
| 719 " var originAssert = this.assert;\n" |
| 720 " originAssert.apply = Function.prototype.apply;\n" |
| 721 " this.assert = assertWrapper;\n" |
| 722 " assertWrapper.toString = () => originAssert.toString();\n" |
| 723 " function assertWrapper(){\n" |
| 724 " if (!!arguments[0]) return;\n" |
| 725 " originAssert.apply(null, arguments);\n" |
| 726 " }\n" |
| 727 "})"; |
| 728 |
| 729 v8::Local<v8::String> assertSource = toV8String(isolate, jsConsoleAssert); |
| 730 V8InspectorImpl* inspector = inspectedContext->inspector(); |
| 731 v8::Local<v8::Value> setupFunction; |
| 732 if (inspector->compileAndRunInternalScript(context, assertSource) |
| 733 .ToLocal(&setupFunction) && |
| 734 setupFunction->IsFunction()) { |
| 735 inspector->callInternalFunction( |
| 736 v8::Local<v8::Function>::Cast(setupFunction), context, console, 0, |
| 737 nullptr); |
| 738 } |
| 739 |
717 if (hasMemoryAttribute) | 740 if (hasMemoryAttribute) |
718 console->SetAccessorProperty( | 741 console->SetAccessorProperty( |
719 toV8StringInternalized(isolate, "memory"), | 742 toV8StringInternalized(isolate, "memory"), |
720 v8::Function::New(context, V8Console::memoryGetterCallback, console, 0, | 743 v8::Function::New(context, V8Console::memoryGetterCallback, console, 0, |
721 v8::ConstructorBehavior::kThrow) | 744 v8::ConstructorBehavior::kThrow) |
722 .ToLocalChecked(), | 745 .ToLocalChecked(), |
723 v8::Function::New(context, V8Console::memorySetterCallback, | 746 v8::Function::New(context, V8Console::memorySetterCallback, |
724 v8::Local<v8::Value>(), 0, | 747 v8::Local<v8::Value>(), 0, |
725 v8::ConstructorBehavior::kThrow) | 748 v8::ConstructorBehavior::kThrow) |
726 .ToLocalChecked(), | 749 .ToLocalChecked(), |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 ->GetOwnPropertyDescriptor( | 935 ->GetOwnPropertyDescriptor( |
913 m_context, v8::Local<v8::String>::Cast(name)) | 936 m_context, v8::Local<v8::String>::Cast(name)) |
914 .ToLocal(&descriptor); | 937 .ToLocal(&descriptor); |
915 DCHECK(success); | 938 DCHECK(success); |
916 USE(success); | 939 USE(success); |
917 } | 940 } |
918 } | 941 } |
919 } | 942 } |
920 | 943 |
921 } // namespace v8_inspector | 944 } // namespace v8_inspector |
OLD | NEW |