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

Unified Diff: content/browser/devtools/protocol/devtools_protocol_browsertest.cc

Issue 2408133004: [DevTools] Implement Target.setDiscoverTargets method. (Closed)
Patch Set: force creation Created 4 years, 2 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
Index: content/browser/devtools/protocol/devtools_protocol_browsertest.cc
diff --git a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
index d5836605f59988e429e03563d88f2b6729c02b67..427ac2be93216e78fb5fc2e7f82c86f52edf0f35 100644
--- a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
+++ b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
@@ -1244,6 +1244,88 @@ IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, ShowCertificateViewer) {
EXPECT_EQ(transient_entry->GetSSL().certificate, last_shown_certificate());
}
+IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) {
+ std::string temp;
+ std::set<std::string> ids;
+ std::unique_ptr<base::DictionaryValue> command_params;
+ std::unique_ptr<base::DictionaryValue> params;
+
+ ASSERT_TRUE(embedded_test_server()->Start());
+ GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html");
+ NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1);
+
+ GURL second_url = embedded_test_server()->GetURL("/devtools/navigation.html");
+ Shell* second = CreateBrowser();
+ NavigateToURLBlockUntilNavigationsComplete(second, second_url, 1);
+
+ Attach();
+ command_params.reset(new base::DictionaryValue());
+ command_params->SetBoolean("discover", true);
+ SendCommand("Target.setDiscoverTargets", std::move(command_params), true);
+ params = WaitForNotification("Target.targetCreated", true);
+ EXPECT_TRUE(params->GetString("targetInfo.type", &temp));
+ EXPECT_EQ("page", temp);
+ EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp));
+ EXPECT_TRUE(ids.find(temp) == ids.end());
+ ids.insert(temp);
+ params = WaitForNotification("Target.targetCreated", true);
+ EXPECT_TRUE(params->GetString("targetInfo.type", &temp));
+ EXPECT_EQ("page", temp);
+ EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp));
+ EXPECT_TRUE(ids.find(temp) == ids.end());
+ ids.insert(temp);
+ EXPECT_TRUE(notifications_.empty());
+
+ GURL third_url = embedded_test_server()->GetURL("/devtools/navigation.html");
+ Shell* third = CreateBrowser();
+ NavigateToURLBlockUntilNavigationsComplete(third, third_url, 1);
+ params = WaitForNotification("Target.targetCreated", true);
+ EXPECT_TRUE(params->GetString("targetInfo.type", &temp));
+ EXPECT_EQ("page", temp);
+ EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp));
+ EXPECT_TRUE(ids.find(temp) == ids.end());
+ std::string attached_id = temp;
+ ids.insert(temp);
+ EXPECT_TRUE(notifications_.empty());
+
+ second->Close();
+ second = nullptr;
+ params = WaitForNotification("Target.targetDestroyed", true);
+ EXPECT_TRUE(params->GetString("targetId", &temp));
+ EXPECT_TRUE(ids.find(temp) != ids.end());
+ ids.erase(temp);
+ EXPECT_TRUE(notifications_.empty());
+
+ command_params.reset(new base::DictionaryValue());
+ command_params->SetString("targetId", attached_id);
+ SendCommand("Target.attachToTarget", std::move(command_params), true);
+ params = WaitForNotification("Target.attachedToTarget", true);
+ EXPECT_TRUE(params->GetString("targetId", &temp));
+ EXPECT_EQ(attached_id, temp);
+ EXPECT_TRUE(notifications_.empty());
+
+ command_params.reset(new base::DictionaryValue());
+ command_params->SetBoolean("discover", false);
+ SendCommand("Target.setDiscoverTargets", std::move(command_params), true);
+ params = WaitForNotification("Target.targetDestroyed", true);
+ EXPECT_TRUE(params->GetString("targetId", &temp));
+ EXPECT_NE(attached_id, temp);
+ ids.erase(temp);
+ EXPECT_TRUE(notifications_.empty());
+
+ command_params.reset(new base::DictionaryValue());
+ command_params->SetString("targetId", attached_id);
+ SendCommand("Target.detachFromTarget", std::move(command_params), true);
+ params = WaitForNotification("Target.detachedFromTarget", true);
+ EXPECT_TRUE(params->GetString("targetId", &temp));
+ EXPECT_EQ(attached_id, temp);
+ params = WaitForNotification("Target.targetDestroyed", true);
+ EXPECT_TRUE(params->GetString("targetId", &temp));
+ EXPECT_EQ(attached_id, temp);
+ ids.erase(temp);
+ EXPECT_TRUE(notifications_.empty());
+}
+
class SitePerProcessDevToolsProtocolTest : public DevToolsProtocolTest {
public:
void SetUpCommandLine(base::CommandLine* command_line) override {
@@ -1304,7 +1386,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsProtocolTest, TargetNoDiscovery) {
params = WaitForNotification("Target.detachedFromTarget", true);
EXPECT_TRUE(params->GetString("targetId", &temp));
EXPECT_EQ(target_id, temp);
- params = WaitForNotification("Target.targetRemoved", true);
+ params = WaitForNotification("Target.targetDestroyed", true);
EXPECT_TRUE(params->GetString("targetId", &temp));
EXPECT_EQ(target_id, temp);
@@ -1326,7 +1408,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsProtocolTest, TargetNoDiscovery) {
params = WaitForNotification("Target.detachedFromTarget", true);
EXPECT_TRUE(params->GetString("targetId", &temp));
EXPECT_EQ(target_id, temp);
- params = WaitForNotification("Target.targetRemoved", true);
+ params = WaitForNotification("Target.targetDestroyed", true);
EXPECT_TRUE(params->GetString("targetId", &temp));
EXPECT_EQ(target_id, temp);
}

Powered by Google App Engine
This is Rietveld 408576698