Commit 4e40f77f authored by John Chen's avatar John Chen Committed by Commit Bot

[ChromeDriver] Fix crash when target isn't tracked

While handling Target.detachedFromTarget events, check that the
target_id exists in frame_to_target_map_ before using the target.

Change-Id: I84d41913bdc2df02338f725eef2b0a513c0c5d4d
Reviewed-on: https://chromium-review.googlesource.com/1013613
Commit-Queue: John Chen <johnchen@chromium.org>
Reviewed-by: default avatarJonathon Kereliuk <kereliuk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551065}
parent 16c5c869
......@@ -178,8 +178,12 @@ Status FrameTracker::OnEvent(DevToolsClient* client,
// Some types of Target.detachedFromTarget events do not have targetId.
// We are not interested in those types of targets.
return Status(kOk);
WebViewImpl* target =
static_cast<WebViewImpl*>(frame_to_target_map_[target_id].get());
auto target_iter = frame_to_target_map_.find(target_id);
if (target_iter == frame_to_target_map_.end())
// There are some target types that we're not keeping track of, thus not
// finding the target in frame_to_target_map_ is OK.
return Status(kOk);
WebViewImpl* target = static_cast<WebViewImpl*>(target_iter->second.get());
if (target->IsLocked())
target->SetDetached();
else
......
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