Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(945)

Unified Diff: chrome/test/chromedriver/chrome/frame_tracker.cc

Issue 2215153002: [DevTools] Eliminate frameId and isContentScript from js protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: navigation tracker Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/chromedriver/chrome/frame_tracker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/chrome/frame_tracker.cc
diff --git a/chrome/test/chromedriver/chrome/frame_tracker.cc b/chrome/test/chromedriver/chrome/frame_tracker.cc
index a899d1c534e644018eb9c95bb1f8efe61354a9b7..4bcdfb7a8a95f410c0f0dd246cf5af2b5892a550 100644
--- a/chrome/test/chromedriver/chrome/frame_tracker.cc
+++ b/chrome/test/chromedriver/chrome/frame_tracker.cc
@@ -49,30 +49,48 @@ Status FrameTracker::OnEvent(DevToolsClient* client,
int context_id;
std::string frame_id;
- if (!context->GetInteger("id", &context_id) ||
- !context->GetString("frameId", &frame_id)) {
+ bool is_default = true;
+
+ if (!context->GetInteger("id", &context_id)) {
std::string json;
base::JSONWriter::Write(*context, &json);
return Status(kUnknownError, method + " has invalid 'context': " + json);
}
+ if (context->HasKey("auxData")) {
+ const base::DictionaryValue* auxData;
+ if (!context->GetDictionary("auxData", &auxData))
+ return Status(kUnknownError, method + " has invalid 'auxData' value");
+ if (!auxData->GetBoolean("isDefault", &is_default))
+ return Status(kUnknownError, method + " has invalid 'isDefault' value");
+ if (!auxData->GetString("frameId", &frame_id))
+ return Status(kUnknownError, method + " has invalid 'frameId' value");
+ }
+
if (context->HasKey("isDefault")) {
- bool is_default = false;
+ // TODO(samuong): remove this when we stop supporting Chrome 53.
if (!context->GetBoolean("isDefault", &is_default))
return Status(kUnknownError, method + " has invalid 'isDefault' value");
- if (is_default)
- frame_to_context_map_[frame_id] = context_id;
- } else {
+ }
+
+ if (context->HasKey("frameId")) {
+ // TODO(samuong): remove this when we stop supporting Chrome 53.
+ if (!context->GetString("frameId", &frame_id))
+ return Status(kUnknownError, method + " has invalid 'frameId' value");
+ }
+
+ if (context->HasKey("type")) {
// Before crrev.com/381172, the optional |type| field can be used to
// determine whether we're looking at the default context.
// TODO(samuong): remove this when we stop supporting Chrome 50.
std::string type;
- if (context->HasKey("type") && !context->GetString("type", &type))
+ if (!context->GetString("type", &type))
return Status(kUnknownError, method + " has invalid 'context.type'");
- if (type != "Extension") // exclude content scripts
- frame_to_context_map_[frame_id] = context_id;
+ is_default = type != "Extension"; // exclude content scripts
}
+ if (is_default && !frame_id.empty())
+ frame_to_context_map_[frame_id] = context_id;
} else if (method == "Runtime.executionContextDestroyed") {
int execution_context_id;
if (!params.GetInteger("executionContextId", &execution_context_id))
« no previous file with comments | « no previous file | chrome/test/chromedriver/chrome/frame_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698