Commit 03c6a235 authored by Alex Rudenko's avatar Alex Rudenko Committed by V8 LUCI CQ

Revert "Expose V8CommandLineAPIScope and V8InspectorSession::createCommandLineAPI"

This reverts commit 1527c487.

Reason for revert: reverted in favour of https://chromium-review.googlesource.com/c/v8/v8/+/2857640

Original change's description:
> Expose V8CommandLineAPIScope and V8InspectorSession::createCommandLineAPI
>
> This CL extracts CommandLineAPIScope from V8Console and exposes it
> as V8CommandLineAPIScope. Also, it exposes V8InspectorSession::createCommandLineAPI.
> These changes will be used by InspectorPageAgent to install command
> line APIs when evaluating scripts added using CDP's command
> Page.addScriptToEvaluateOnNewDocument.
>
> Chromium CL: https://crrev.com/c/2835786
>
> Doc: https://docs.google.com/document/d/1zGG7-NZMb-aOfFfHf1u4VsP4C-lZettopCvYDC6pkBw/
> Bug: chromium:1200705
> Change-Id: I39b27f957cfb6d682ea84e385eaf25d09d261b58
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2835712
> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
> Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#74096}

Bug: chromium:1200705
Change-Id: Ic7f411f3c66dd33c1b021dab90f202b361ee85c2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2859953Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74350}
parent bfc8950e
...@@ -35,28 +35,6 @@ class Domain; ...@@ -35,28 +35,6 @@ class Domain;
} }
} // namespace protocol } // namespace protocol
class V8_EXPORT V8CommandLineAPIScope {
public:
V8CommandLineAPIScope(v8::Local<v8::Context>,
v8::Local<v8::Object> commandLineAPI,
v8::Local<v8::Object> global);
~V8CommandLineAPIScope();
V8CommandLineAPIScope(const V8CommandLineAPIScope&) = delete;
V8CommandLineAPIScope& operator=(const V8CommandLineAPIScope&) = delete;
private:
static void accessorGetterCallback(
v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&);
static void accessorSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value>,
const v8::PropertyCallbackInfo<void>&);
v8::Local<v8::Context> m_context;
v8::Local<v8::Object> m_commandLineAPI;
v8::Local<v8::Object> m_global;
v8::Local<v8::Set> m_installedMethods;
v8::Local<v8::ArrayBuffer> m_thisReference;
};
class V8_EXPORT StringView { class V8_EXPORT StringView {
public: public:
StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {} StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {}
...@@ -165,8 +143,6 @@ class V8_EXPORT V8InspectorSession { ...@@ -165,8 +143,6 @@ class V8_EXPORT V8InspectorSession {
virtual std::vector<std::unique_ptr<protocol::Schema::API::Domain>> virtual std::vector<std::unique_ptr<protocol::Schema::API::Domain>>
supportedDomains() = 0; supportedDomains() = 0;
virtual v8::Local<v8::Object> createCommandLineAPI(
v8::Local<v8::Context> context) = 0;
virtual std::unique_ptr<V8InspectorSession::CommandLineAPIScope> virtual std::unique_ptr<V8InspectorSession::CommandLineAPIScope>
initializeCommandLineAPIScope(int executionContextId) = 0; initializeCommandLineAPIScope(int executionContextId) = 0;
......
...@@ -891,7 +891,7 @@ Response InjectedScript::Scope::initialize() { ...@@ -891,7 +891,7 @@ Response InjectedScript::Scope::initialize() {
void InjectedScript::Scope::installCommandLineAPI() { void InjectedScript::Scope::installCommandLineAPI() {
DCHECK(m_injectedScript && !m_context.IsEmpty() && DCHECK(m_injectedScript && !m_context.IsEmpty() &&
!m_commandLineAPIScope.get()); !m_commandLineAPIScope.get());
m_commandLineAPIScope.reset(new V8CommandLineAPIScope( m_commandLineAPIScope.reset(new V8Console::CommandLineAPIScope(
m_context, m_injectedScript->commandLineAPI(), m_context->Global())); m_context, m_injectedScript->commandLineAPI(), m_context->Global()));
} }
......
...@@ -164,7 +164,7 @@ class InjectedScript final { ...@@ -164,7 +164,7 @@ class InjectedScript final {
v8::HandleScope m_handleScope; v8::HandleScope m_handleScope;
v8::TryCatch m_tryCatch; v8::TryCatch m_tryCatch;
v8::Local<v8::Context> m_context; v8::Local<v8::Context> m_context;
std::unique_ptr<V8CommandLineAPIScope> m_commandLineAPIScope; std::unique_ptr<V8Console::CommandLineAPIScope> m_commandLineAPIScope;
bool m_ignoreExceptionsAndMuteConsole; bool m_ignoreExceptionsAndMuteConsole;
v8::debug::ExceptionBreakState m_previousPauseOnExceptionsState; v8::debug::ExceptionBreakState m_previousPauseOnExceptionsState;
bool m_userGesture; bool m_userGesture;
......
...@@ -783,9 +783,9 @@ static bool isCommandLineAPIGetter(const String16& name) { ...@@ -783,9 +783,9 @@ static bool isCommandLineAPIGetter(const String16& name) {
((name[1] >= '0' && name[1] <= '4') || name[1] == '_'); ((name[1] >= '0' && name[1] <= '4') || name[1] == '_');
} }
void V8CommandLineAPIScope::accessorGetterCallback( void V8Console::CommandLineAPIScope::accessorGetterCallback(
v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
V8CommandLineAPIScope* scope = *static_cast<V8CommandLineAPIScope**>( CommandLineAPIScope* scope = *static_cast<CommandLineAPIScope**>(
info.Data().As<v8::ArrayBuffer>()->GetBackingStore()->Data()); info.Data().As<v8::ArrayBuffer>()->GetBackingStore()->Data());
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
if (scope == nullptr) { if (scope == nullptr) {
...@@ -810,10 +810,10 @@ void V8CommandLineAPIScope::accessorGetterCallback( ...@@ -810,10 +810,10 @@ void V8CommandLineAPIScope::accessorGetterCallback(
} }
} }
void V8CommandLineAPIScope::accessorSetterCallback( void V8Console::CommandLineAPIScope::accessorSetterCallback(
v8::Local<v8::Name> name, v8::Local<v8::Value> value, v8::Local<v8::Name> name, v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info) { const v8::PropertyCallbackInfo<void>& info) {
V8CommandLineAPIScope* scope = *static_cast<V8CommandLineAPIScope**>( CommandLineAPIScope* scope = *static_cast<CommandLineAPIScope**>(
info.Data().As<v8::ArrayBuffer>()->GetBackingStore()->Data()); info.Data().As<v8::ArrayBuffer>()->GetBackingStore()->Data());
if (scope == nullptr) return; if (scope == nullptr) return;
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
...@@ -823,7 +823,7 @@ void V8CommandLineAPIScope::accessorSetterCallback( ...@@ -823,7 +823,7 @@ void V8CommandLineAPIScope::accessorSetterCallback(
USE(scope->m_installedMethods->Delete(context, name).FromMaybe(false)); USE(scope->m_installedMethods->Delete(context, name).FromMaybe(false));
} }
V8CommandLineAPIScope::V8CommandLineAPIScope( V8Console::CommandLineAPIScope::CommandLineAPIScope(
v8::Local<v8::Context> context, v8::Local<v8::Object> commandLineAPI, v8::Local<v8::Context> context, v8::Local<v8::Object> commandLineAPI,
v8::Local<v8::Object> global) v8::Local<v8::Object> global)
: m_context(context), : m_context(context),
...@@ -834,9 +834,9 @@ V8CommandLineAPIScope::V8CommandLineAPIScope( ...@@ -834,9 +834,9 @@ V8CommandLineAPIScope::V8CommandLineAPIScope(
v8::MicrotasksScope::kDoNotRunMicrotasks); v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Array> names; v8::Local<v8::Array> names;
if (!m_commandLineAPI->GetOwnPropertyNames(context).ToLocal(&names)) return; if (!m_commandLineAPI->GetOwnPropertyNames(context).ToLocal(&names)) return;
m_thisReference = v8::ArrayBuffer::New(context->GetIsolate(), m_thisReference =
sizeof(V8CommandLineAPIScope*)); v8::ArrayBuffer::New(context->GetIsolate(), sizeof(CommandLineAPIScope*));
*static_cast<V8CommandLineAPIScope**>( *static_cast<CommandLineAPIScope**>(
m_thisReference->GetBackingStore()->Data()) = this; m_thisReference->GetBackingStore()->Data()) = this;
for (uint32_t i = 0; i < names->Length(); ++i) { for (uint32_t i = 0; i < names->Length(); ++i) {
v8::Local<v8::Value> name; v8::Local<v8::Value> name;
...@@ -846,8 +846,8 @@ V8CommandLineAPIScope::V8CommandLineAPIScope( ...@@ -846,8 +846,8 @@ V8CommandLineAPIScope::V8CommandLineAPIScope(
continue; continue;
if (!m_global if (!m_global
->SetAccessor(context, name.As<v8::Name>(), ->SetAccessor(context, name.As<v8::Name>(),
V8CommandLineAPIScope::accessorGetterCallback, CommandLineAPIScope::accessorGetterCallback,
V8CommandLineAPIScope::accessorSetterCallback, CommandLineAPIScope::accessorSetterCallback,
m_thisReference, v8::DEFAULT, v8::DontEnum, m_thisReference, v8::DEFAULT, v8::DontEnum,
v8::SideEffectType::kHasNoSideEffect) v8::SideEffectType::kHasNoSideEffect)
.FromMaybe(false)) { .FromMaybe(false)) {
...@@ -859,10 +859,10 @@ V8CommandLineAPIScope::V8CommandLineAPIScope( ...@@ -859,10 +859,10 @@ V8CommandLineAPIScope::V8CommandLineAPIScope(
} }
} }
V8CommandLineAPIScope::~V8CommandLineAPIScope() { V8Console::CommandLineAPIScope::~CommandLineAPIScope() {
v8::MicrotasksScope microtasksScope(m_context->GetIsolate(), v8::MicrotasksScope microtasksScope(m_context->GetIsolate(),
v8::MicrotasksScope::kDoNotRunMicrotasks); v8::MicrotasksScope::kDoNotRunMicrotasks);
*static_cast<V8CommandLineAPIScope**>( *static_cast<CommandLineAPIScope**>(
m_thisReference->GetBackingStore()->Data()) = nullptr; m_thisReference->GetBackingStore()->Data()) = nullptr;
v8::Local<v8::Array> names = m_installedMethods->AsArray(); v8::Local<v8::Array> names = m_installedMethods->AsArray();
for (uint32_t i = 0; i < names->Length(); ++i) { for (uint32_t i = 0; i < names->Length(); ++i) {
......
...@@ -24,6 +24,29 @@ class V8Console : public v8::debug::ConsoleDelegate { ...@@ -24,6 +24,29 @@ class V8Console : public v8::debug::ConsoleDelegate {
void installMemoryGetter(v8::Local<v8::Context> context, void installMemoryGetter(v8::Local<v8::Context> context,
v8::Local<v8::Object> console); v8::Local<v8::Object> console);
class V8_NODISCARD CommandLineAPIScope {
public:
CommandLineAPIScope(v8::Local<v8::Context>,
v8::Local<v8::Object> commandLineAPI,
v8::Local<v8::Object> global);
~CommandLineAPIScope();
CommandLineAPIScope(const CommandLineAPIScope&) = delete;
CommandLineAPIScope& operator=(const CommandLineAPIScope&) = delete;
private:
static void accessorGetterCallback(
v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&);
static void accessorSetterCallback(v8::Local<v8::Name>,
v8::Local<v8::Value>,
const v8::PropertyCallbackInfo<void>&);
v8::Local<v8::Context> m_context;
v8::Local<v8::Object> m_commandLineAPI;
v8::Local<v8::Object> m_global;
v8::Local<v8::Set> m_installedMethods;
v8::Local<v8::ArrayBuffer> m_thisReference;
};
explicit V8Console(V8InspectorImpl* inspector); explicit V8Console(V8InspectorImpl* inspector);
private: private:
......
...@@ -169,11 +169,6 @@ V8InspectorSessionImpl::initializeCommandLineAPIScope(int executionContextId) { ...@@ -169,11 +169,6 @@ V8InspectorSessionImpl::initializeCommandLineAPIScope(int executionContextId) {
return scope; return scope;
} }
v8::Local<v8::Object> V8InspectorSessionImpl::createCommandLineAPI(
v8::Local<v8::Context> context) {
return inspector()->console()->createCommandLineAPI(context, sessionId());
}
protocol::DictionaryValue* V8InspectorSessionImpl::agentState( protocol::DictionaryValue* V8InspectorSessionImpl::agentState(
const String16& name) { const String16& name) {
protocol::DictionaryValue* state = m_state->getObject(name); protocol::DictionaryValue* state = m_state->getObject(name);
......
...@@ -50,9 +50,6 @@ class V8InspectorSessionImpl : public V8InspectorSession, ...@@ -50,9 +50,6 @@ class V8InspectorSessionImpl : public V8InspectorSession,
int contextGroupId() const { return m_contextGroupId; } int contextGroupId() const { return m_contextGroupId; }
int sessionId() const { return m_sessionId; } int sessionId() const { return m_sessionId; }
v8::Local<v8::Object> createCommandLineAPI(
v8::Local<v8::Context> context) override;
std::unique_ptr<V8InspectorSession::CommandLineAPIScope> std::unique_ptr<V8InspectorSession::CommandLineAPIScope>
initializeCommandLineAPIScope(int executionContextId) override; initializeCommandLineAPIScope(int executionContextId) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment