Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
env:
global:
- NODE_VERSION=10
- NDK_VERSION=r21
- NDK_VERSION=r21b
- DATE=$(date +%Y-%m-%d)
- PACKAGE_VERSION=next-$DATE-$TRAVIS_BUILD_NUMBER
- EMULATOR_API_LEVEL=21
Expand Down
4 changes: 2 additions & 2 deletions build-artifacts/project-template-gradle/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"v8Version": "8.0.426.16",
"ndkRevision": "21.0.6113669",
"v8Version": "8.3.110.9",
"ndkRevision": "21.1.6352462",
"mksnapshotParams": "--profile_deserialization --turbo_instruction_scheduling --target_os=android --no-native-code-counters"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"version": "5.4.1",
"android": "3.5.3"
},
"android_ndk_version": "21"
"android_ndk_version": "21b"
}
1 change: 0 additions & 1 deletion test-app/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ if (NOT OPTIMIZED_BUILD OR OPTIMIZED_WITH_INSPECTOR_BUILD)
src/main/cpp/v8_inspector/src/inspector/v8-string-conversions.cc
src/main/cpp/v8_inspector/src/inspector/v8-value-utils.cc
src/main/cpp/v8_inspector/src/inspector/value-mirror.cc
src/main/cpp/v8_inspector/src/inspector/wasm-translation.cc
)
else ()
# Debug builds will include the V8 inspector sources
Expand Down
15 changes: 10 additions & 5 deletions test-app/runtime/src/main/cpp/DOMDomainCallbackHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <sstream>
#include <ArgConverter.h>
#include <NativeScriptAssert.h>
#include <v8_inspector/third_party/inspector_protocol/crdtp/json.h>
#include "DOMDomainCallbackHandlers.h"

