File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 19
19
#include " webdriver_session_manager.h"
20
20
#include " webdriver_util.h"
21
21
#include " webdriver_view_executor.h"
22
+ #include " webdriver_view_enumerator.h"
22
23
23
24
namespace webdriver {
24
25
@@ -52,6 +53,23 @@ bool WebDriverCommand::Init(Response* const response) {
52
53
message += " with params " + JsonStringifyForDisplay (parameters_.GetRawPointer ());
53
54
session_->logger ().Log (kFineLogLevel , message);
54
55
56
+ // terminate session if no views found
57
+ std::vector<ViewId> views;
58
+
59
+ session_->RunSessionTask (base::Bind (
60
+ &ViewEnumerator::EnumerateViews,
61
+ session_,
62
+ &views));
63
+
64
+ if (views.empty ()) {
65
+ // Session manages its own lifetime, so do not call delete.
66
+ session_->Terminate ();
67
+
68
+ response->SetError (
69
+ new Error (kSessionNotFound , " Session not found: " + session_id_));
70
+ return false ;
71
+ }
72
+
55
73
if (ShouldRunPreAndPostCommandHandlers ()) {
56
74
Error* error = session_->BeforeExecuteCommand ();
57
75
if (error) {
You can’t perform that action at this time.
0 commit comments