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

Unified Diff: content/browser/devtools/site_per_process_devtools_browsertest.cc

Issue 976313003: [DevTools] Expose DevToolsAgentHost for OOPIF, display it in chrome://inspect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disabled test on android Created 5 years, 9 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 | « content/browser/devtools/render_frame_devtools_agent_host.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/devtools/site_per_process_devtools_browsertest.cc
diff --git a/content/browser/devtools/site_per_process_devtools_browsertest.cc b/content/browser/devtools/site_per_process_devtools_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..aaa935f744fca39d2a34d0bfe159eefedf3148dd
--- /dev/null
+++ b/content/browser/devtools/site_per_process_devtools_browsertest.cc
@@ -0,0 +1,113 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
Charlie Reis 2015/03/09 23:02:38 nit: 2015
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
Charlie Reis 2015/03/09 23:02:38 nit: Remove one of the two blank lines.
+
+#include "content/browser/frame_host/frame_tree.h"
+#include "content/browser/site_per_process_browsertest.h"
+#include "content/browser/web_contents/web_contents_impl.h"
+#include "content/public/browser/devtools_agent_host.h"
+#include "content/public/test/content_browser_test_utils.h"
+#include "content/public/test/test_utils.h"
+#include "content/shell/browser/shell.h"
+#include "content/test/content_browser_test_utils_internal.h"
+#include "net/dns/mock_host_resolver.h"
+
+namespace content {
+
+class SitePerProcessDevToolsBrowserTest
+ : public SitePerProcessBrowserTest {
+ public:
+ SitePerProcessDevToolsBrowserTest() {}
+};
+
+class TestClient: public DevToolsAgentHostClient {
+ public:
+ TestClient() : closed_(false) {}
+ ~TestClient() override {}
+
+ bool closed() { return closed_; }
+
+ void DispatchProtocolMessage(
+ DevToolsAgentHost* agent_host,
+ const std::string& message) override {
+ }
+
+ void AgentHostClosed(
+ DevToolsAgentHost* agent_host,
+ bool replaced_with_another_client) override {
+ closed_ = true;
+ }
+
+ private:
+ bool closed_;
+};
+
+// Fails on Android, http://crbug.com/464993.
+#if defined(OS_ANDROID)
+#define MAYBE_CrossSiteIframeAgentHost DISABLED_CrossSiteIframeAgentHost
+#else
+#define MAYBE_CrossSiteIframeAgentHost CrossSiteIframeAgentHost
+#endif
+IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsBrowserTest,
+ MAYBE_CrossSiteIframeAgentHost) {
+ DevToolsAgentHost::List list;
+ host_resolver()->AddRule("*", "127.0.0.1");
+ ASSERT_TRUE(test_server()->Start());
+ GURL main_url(test_server()->GetURL("files/site_per_process_main.html"));
+ NavigateToURL(shell(), main_url);
+
+ // It is safe to obtain the root frame tree node here, as it doesn't change.
+ FrameTreeNode* root =
+ static_cast<WebContentsImpl*>(shell()->web_contents())->
+ GetFrameTree()->root();
+
+ list = DevToolsAgentHost::GetOrCreateAll();
+ EXPECT_EQ(1U, list.size());
+ EXPECT_EQ(DevToolsAgentHost::TYPE_WEB_CONTENTS, list[0]->GetType());
+ EXPECT_EQ(main_url.spec(), list[0]->GetURL().spec());
+
+ // Load same-site page into iframe.
+ FrameTreeNode* child = root->child_at(0);
+ GURL http_url(test_server()->GetURL("files/title1.html"));
+ NavigateFrameToURL(child, http_url);
+
+ list = DevToolsAgentHost::GetOrCreateAll();
+ EXPECT_EQ(1U, list.size());
+ EXPECT_EQ(DevToolsAgentHost::TYPE_WEB_CONTENTS, list[0]->GetType());
+ EXPECT_EQ(main_url.spec(), list[0]->GetURL().spec());
+
+ // Load cross-site page into iframe.
+ GURL::Replacements replace_host;
+ GURL cross_site_url(test_server()->GetURL("files/title2.html"));
+ replace_host.SetHostStr("foo.com");
+ cross_site_url = cross_site_url.ReplaceComponents(replace_host);
+ NavigateFrameToURL(root->child_at(0), cross_site_url);
+
+ list = DevToolsAgentHost::GetOrCreateAll();
+ EXPECT_EQ(2U, list.size());
+ EXPECT_EQ(DevToolsAgentHost::TYPE_WEB_CONTENTS, list[0]->GetType());
+ EXPECT_EQ(main_url.spec(), list[0]->GetURL().spec());
+ EXPECT_EQ(DevToolsAgentHost::TYPE_FRAME, list[1]->GetType());
+ EXPECT_EQ(cross_site_url.spec(), list[1]->GetURL().spec());
+
+ // Attaching to child frame.
+ scoped_refptr<DevToolsAgentHost> child_host = list[1];
+ TestClient client;
+ child_host->AttachClient(&client);
+
+ // Load back same-site page into iframe.
+ NavigateFrameToURL(root->child_at(0), http_url);
+
+ list = DevToolsAgentHost::GetOrCreateAll();
+ EXPECT_EQ(1U, list.size());
+ EXPECT_EQ(DevToolsAgentHost::TYPE_WEB_CONTENTS, list[0]->GetType());
+ EXPECT_EQ(main_url.spec(), list[0]->GetURL().spec());
+ // TODO(dgozman): we should get closed notification here.
+ // See http://crbug.com/464993.
+ EXPECT_FALSE(client.closed());
+ child_host->DetachClient();
+ child_host = nullptr;
+}
+
+} // namespace content
« no previous file with comments | « content/browser/devtools/render_frame_devtools_agent_host.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698