using namespace tns;
Expand Down Expand Up @@ -41,14 +42,18 @@ void DOMDomainCallbackHandlers::ChildNodeInsertedCallback(const v8::FunctionCall
auto node = args[2]->ToString(context).ToLocalChecked();

auto resultString = V8DOMAgentImpl::AddBackendNodeIdProperty(isolate, node);
auto resultUtf16Data = resultString.data();

auto nodeJson = protocol::StringUtil::parseJSON(String16((const uint16_t*) resultUtf16Data));
auto nodeUtf16Data = resultString.data();
const String16& nodeString16 = String16((const uint16_t*) nodeUtf16Data);
std::vector<uint8_t> cbor;
v8_crdtp::json::ConvertJSONToCBOR(v8_crdtp::span<uint16_t>(nodeString16.characters16(), nodeString16.length()), &cbor);
std::unique_ptr<protocol::Value> protocolNodeJson = protocol::Value::parseBinary(cbor.data(), cbor.size());

protocol::ErrorSupport errorSupport;
auto domNode = protocol::DOM::Node::fromValue(nodeJson.get(), &errorSupport);
auto domNode = protocol::DOM::Node::fromValue(protocolNodeJson.get(), &errorSupport);

auto errorSupportString = errorSupport.errors().utf8();
std::vector<uint8_t> json;
v8_crdtp::json::ConvertCBORToJSON(errorSupport.Errors(), &json);
auto errorSupportString = String16(reinterpret_cast<const char*>(json.data()), json.size()).utf8();
if (!errorSupportString.empty()) {
auto errorMessage = "Error while parsing debug `DOM Node` object. ";
DEBUG_WRITE_FORCE("%s Error: %s", errorMessage, errorSupportString.c_str());
Expand Down
3 changes: 2 additions & 1 deletion test-app/runtime/src/main/cpp/MetadataNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ void MetadataNode::FieldAccessorSetterCallback(Local<Name> property, Local<Value
auto fieldCallbackData = reinterpret_cast<FieldCallbackData*>(info.Data().As<External>()->Value());

if (!fieldCallbackData->isStatic && thiz->StrictEquals(info.Holder())) {
info.GetReturnValue().SetUndefined();
auto isolate = info.GetIsolate();
info.GetReturnValue().Set(v8::Undefined(isolate));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test-app/runtime/src/main/cpp/NSV8DebuggerAgentImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Response NSV8DebuggerAgentImpl::getPossibleBreakpoints(
return V8DebuggerAgentImpl::getPossibleBreakpoints(std::move(start), std::move(end), std::move(restrictToFunction), locations);
} else {
*locations = std::make_unique<protocol::Array<protocol::Debugger::BreakLocation>>();
return Response::OK();
return Response::Success();
}
}

Expand Down
28 changes: 16 additions & 12 deletions test-app/runtime/src/main/cpp/NetworkDomainCallbackHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

#include <sstream>
#include <v8_inspector/third_party/inspector_protocol/crdtp/json.h>
#include "NetworkDomainCallbackHandlers.h"
#include "NativeScriptAssert.h"

Expand Down Expand Up @@ -65,16 +66,17 @@ void NetworkDomainCallbackHandlers::ResponseReceivedCallback(const v8::FunctionC
throw NativeScriptException("`response` parameter not in the correct format.");
}

auto responseJsonString = ArgConverter::ConvertToUtf16String(responseJson);
auto responseUtf16Data = responseJsonString.data();
auto protocolResponseJson = protocol::StringUtil::parseJSON(String16((const uint16_t*) responseUtf16Data));
const String16 responseJsonString = toProtocolString(isolate, responseJson);
std::vector<uint8_t> cbor;
v8_crdtp::json::ConvertJSONToCBOR(v8_crdtp::span<uint16_t>(responseJsonString.characters16(), responseJsonString.length()), &cbor);
std::unique_ptr<protocol::Value> protocolResponseJson = protocol::Value::parseBinary(cbor.data(), cbor.size());

protocol::ErrorSupport errorSupport;
auto protocolResponseObj = protocol::Network::Response::fromValue(protocolResponseJson.get(), &errorSupport);

auto protocolResponseObj = protocol::Network::Response::fromValue(protocolResponseJson.get(),
&errorSupport);

auto errorString = errorSupport.errors().utf8();
std::vector<uint8_t> json;
v8_crdtp::json::ConvertCBORToJSON(errorSupport.Errors(), &json);
auto errorString = String16(reinterpret_cast<const char*>(json.data()), json.size()).utf8();

if (!errorString.empty()) {
auto errorMessage = "Error while parsing debug `response` object. ";
Expand Down Expand Up @@ -166,16 +168,18 @@ void NetworkDomainCallbackHandlers::RequestWillBeSentCallback(const v8::Function
throw NativeScriptException("`request` parameter not in the correct format.");
}

auto requestJsonString = ArgConverter::ConvertToUtf16String(requestJson);
auto requestUtf16Data = requestJsonString.data();
auto protocolRequestJson = protocol::StringUtil::parseJSON(String16((const uint16_t*) requestUtf16Data));
const String16& requestJsonString16 = toProtocolString(isolate, requestJson);
std::vector<uint8_t> cbor;
v8_crdtp::json::ConvertJSONToCBOR(v8_crdtp::span<uint16_t>(requestJsonString16.characters16(), requestJsonString16.length()), &cbor);
std::unique_ptr<protocol::Value> protocolRequestJson = protocol::Value::parseBinary(cbor.data(), cbor.size());

protocol::ErrorSupport errorSupport;

auto protocolRequestObj = protocol::Network::Request::fromValue(protocolRequestJson.get(), &errorSupport);
auto initiator = protocol::Network::Initiator::create().setType(protocol::Network::Initiator::TypeEnum::Script).build();

auto errorString = errorSupport.errors().utf8();
std::vector<uint8_t> json;
v8_crdtp::json::ConvertCBORToJSON(errorSupport.Errors(), &json);
auto errorString = String16(reinterpret_cast<const char*>(json.data()), json.size()).utf8();

if (!errorString.empty()) {
auto errorMessage = "Error while parsing debug `request` object. ";
Expand Down
5 changes: 2 additions & 3 deletions test-app/runtime/src/main/cpp/include/inspector/Debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace protocol {
#define v8_inspector_protocol_exported_api_h
class V8_EXPORT Exported {
public:
virtual std::unique_ptr<StringBuffer> toJSONString() const = 0;
virtual void writeBinary(std::vector<uint8_t>* out) const = 0;
virtual void AppendSerialized(std::vector<uint8_t>* out) const = 0;

virtual ~Exported() { }
};
#endif // !defined(v8_inspector_protocol_exported_api_h)
Expand Down Expand Up @@ -47,7 +47,6 @@ V8_EXPORT extern const char* XHR;

class V8_EXPORT SearchMatch : public Exported {
public:
static std::unique_ptr<protocol::Debugger::API::SearchMatch> fromJSONString(const StringView& json);
static std::unique_ptr<protocol::Debugger::API::SearchMatch> fromBinary(const uint8_t* data, size_t length);
};

Expand Down
7 changes: 2 additions & 5 deletions test-app/runtime/src/main/cpp/include/inspector/Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace protocol {
#define v8_inspector_protocol_exported_api_h
class V8_EXPORT Exported {
public:
virtual std::unique_ptr<StringBuffer> toJSONString() const = 0;
virtual void writeBinary(std::vector<uint8_t>* out) const = 0;
virtual void AppendSerialized(std::vector<uint8_t>* out) const = 0;

virtual ~Exported() { }
};
#endif // !defined(v8_inspector_protocol_exported_api_h)
Expand All @@ -31,19 +31,16 @@ namespace API {

class V8_EXPORT RemoteObject : public Exported {
public:
static std::unique_ptr<protocol::Runtime::API::RemoteObject> fromJSONString(const StringView& json);
static std::unique_ptr<protocol::Runtime::API::RemoteObject> fromBinary(const uint8_t* data, size_t length);
};

class V8_EXPORT StackTrace : public Exported {
public:
static std::unique_ptr<protocol::Runtime::API::StackTrace> fromJSONString(const StringView& json);
static std::unique_ptr<protocol::Runtime::API::StackTrace> fromBinary(const uint8_t* data, size_t length);
};

class V8_EXPORT StackTraceId : public Exported {
public:
static std::unique_ptr<protocol::Runtime::API::StackTraceId> fromJSONString(const StringView& json);
static std::unique_ptr<protocol::Runtime::API::StackTraceId> fromBinary(const uint8_t* data, size_t length);
};

Expand Down
5 changes: 2 additions & 3 deletions test-app/runtime/src/main/cpp/include/inspector/Schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace protocol {
#define v8_inspector_protocol_exported_api_h
class V8_EXPORT Exported {
public:
virtual std::unique_ptr<StringBuffer> toJSONString() const = 0;
virtual void writeBinary(std::vector<uint8_t>* out) const = 0;
virtual void AppendSerialized(std::vector<uint8_t>* out) const = 0;

virtual ~Exported() { }
};
#endif // !defined(v8_inspector_protocol_exported_api_h)
Expand All @@ -31,7 +31,6 @@ namespace API {

class V8_EXPORT Domain : public Exported {
public:
static std::unique_ptr<protocol::Schema::API::Domain> fromJSONString(const StringView& json);
static std::unique_ptr<protocol::Schema::API::Domain> fromBinary(const uint8_t* data, size_t length);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ V8_PLATFORM_EXPORT std::unique_ptr<v8::Platform> NewDefaultPlatform(
* Pumps the message loop for the given isolate.
*
* The caller has to make sure that this is called from the right thread.
* Returns true if a task was executed, and false otherwise. Unless requested
* through the |behavior| parameter, this call does not block if no task is
* pending. The |platform| has to be created using |NewDefaultPlatform|.
* Returns true if a task was executed, and false otherwise. If the call to
* PumpMessageLoop is nested within another call to PumpMessageLoop, only
* nestable tasks may run. Otherwise, any task may run. Unless requested through
* the |behavior| parameter, this call does not block if no task is pending. The
* |platform| has to be created using |NewDefaultPlatform|.
*/
V8_PLATFORM_EXPORT bool PumpMessageLoop(
v8::Platform* platform, v8::Isolate* isolate,
Expand Down
56 changes: 29 additions & 27 deletions test-app/runtime/src/main/cpp/include/v8-inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ class V8_EXPORT StringView {
class V8_EXPORT StringBuffer {
public:
virtual ~StringBuffer() = default;
virtual const StringView& string() = 0;
virtual StringView string() const = 0;
// This method copies contents.
static std::unique_ptr<StringBuffer> create(const StringView&);
static std::unique_ptr<StringBuffer> create(StringView);
};

class V8_EXPORT V8ContextInfo {
public:
V8ContextInfo(v8::Local<v8::Context> context, int contextGroupId,
const StringView& humanReadableName)
StringView humanReadableName)
: context(context),
contextGroupId(contextGroupId),
humanReadableName(humanReadableName),
Expand Down Expand Up @@ -132,35 +132,36 @@ class V8_EXPORT V8InspectorSession {
virtual void addInspectedObject(std::unique_ptr<Inspectable>) = 0;

// Dispatching protocol messages.
static bool canDispatchMethod(const StringView& method);
virtual void dispatchProtocolMessage(const StringView& message) = 0;
static bool canDispatchMethod(StringView method);
virtual void dispatchProtocolMessage(StringView message) = 0;
virtual std::vector<uint8_t> state() = 0;
virtual std::vector<std::unique_ptr<protocol::Schema::API::Domain>>
supportedDomains() = 0;

// Debugger actions.
virtual void schedulePauseOnNextStatement(const StringView& breakReason,
const StringView& breakDetails) = 0;
virtual void schedulePauseOnNextStatement(StringView breakReason,
StringView breakDetails) = 0;
virtual void cancelPauseOnNextStatement() = 0;
virtual void breakProgram(const StringView& breakReason,
const StringView& breakDetails) = 0;
virtual void breakProgram(StringView breakReason,
StringView breakDetails) = 0;
virtual void setSkipAllPauses(bool) = 0;
virtual void resume() = 0;
virtual void resume(bool setTerminateOnResume = false) = 0;
virtual void stepOver() = 0;
virtual std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>>
searchInTextByLines(const StringView& text, const StringView& query,
bool caseSensitive, bool isRegex) = 0;
searchInTextByLines(StringView text, StringView query, bool caseSensitive,
bool isRegex) = 0;

// Remote objects.
virtual std::unique_ptr<protocol::Runtime::API::RemoteObject> wrapObject(
v8::Local<v8::Context>, v8::Local<v8::Value>, const StringView& groupName,
v8::Local<v8::Context>, v8::Local<v8::Value>, StringView groupName,
bool generatePreview) = 0;

virtual bool unwrapObject(std::unique_ptr<StringBuffer>* error,
const StringView& objectId, v8::Local<v8::Value>*,
StringView objectId, v8::Local<v8::Value>*,
v8::Local<v8::Context>*,
std::unique_ptr<StringBuffer>* objectGroup) = 0;
virtual void releaseObjectGroup(const StringView&) = 0;
virtual void releaseObjectGroup(StringView) = 0;
virtual void triggerPreciseCoverageDeltaUpdate(StringView occassion) = 0;
};

class V8_EXPORT V8InspectorClient {
Expand Down Expand Up @@ -238,7 +239,7 @@ struct V8_EXPORT V8StackTraceId {
V8StackTraceId(uintptr_t id, const std::pair<int64_t, int64_t> debugger_id);
V8StackTraceId(uintptr_t id, const std::pair<int64_t, int64_t> debugger_id,
bool should_pause);
explicit V8StackTraceId(const StringView&);
explicit V8StackTraceId(StringView);
V8StackTraceId& operator=(const V8StackTraceId&) = default;
V8StackTraceId& operator=(V8StackTraceId&&) noexcept = default;
~V8StackTraceId() = default;
Expand All @@ -263,26 +264,26 @@ class V8_EXPORT V8Inspector {
virtual void idleFinished() = 0;

// Async stack traces instrumentation.
virtual void asyncTaskScheduled(const StringView& taskName, void* task,
virtual void asyncTaskScheduled(StringView taskName, void* task,
bool recurring) = 0;
virtual void asyncTaskCanceled(void* task) = 0;
virtual void asyncTaskStarted(void* task) = 0;
virtual void asyncTaskFinished(void* task) = 0;
virtual void allAsyncTasksCanceled() = 0;

virtual V8StackTraceId storeCurrentStackTrace(
const StringView& description) = 0;
virtual V8StackTraceId storeCurrentStackTrace(StringView description) = 0;
virtual void externalAsyncTaskStarted(const V8StackTraceId& parent) = 0;
virtual void externalAsyncTaskFinished(const V8StackTraceId& parent) = 0;

// Exceptions instrumentation.
virtual unsigned exceptionThrown(
v8::Local<v8::Context>, const StringView& message,
v8::Local<v8::Value> exception, const StringView& detailedMessage,
const StringView& url, unsigned lineNumber, unsigned columnNumber,
std::unique_ptr<V8StackTrace>, int scriptId) = 0;
virtual unsigned exceptionThrown(v8::Local<v8::Context>, StringView message,
v8::Local<v8::Value> exception,
StringView detailedMessage, StringView url,
unsigned lineNumber, unsigned columnNumber,
std::unique_ptr<V8StackTrace>,
int scriptId) = 0;
virtual void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId,
const StringView& message) = 0;
StringView message) = 0;

// Connection.
class V8_EXPORT Channel {
Expand All @@ -293,8 +294,9 @@ class V8_EXPORT V8Inspector {
virtual void sendNotification(std::unique_ptr<StringBuffer> message) = 0;
virtual void flushProtocolNotifications() = 0;
};
virtual std::unique_ptr<V8InspectorSession> connect(
int contextGroupId, Channel*, const StringView& state) = 0;
virtual std::unique_ptr<V8InspectorSession> connect(int contextGroupId,
Channel*,
StringView state) = 0;

// API methods.
virtual std::unique_ptr<V8StackTrace> createStackTrace(
Expand Down
Loading