Commit 6dd34460 authored by Shengfa Lin's avatar Shengfa Lin Committed by Commit Bot

[ChromeDriver] Remove TODOs in frame_tracker

Remove isDefault and frameId for Chrome 53 and type for Chrome 50 parsing
support

Change-Id: Ia9c630eede1c0af305477b6017d9af7fd72c5641
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2138231Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Shengfa Lin <shengfa@google.com>
Cr-Commit-Position: refs/heads/master@{#757150}
parent 84326ff8
...@@ -121,28 +121,6 @@ Status FrameTracker::OnEvent(DevToolsClient* client, ...@@ -121,28 +121,6 @@ Status FrameTracker::OnEvent(DevToolsClient* client,
return Status(kUnknownError, method + " has invalid 'frameId' value"); return Status(kUnknownError, method + " has invalid 'frameId' value");
} }
if (context->HasKey("isDefault")) {
// 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 (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->GetString("type", &type))
return Status(kUnknownError, method + " has invalid 'context.type'");
is_default = type != "Extension"; // exclude content scripts
}
if (is_default && !frame_id.empty()) if (is_default && !frame_id.empty())
frame_to_context_map_[frame_id] = context_id; frame_to_context_map_[frame_id] = context_id;
} else if (method == "Runtime.executionContextDestroyed") { } else if (method == "Runtime.executionContextDestroyed") {
......
...@@ -18,7 +18,8 @@ TEST(FrameTracker, GetContextIdForFrame) { ...@@ -18,7 +18,8 @@ TEST(FrameTracker, GetContextIdForFrame) {
ASSERT_TRUE(tracker.GetContextIdForFrame("f", &context_id).IsError()); ASSERT_TRUE(tracker.GetContextIdForFrame("f", &context_id).IsError());
ASSERT_EQ(-1, context_id); ASSERT_EQ(-1, context_id);
const char context[] = "{\"id\":100,\"frameId\":\"f\"}"; const char context[] =
"{\"id\":100,\"auxData\":{\"frameId\":\"f\",\"isDefault\":true}}";
base::DictionaryValue params; base::DictionaryValue params;
params.Set("context", base::JSONReader::ReadDeprecated(context)); params.Set("context", base::JSONReader::ReadDeprecated(context));
ASSERT_EQ(kOk, ASSERT_EQ(kOk,
...@@ -68,7 +69,8 @@ TEST(FrameTracker, CanUpdateFrameContextId) { ...@@ -68,7 +69,8 @@ TEST(FrameTracker, CanUpdateFrameContextId) {
StubDevToolsClient client; StubDevToolsClient client;
FrameTracker tracker(&client); FrameTracker tracker(&client);
const char context[] = "{\"id\":1,\"frameId\":\"f\"}"; const char context[] =
"{\"id\":1,\"auxData\":{\"frameId\":\"f\",\"isDefault\":true}}";
base::DictionaryValue params; base::DictionaryValue params;
params.Set("context", base::JSONReader::ReadDeprecated(context)); params.Set("context", base::JSONReader::ReadDeprecated(context));
ASSERT_EQ(kOk, ASSERT_EQ(kOk,
...@@ -90,7 +92,8 @@ TEST(FrameTracker, DontTrackContentScriptContexts) { ...@@ -90,7 +92,8 @@ TEST(FrameTracker, DontTrackContentScriptContexts) {
StubDevToolsClient client; StubDevToolsClient client;
FrameTracker tracker(&client); FrameTracker tracker(&client);
const char context[] = "{\"id\":1,\"frameId\":\"f\"}"; const char context[] =
"{\"id\":1,\"auxData\":{\"frameId\":\"f\",\"isDefault\":true}}";
base::DictionaryValue params; base::DictionaryValue params;
params.Set("context", base::JSONReader::ReadDeprecated(context)); params.Set("context", base::JSONReader::ReadDeprecated(context));
ASSERT_EQ(kOk, ASSERT_EQ(kOk,
...@@ -101,7 +104,7 @@ TEST(FrameTracker, DontTrackContentScriptContexts) { ...@@ -101,7 +104,7 @@ TEST(FrameTracker, DontTrackContentScriptContexts) {
ASSERT_EQ(1, context_id); ASSERT_EQ(1, context_id);
params.SetInteger("context.id", 2); params.SetInteger("context.id", 2);
params.SetString("context.type", "Extension"); params.SetBoolean("context.auxData.isDefault", false);
ASSERT_EQ(kOk, ASSERT_EQ(kOk,
tracker.OnEvent(&client, "Runtime.executionContextCreated", params) tracker.OnEvent(&client, "Runtime.executionContextCreated", params)
.code()); .code());
......
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