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/inspected-context.h" | 5 #include "src/inspector/inspected-context.h" |
6 | 6 |
7 #include "src/inspector/injected-script.h" | 7 #include "src/inspector/injected-script.h" |
8 #include "src/inspector/string-util.h" | 8 #include "src/inspector/string-util.h" |
9 #include "src/inspector/v8-console.h" | 9 #include "src/inspector/v8-console.h" |
10 #include "src/inspector/v8-inspector-impl.h" | 10 #include "src/inspector/v8-inspector-impl.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 m_humanReadableName(toString16(info.humanReadableName)), | 41 m_humanReadableName(toString16(info.humanReadableName)), |
42 m_auxData(toString16(info.auxData)), | 42 m_auxData(toString16(info.auxData)), |
43 m_reported(false) { | 43 m_reported(false) { |
44 m_context.SetWeak(&m_context, &clearContext, | 44 m_context.SetWeak(&m_context, &clearContext, |
45 v8::WeakCallbackType::kParameter); | 45 v8::WeakCallbackType::kParameter); |
46 | 46 |
47 v8::Isolate* isolate = m_inspector->isolate(); | 47 v8::Isolate* isolate = m_inspector->isolate(); |
48 v8::Local<v8::Object> global = info.context->Global(); | 48 v8::Local<v8::Object> global = info.context->Global(); |
49 v8::Local<v8::Object> console = | 49 v8::Local<v8::Object> console = |
50 V8Console::createConsole(this, info.hasMemoryOnConsole); | 50 V8Console::createConsole(this, info.hasMemoryOnConsole); |
51 v8::PropertyDescriptor descriptor(console, /* writable */ true); | 51 if (!global |
52 descriptor.set_enumerable(false); | 52 ->Set(info.context, toV8StringInternalized(isolate, "console"), |
53 descriptor.set_configurable(true); | 53 console) |
54 v8::Local<v8::String> consoleKey = toV8StringInternalized(isolate, "console"); | |
55 if (!global->DefineProperty(info.context, consoleKey, descriptor) | |
56 .FromMaybe(false)) | 54 .FromMaybe(false)) |
57 return; | 55 return; |
58 m_console.Reset(isolate, console); | 56 m_console.Reset(isolate, console); |
59 m_console.SetWeak(); | 57 m_console.SetWeak(); |
60 } | 58 } |
61 | 59 |
62 InspectedContext::~InspectedContext() { | 60 InspectedContext::~InspectedContext() { |
63 if (!m_console.IsEmpty()) { | 61 if (!m_console.IsEmpty()) { |
64 v8::HandleScope scope(isolate()); | 62 v8::HandleScope scope(isolate()); |
65 V8Console::clearInspectedContextIfNeeded(context(), | 63 V8Console::clearInspectedContextIfNeeded(context(), |
(...skipping 10 matching lines...) Expand all Loading... |
76 } | 74 } |
77 | 75 |
78 void InspectedContext::createInjectedScript() { | 76 void InspectedContext::createInjectedScript() { |
79 DCHECK(!m_injectedScript); | 77 DCHECK(!m_injectedScript); |
80 m_injectedScript = InjectedScript::create(this); | 78 m_injectedScript = InjectedScript::create(this); |
81 } | 79 } |
82 | 80 |
83 void InspectedContext::discardInjectedScript() { m_injectedScript.reset(); } | 81 void InspectedContext::discardInjectedScript() { m_injectedScript.reset(); } |
84 | 82 |
85 } // namespace v8_inspector | 83 } // namespace v8_inspector |
OLD | NEW |