Commit 6131eb90 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Remove //content/browser dependency in //chrome/browser/ui/webui

crrev.com/c/2259537 made ChromeWebUINavigationBrowserTest use
RenderFrameHostImpl directly for testing instead of using the
existing content::PwnMessageHelper::OpenURL(). But, it's a layer
violation. So this CL restores OpenURL() in content::PwnMessageHelper
in browser_test_utils.h again, then makes it use
content::PwnMessageHelper::OpenURL() to fix the layer violation.

Additionally, all test methods of PwnMessageHelper start to use
Mojo methods instead of IPC method. So, this CL updates the comments
properly.

Bug: 1093920
Change-Id: I8608cb7bc5a3e84628c741020ed2515d28445e2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2387541Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#804591}
parent 98dcb88c
...@@ -10,11 +10,4 @@ include_rules = [ ...@@ -10,11 +10,4 @@ include_rules = [
"+third_party/angle", # For ANGLE version. "+third_party/angle", # For ANGLE version.
"+third_party/brotli", # For compressed resources. "+third_party/brotli", # For compressed resources.
"+third_party/zlib/zlib.h", # For compression level constants. "+third_party/zlib/zlib.h", # For compression level constants.
] ]
\ No newline at end of file
specific_include_rules = {
"chrome_webui_navigation_browsertest.cc": [
"+content/browser/frame_host/render_frame_host_impl.h",
"+content/common/frame.mojom.h",
],
}
\ No newline at end of file
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/common/frame.mojom.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "content/public/test/browser_test.h" #include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
...@@ -20,19 +18,6 @@ ...@@ -20,19 +18,6 @@
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/url_constants.h" #include "url/url_constants.h"
namespace {
content::mojom::OpenURLParamsPtr CreateOpenURLParams(const GURL& url) {
auto params = content::mojom::OpenURLParams::New();
params->url = url;
params->disposition = WindowOpenDisposition::CURRENT_TAB;
params->should_replace_current_entry = false;
params->user_gesture = true;
return params;
}
} // namespace
// Tests embedder specific behavior of WebUIs. // Tests embedder specific behavior of WebUIs.
class ChromeWebUINavigationBrowserTest : public InProcessBrowserTest { class ChromeWebUINavigationBrowserTest : public InProcessBrowserTest {
public: public:
...@@ -76,9 +61,8 @@ IN_PROC_BROWSER_TEST_F(ChromeWebUINavigationBrowserTest, ...@@ -76,9 +61,8 @@ IN_PROC_BROWSER_TEST_F(ChromeWebUINavigationBrowserTest,
EXPECT_EQ("about:blank", child->GetLastCommittedURL()); EXPECT_EQ("about:blank", child->GetLastCommittedURL());
content::TestNavigationObserver observer(web_contents); content::TestNavigationObserver observer(web_contents);
static_cast<content::RenderFrameHostImpl*>(child)->OpenURL( content::PwnMessageHelper::OpenURL(
CreateOpenURLParams( child, content::GetWebUIURL("web-ui/title1.html?noxfo=true"));
content::GetWebUIURL("web-ui/title1.html?noxfo=true")));
observer.Wait(); observer.Wait();
// Retrieve the RenderFrameHost again since it might have been swapped. // Retrieve the RenderFrameHost again since it might have been swapped.
...@@ -115,9 +99,8 @@ IN_PROC_BROWSER_TEST_F( ...@@ -115,9 +99,8 @@ IN_PROC_BROWSER_TEST_F(
content::AddUntrustedDataSource(browser()->profile(), "test-iframe-host", content::AddUntrustedDataSource(browser()->profile(), "test-iframe-host",
csp); csp);
static_cast<content::RenderFrameHostImpl*>(child)->OpenURL( content::PwnMessageHelper::OpenURL(
CreateOpenURLParams( child, content::GetChromeUntrustedUIURL("test-iframe-host/title1.html"));
content::GetChromeUntrustedUIURL("test-iframe-host/title1.html")));
observer.Wait(); observer.Wait();
// Retrieve the RenderFrameHost again since it might have been swapped. // Retrieve the RenderFrameHost again since it might have been swapped.
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "content/browser/storage_partition_impl.h" #include "content/browser/storage_partition_impl.h"
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/web_contents/web_contents_view.h" #include "content/browser/web_contents/web_contents_view.h"
#include "content/common/frame.mojom.h"
#include "content/common/frame_messages.h" #include "content/common/frame_messages.h"
#include "content/common/input_messages.h" #include "content/common/input_messages.h"
#include "content/common/widget_messages.h" #include "content/common/widget_messages.h"
...@@ -3150,6 +3151,17 @@ void PwnMessageHelper::FileSystemWrite(RenderProcessHost* process, ...@@ -3150,6 +3151,17 @@ void PwnMessageHelper::FileSystemWrite(RenderProcessHost* process,
waiter.WaitForOperationToFinish(); waiter.WaitForOperationToFinish();
} }
void PwnMessageHelper::OpenURL(RenderFrameHost* render_frame_host,
const GURL& url) {
auto params = content::mojom::OpenURLParams::New();
params->url = url;
params->disposition = WindowOpenDisposition::CURRENT_TAB;
params->should_replace_current_entry = false;
params->user_gesture = true;
static_cast<content::RenderFrameHostImpl*>(render_frame_host)
->OpenURL(std::move(params));
}
#if defined(USE_AURA) #if defined(USE_AURA)
namespace { namespace {
......
...@@ -1644,11 +1644,11 @@ class WebContentsConsoleObserver : public WebContentsObserver { ...@@ -1644,11 +1644,11 @@ class WebContentsConsoleObserver : public WebContentsObserver {
std::vector<Message> messages_; std::vector<Message> messages_;
}; };
// Static methods that inject particular IPCs into the message pipe as if they // Static methods that simulates Mojo methods as if they were called by a
// came from |process|. Used to simulate a compromised renderer. // renderer. Used to simulate a compromised renderer.
class PwnMessageHelper { class PwnMessageHelper {
public: public:
// Sends FileSystemHostMsg_Create // Calls Create method in FileSystemHost Mojo interface.
static void FileSystemCreate(RenderProcessHost* process, static void FileSystemCreate(RenderProcessHost* process,
int request_id, int request_id,
GURL path, GURL path,
...@@ -1656,13 +1656,16 @@ class PwnMessageHelper { ...@@ -1656,13 +1656,16 @@ class PwnMessageHelper {
bool is_directory, bool is_directory,
bool recursive); bool recursive);
// Sends FileSystemHostMsg_Write // Calls Write method in FileSystemHost Mojo interface.
static void FileSystemWrite(RenderProcessHost* process, static void FileSystemWrite(RenderProcessHost* process,
int request_id, int request_id,
GURL file_path, GURL file_path,
std::string blob_uuid, std::string blob_uuid,
int64_t position); int64_t position);
// Calls OpenURL method in FrameHost Mojo interface.
static void OpenURL(RenderFrameHost* render_frame_host, const GURL& url);
private: private:
PwnMessageHelper(); // Not instantiable. PwnMessageHelper(); // Not instantiable.
......
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