| 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->callFunction(v8::Local<v8::Function>::Cast(setupFunction), |  | 
|  736                             context, console, 0, nullptr); |  | 
|  737   } |  | 
|  738  |  | 
|  739   if (hasMemoryAttribute) |  717   if (hasMemoryAttribute) | 
|  740     console->SetAccessorProperty( |  718     console->SetAccessorProperty( | 
|  741         toV8StringInternalized(isolate, "memory"), |  719         toV8StringInternalized(isolate, "memory"), | 
|  742         v8::Function::New(context, V8Console::memoryGetterCallback, console, 0, |  720         v8::Function::New(context, V8Console::memoryGetterCallback, console, 0, | 
|  743                           v8::ConstructorBehavior::kThrow) |  721                           v8::ConstructorBehavior::kThrow) | 
|  744             .ToLocalChecked(), |  722             .ToLocalChecked(), | 
|  745         v8::Function::New(context, V8Console::memorySetterCallback, |  723         v8::Function::New(context, V8Console::memorySetterCallback, | 
|  746                           v8::Local<v8::Value>(), 0, |  724                           v8::Local<v8::Value>(), 0, | 
|  747                           v8::ConstructorBehavior::kThrow) |  725                           v8::ConstructorBehavior::kThrow) | 
|  748             .ToLocalChecked(), |  726             .ToLocalChecked(), | 
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  934                          ->GetOwnPropertyDescriptor( |  912                          ->GetOwnPropertyDescriptor( | 
|  935                              m_context, v8::Local<v8::String>::Cast(name)) |  913                              m_context, v8::Local<v8::String>::Cast(name)) | 
|  936                          .ToLocal(&descriptor); |  914                          .ToLocal(&descriptor); | 
|  937       DCHECK(success); |  915       DCHECK(success); | 
|  938       USE(success); |  916       USE(success); | 
|  939     } |  917     } | 
|  940   } |  918   } | 
|  941 } |  919 } | 
|  942  |  920  | 
|  943 }  // namespace v8_inspector |  921 }  // namespace v8_inspector | 
| OLD | NEW |