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

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

Issue 2253643002: [DevTools] Copy objects from debugger context to inspected context properly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copier Created 4 years, 4 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/v8_inspector/InjectedScript.h" 7 #include "platform/v8_inspector/InjectedScript.h"
8 #include "platform/v8_inspector/InspectedContext.h" 8 #include "platform/v8_inspector/InspectedContext.h"
9 #include "platform/v8_inspector/V8Compat.h" 9 #include "platform/v8_inspector/V8Compat.h"
10 #include "platform/v8_inspector/V8ConsoleMessage.h" 10 #include "platform/v8_inspector/V8ConsoleMessage.h"
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 } 652 }
653 653
654 v8::Local<v8::Object> V8Console::createConsole(InspectedContext* inspectedContex t, bool hasMemoryAttribute) 654 v8::Local<v8::Object> V8Console::createConsole(InspectedContext* inspectedContex t, bool hasMemoryAttribute)
655 { 655 {
656 v8::Local<v8::Context> context = inspectedContext->context(); 656 v8::Local<v8::Context> context = inspectedContext->context();
657 v8::Context::Scope contextScope(context); 657 v8::Context::Scope contextScope(context);
658 v8::Isolate* isolate = context->GetIsolate(); 658 v8::Isolate* isolate = context->GetIsolate();
659 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks); 659 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks);
660 660
661 v8::Local<v8::Object> console = v8::Object::New(isolate); 661 v8::Local<v8::Object> console = v8::Object::New(isolate);
662 bool success = console->SetPrototype(context, v8::Object::New(isolate)).From Maybe(false);
663 DCHECK(success);
662 664
663 createBoundFunctionProperty(context, console, "debug", V8Console::debugCallb ack); 665 createBoundFunctionProperty(context, console, "debug", V8Console::debugCallb ack);
664 createBoundFunctionProperty(context, console, "error", V8Console::errorCallb ack); 666 createBoundFunctionProperty(context, console, "error", V8Console::errorCallb ack);
665 createBoundFunctionProperty(context, console, "info", V8Console::infoCallbac k); 667 createBoundFunctionProperty(context, console, "info", V8Console::infoCallbac k);
666 createBoundFunctionProperty(context, console, "log", V8Console::logCallback) ; 668 createBoundFunctionProperty(context, console, "log", V8Console::logCallback) ;
667 createBoundFunctionProperty(context, console, "warn", V8Console::warnCallbac k); 669 createBoundFunctionProperty(context, console, "warn", V8Console::warnCallbac k);
668 createBoundFunctionProperty(context, console, "dir", V8Console::dirCallback) ; 670 createBoundFunctionProperty(context, console, "dir", V8Console::dirCallback) ;
669 createBoundFunctionProperty(context, console, "dirxml", V8Console::dirxmlCal lback); 671 createBoundFunctionProperty(context, console, "dirxml", V8Console::dirxmlCal lback);
670 createBoundFunctionProperty(context, console, "table", V8Console::tableCallb ack); 672 createBoundFunctionProperty(context, console, "table", V8Console::tableCallb ack);
671 createBoundFunctionProperty(context, console, "trace", V8Console::traceCallb ack); 673 createBoundFunctionProperty(context, console, "trace", V8Console::traceCallb ack);
672 createBoundFunctionProperty(context, console, "group", V8Console::groupCallb ack); 674 createBoundFunctionProperty(context, console, "group", V8Console::groupCallb ack);
673 createBoundFunctionProperty(context, console, "groupCollapsed", V8Console::g roupCollapsedCallback); 675 createBoundFunctionProperty(context, console, "groupCollapsed", V8Console::g roupCollapsedCallback);
674 createBoundFunctionProperty(context, console, "groupEnd", V8Console::groupEn dCallback); 676 createBoundFunctionProperty(context, console, "groupEnd", V8Console::groupEn dCallback);
675 createBoundFunctionProperty(context, console, "clear", V8Console::clearCallb ack); 677 createBoundFunctionProperty(context, console, "clear", V8Console::clearCallb ack);
676 createBoundFunctionProperty(context, console, "count", V8Console::countCallb ack); 678 createBoundFunctionProperty(context, console, "count", V8Console::countCallb ack);
677 createBoundFunctionProperty(context, console, "assert", V8Console::assertCal lback); 679 createBoundFunctionProperty(context, console, "assert", V8Console::assertCal lback);
678 createBoundFunctionProperty(context, console, "markTimeline", V8Console::mar kTimelineCallback); 680 createBoundFunctionProperty(context, console, "markTimeline", V8Console::mar kTimelineCallback);
679 createBoundFunctionProperty(context, console, "profile", V8Console::profileC allback); 681 createBoundFunctionProperty(context, console, "profile", V8Console::profileC allback);
680 createBoundFunctionProperty(context, console, "profileEnd", V8Console::profi leEndCallback); 682 createBoundFunctionProperty(context, console, "profileEnd", V8Console::profi leEndCallback);
681 createBoundFunctionProperty(context, console, "timeline", V8Console::timelin eCallback); 683 createBoundFunctionProperty(context, console, "timeline", V8Console::timelin eCallback);
682 createBoundFunctionProperty(context, console, "timelineEnd", V8Console::time lineEndCallback); 684 createBoundFunctionProperty(context, console, "timelineEnd", V8Console::time lineEndCallback);
683 createBoundFunctionProperty(context, console, "time", V8Console::timeCallbac k); 685 createBoundFunctionProperty(context, console, "time", V8Console::timeCallbac k);
684 createBoundFunctionProperty(context, console, "timeEnd", V8Console::timeEndC allback); 686 createBoundFunctionProperty(context, console, "timeEnd", V8Console::timeEndC allback);
685 createBoundFunctionProperty(context, console, "timeStamp", V8Console::timeSt ampCallback); 687 createBoundFunctionProperty(context, console, "timeStamp", V8Console::timeSt ampCallback);
686 688
687 bool success = console->SetPrototype(context, v8::Object::New(isolate)).From Maybe(false);
688 DCHECK(success);
689
690 if (hasMemoryAttribute) 689 if (hasMemoryAttribute)
691 console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, V8Console::memoryGetterCallback, conso le, 0).ToLocalChecked(), V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, V8Console::me morySetterCallback, v8::Local<v8::Value>(), 0).ToLocalChecked(), static_cast<v8: :PropertyAttribute>(v8::None), v8::DEFAULT); 690 console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, V8Console::memoryGetterCallback, conso le, 0).ToLocalChecked(), V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, V8Console::me morySetterCallback, v8::Local<v8::Value>(), 0).ToLocalChecked(), static_cast<v8: :PropertyAttribute>(v8::None), v8::DEFAULT);
692 691
693 console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::Extern al::New(isolate, inspectedContext)); 692 console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::Extern al::New(isolate, inspectedContext));
694 return console; 693 return console;
695 } 694 }
696 695
697 void V8Console::clearInspectedContextIfNeeded(v8::Local<v8::Context> context, v8 ::Local<v8::Object> console) 696 void V8Console::clearInspectedContextIfNeeded(v8::Local<v8::Context> context, v8 ::Local<v8::Object> console)
698 { 697 {
699 v8::Isolate* isolate = context->GetIsolate(); 698 v8::Isolate* isolate = context->GetIsolate();
700 console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::Extern al::New(isolate, nullptr)); 699 console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::Extern al::New(isolate, nullptr));
701 } 700 }
702 701
703 v8::Local<v8::Object> V8Console::createCommandLineAPI(InspectedContext* inspecte dContext) 702 v8::Local<v8::Object> V8Console::createCommandLineAPI(InspectedContext* inspecte dContext)
704 { 703 {
705 v8::Local<v8::Context> context = inspectedContext->context(); 704 v8::Local<v8::Context> context = inspectedContext->context();
706 v8::Isolate* isolate = context->GetIsolate(); 705 v8::Isolate* isolate = context->GetIsolate();
707 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks); 706 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks);
708 707
709 v8::Local<v8::Object> commandLineAPI = v8::Object::New(isolate); 708 v8::Local<v8::Object> commandLineAPI = v8::Object::New(isolate);
709 bool success = commandLineAPI->SetPrototype(context, v8::Null(isolate)).From Maybe(false);
710 DCHECK(success);
710 711
711 createBoundFunctionProperty(context, commandLineAPI, "dir", V8Console::dirCa llback, "function dir(value) { [Command Line API] }"); 712 createBoundFunctionProperty(context, commandLineAPI, "dir", V8Console::dirCa llback, "function dir(value) { [Command Line API] }");
712 createBoundFunctionProperty(context, commandLineAPI, "dirxml", V8Console::di rxmlCallback, "function dirxml(value) { [Command Line API] }"); 713 createBoundFunctionProperty(context, commandLineAPI, "dirxml", V8Console::di rxmlCallback, "function dirxml(value) { [Command Line API] }");
713 createBoundFunctionProperty(context, commandLineAPI, "profile", V8Console::p rofileCallback, "function profile(title) { [Command Line API] }"); 714 createBoundFunctionProperty(context, commandLineAPI, "profile", V8Console::p rofileCallback, "function profile(title) { [Command Line API] }");
714 createBoundFunctionProperty(context, commandLineAPI, "profileEnd", V8Console ::profileEndCallback, "function profileEnd(title) { [Command Line API] }"); 715 createBoundFunctionProperty(context, commandLineAPI, "profileEnd", V8Console ::profileEndCallback, "function profileEnd(title) { [Command Line API] }");
715 createBoundFunctionProperty(context, commandLineAPI, "clear", V8Console::cle arCallback, "function clear() { [Command Line API] }"); 716 createBoundFunctionProperty(context, commandLineAPI, "clear", V8Console::cle arCallback, "function clear() { [Command Line API] }");
716 createBoundFunctionProperty(context, commandLineAPI, "table", V8Console::tab leCallback, "function table(data, [columns]) { [Command Line API] }"); 717 createBoundFunctionProperty(context, commandLineAPI, "table", V8Console::tab leCallback, "function table(data, [columns]) { [Command Line API] }");
717 718
718 createBoundFunctionProperty(context, commandLineAPI, "keys", V8Console::keys Callback, "function keys(object) { [Command Line API] }"); 719 createBoundFunctionProperty(context, commandLineAPI, "keys", V8Console::keys Callback, "function keys(object) { [Command Line API] }");
719 createBoundFunctionProperty(context, commandLineAPI, "values", V8Console::va luesCallback, "function values(object) { [Command Line API] }"); 720 createBoundFunctionProperty(context, commandLineAPI, "values", V8Console::va luesCallback, "function values(object) { [Command Line API] }");
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 continue; 822 continue;
822 if (name->IsString()) { 823 if (name->IsString()) {
823 v8::Local<v8::Value> descriptor; 824 v8::Local<v8::Value> descriptor;
824 bool success = m_global->GetOwnPropertyDescriptor(m_context, v8::Loc al<v8::String>::Cast(name)).ToLocal(&descriptor); 825 bool success = m_global->GetOwnPropertyDescriptor(m_context, v8::Loc al<v8::String>::Cast(name)).ToLocal(&descriptor);
825 DCHECK(success); 826 DCHECK(success);
826 } 827 }
827 } 828 }
828 } 829 }
829 830
830 } // namespace v8_inspector 831 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/blink_platform.gypi ('k') | third_party/WebKit/Source/platform/v8_inspector/V8Debugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698