@@ -50,14 +50,6 @@ void V8DOMAgentImpl::disable(ErrorString*) {
50
50
}
51
51
52
52
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
-
61
53
std::string getDocumentFunctionString = " getDocument" ;
62
54
// TODO: Pete: Find a better way to get a hold of the isolate
63
55
auto isolate = v8::Isolate::GetCurrent ();
@@ -79,7 +71,6 @@ void V8DOMAgentImpl::getDocument(ErrorString* errorString, std::unique_ptr<proto
79
71
if (tc.HasCaught ()) {
80
72
*errorString = utils::Common::getJSCallErrorMessage (getDocumentFunctionString, tc.Message ()->Get ()).c_str ();
81
73
82
- *out_root = std::move (defaultNode);
83
74
return ;
84
75
}
85
76
@@ -100,18 +91,27 @@ void V8DOMAgentImpl::getDocument(ErrorString* errorString, std::unique_ptr<proto
100
91
if (!errorSupportString.empty ()) {
101
92
auto errorMessage = " Error while parsing debug `DOM Node` object. " ;
102
93
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 ;
103
101
} else {
104
102
*out_root = std::move (domNode);
105
103
106
104
return ;
107
105
}
108
106
} else {
109
107
*errorString = " Didn't get a proper result from __getDocument call. Returning empty visual tree." ;
108
+
109
+ return ;
110
110
}
111
111
}
112
112
}
113
113
114
- *out_root = std::move (defaultNode) ;
114
+ *errorString = " getDocument function not available on the global object. " ;
115
115
}
116
116
117
117
void V8DOMAgentImpl::removeNode (ErrorString* errorString, int in_nodeId) {
0 commit comments