Skip to content

Commit c5c0cc2

Browse files
authored
Merge pull request #969 from NativeScript/pete/fix-devtools-elements-tab
fix(devtools): if Elements tab is empty, try to repopulate on consecutive opening
2 parents f88bfe0 + 583b9e6 commit c5c0cc2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

test-app/runtime/src/main/cpp/v8_inspector/src/inspector/v8-dom-agent-impl.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ void V8DOMAgentImpl::disable(ErrorString*) {
5050
}
5151

5252
void V8DOMAgentImpl::getDocument(ErrorString* errorString, std::unique_ptr<protocol::DOM::Node>* out_root) {
53-
std::unique_ptr<protocol::DOM::Node> defaultNode = protocol::DOM::Node::create()
54-
.setNodeId(0)
55-
.setNodeType(9)
56-
.setNodeName("Frame")
57-
.setLocalName("Frame")
58-
.setNodeValue("")
59-
.build();
60-
6153
std::string getDocumentFunctionString = "getDocument";
6254
// TODO: Pete: Find a better way to get a hold of the isolate
6355
auto isolate = v8::Isolate::GetCurrent();
@@ -79,7 +71,6 @@ void V8DOMAgentImpl::getDocument(ErrorString* errorString, std::unique_ptr<proto
7971
if (tc.HasCaught()) {
8072
*errorString = utils::Common::getJSCallErrorMessage(getDocumentFunctionString, tc.Message()->Get()).c_str();
8173

82-
*out_root = std::move(defaultNode);
8374
return;
8475
}
8576

@@ -100,18 +91,27 @@ void V8DOMAgentImpl::getDocument(ErrorString* errorString, std::unique_ptr<proto
10091
if (!errorSupportString.empty()) {
10192
auto errorMessage = "Error while parsing debug `DOM Node` object. ";
10293
DEBUG_WRITE_FORCE("JS Error: %s", errorMessage, errorSupportString.c_str());
94+
*errorString = errorSupportString.c_str();
95+
96+
return;
97+
} else if (domNode->getChildren(protocol::Array<protocol::DOM::Node>::create().get())->length() == 0) {
98+
*errorString = "Root view empty.";
99+
100+
return;
103101
} else {
104102
*out_root = std::move(domNode);
105103

106104
return;
107105
}
108106
} else {
109107
*errorString = "Didn't get a proper result from __getDocument call. Returning empty visual tree.";
108+
109+
return;
110110
}
111111
}
112112
}
113113

114-
*out_root = std::move(defaultNode);
114+
*errorString = "getDocument function not available on the global object.";
115115
}
116116

117117
void V8DOMAgentImpl::removeNode(ErrorString* errorString, int in_nodeId) {

0 commit comments

Comments
 (0)