Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8Console.cpp

Issue 1995423002: [DevTools] Set vanilla object as console prototype (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium 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 "platform/v8_inspector/V8Console.h" 5 #include "platform/v8_inspector/V8Console.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/v8_inspector/InjectedScript.h" 8 #include "platform/v8_inspector/InjectedScript.h"
9 #include "platform/v8_inspector/InspectedContext.h" 9 #include "platform/v8_inspector/InspectedContext.h"
10 #include "platform/v8_inspector/V8Compat.h" 10 #include "platform/v8_inspector/V8Compat.h"
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 if (V8InspectorSessionImpl* session = helper.currentSession()) { 617 if (V8InspectorSessionImpl* session = helper.currentSession()) {
618 V8InspectorSession::Inspectable* object = session->inspectedObject(num); 618 V8InspectorSession::Inspectable* object = session->inspectedObject(num);
619 v8::Isolate* isolate = info.GetIsolate(); 619 v8::Isolate* isolate = info.GetIsolate();
620 if (object) 620 if (object)
621 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext())) ; 621 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext())) ;
622 else 622 else
623 info.GetReturnValue().Set(v8::Undefined(isolate)); 623 info.GetReturnValue().Set(v8::Undefined(isolate));
624 } 624 }
625 } 625 }
626 626
627 static void suppressBoolUnused(bool) {}
628
627 v8::Local<v8::Object> V8Console::createConsole(InspectedContext* inspectedContex t, bool hasMemoryAttribute) 629 v8::Local<v8::Object> V8Console::createConsole(InspectedContext* inspectedContex t, bool hasMemoryAttribute)
628 { 630 {
629 v8::Local<v8::Context> context = inspectedContext->context(); 631 v8::Local<v8::Context> context = inspectedContext->context();
630 v8::Isolate* isolate = context->GetIsolate(); 632 v8::Isolate* isolate = context->GetIsolate();
631 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks); 633 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks);
632 634
633 v8::Local<v8::Object> console = v8::Object::New(isolate); 635 v8::Local<v8::Object> console = v8::Object::New(isolate);
634 636
635 createBoundFunctionProperty(context, console, "debug", V8Console::debugCallb ack); 637 createBoundFunctionProperty(context, console, "debug", V8Console::debugCallb ack);
636 createBoundFunctionProperty(context, console, "error", V8Console::errorCallb ack); 638 createBoundFunctionProperty(context, console, "error", V8Console::errorCallb ack);
(...skipping 12 matching lines...) Expand all
649 createBoundFunctionProperty(context, console, "assert", V8Console::assertCal lback); 651 createBoundFunctionProperty(context, console, "assert", V8Console::assertCal lback);
650 createBoundFunctionProperty(context, console, "markTimeline", V8Console::mar kTimelineCallback); 652 createBoundFunctionProperty(context, console, "markTimeline", V8Console::mar kTimelineCallback);
651 createBoundFunctionProperty(context, console, "profile", V8Console::profileC allback); 653 createBoundFunctionProperty(context, console, "profile", V8Console::profileC allback);
652 createBoundFunctionProperty(context, console, "profileEnd", V8Console::profi leEndCallback); 654 createBoundFunctionProperty(context, console, "profileEnd", V8Console::profi leEndCallback);
653 createBoundFunctionProperty(context, console, "timeline", V8Console::timelin eCallback); 655 createBoundFunctionProperty(context, console, "timeline", V8Console::timelin eCallback);
654 createBoundFunctionProperty(context, console, "timelineEnd", V8Console::time lineEndCallback); 656 createBoundFunctionProperty(context, console, "timelineEnd", V8Console::time lineEndCallback);
655 createBoundFunctionProperty(context, console, "time", V8Console::timeCallbac k); 657 createBoundFunctionProperty(context, console, "time", V8Console::timeCallbac k);
656 createBoundFunctionProperty(context, console, "timeEnd", V8Console::timeEndC allback); 658 createBoundFunctionProperty(context, console, "timeEnd", V8Console::timeEndC allback);
657 createBoundFunctionProperty(context, console, "timeStamp", V8Console::timeSt ampCallback); 659 createBoundFunctionProperty(context, console, "timeStamp", V8Console::timeSt ampCallback);
658 660
661 suppressBoolUnused(console->SetPrototype(context, v8::Object::New(isolate)). FromMaybe(false));
dgozman 2016/05/20 18:26:36 Use DCHECK.
kozy 2016/05/20 18:32:52 Done.
662
659 if (hasMemoryAttribute) 663 if (hasMemoryAttribute)
660 console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), v8::Function::New(isolate, V8Console::memoryGetterCallback, console), v8::Functi on::New(isolate, V8Console::memorySetterCallback), static_cast<v8::PropertyAttri bute>(v8::None), v8::DEFAULT); 664 console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), v8::Function::New(isolate, V8Console::memoryGetterCallback, console), v8::Functi on::New(isolate, V8Console::memorySetterCallback), static_cast<v8::PropertyAttri bute>(v8::None), v8::DEFAULT);
661 665
662 console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::Extern al::New(isolate, inspectedContext)); 666 console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::Extern al::New(isolate, inspectedContext));
663 return console; 667 return console;
664 } 668 }
665 669
666 v8::Local<v8::Object> V8Console::createCommandLineAPI(InspectedContext* inspecte dContext) 670 v8::Local<v8::Object> V8Console::createCommandLineAPI(InspectedContext* inspecte dContext)
667 { 671 {
668 v8::Local<v8::Context> context = inspectedContext->context(); 672 v8::Local<v8::Context> context = inspectedContext->context();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, getters, ()); 727 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, getters, ());
724 if (getters.size() == 0) { 728 if (getters.size() == 0) {
725 const char* members[] = { "$0", "$1", "$2", "$3", "$4", "$_" }; 729 const char* members[] = { "$0", "$1", "$2", "$3", "$4", "$_" };
726 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i) 730 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i)
727 getters.add(members[i]); 731 getters.add(members[i]);
728 } 732 }
729 return getters.find(name) != getters.end(); 733 return getters.find(name) != getters.end();
730 } 734 }
731 735
732 } // namespace blink 736 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698