Commit 215aa30b authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

Improve test readability by extracting a small helper function

R=petermarshall@chromium.org

Bug: chromium:1063007
Change-Id: I85fcebe7a0934ee27270756ae02c6a06340bfad0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2317227
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Auto-Submit: Simon Zünd <szuend@chromium.org>
Reviewed-by: default avatarPeter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791346}
parent 154c311c
...@@ -30,6 +30,13 @@ class DevToolsIssueStorageBrowserTest : public DevToolsProtocolTest { ...@@ -30,6 +30,13 @@ class DevToolsIssueStorageBrowserTest : public DevToolsProtocolTest {
host_resolver()->AddRule("*", "127.0.0.1"); host_resolver()->AddRule("*", "127.0.0.1");
SetupCrossSiteRedirector(embedded_test_server()); SetupCrossSiteRedirector(embedded_test_server());
} }
protected:
RenderFrameHostImpl* main_frame_host() {
WebContentsImpl* web_contents_impl =
static_cast<WebContentsImpl*>(shell()->web_contents());
return web_contents_impl->GetFrameTree()->GetMainFrame();
}
}; };
namespace { namespace {
...@@ -54,10 +61,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest, ...@@ -54,10 +61,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest,
EXPECT_TRUE(NavigateToURL(shell(), GURL("about:blank"))); EXPECT_TRUE(NavigateToURL(shell(), GURL("about:blank")));
// 2) Report an empty SameSite cookie issue. // 2) Report an empty SameSite cookie issue.
WebContentsImpl* web_contents_impl = ReportDummyIssue(main_frame_host());
static_cast<WebContentsImpl*>(shell()->web_contents());
RenderFrameHostImpl* root = web_contents_impl->GetFrameTree()->GetMainFrame();
ReportDummyIssue(root);
// 3) Open DevTools. // 3) Open DevTools.
Attach(); Attach();
...@@ -85,10 +89,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest, ...@@ -85,10 +89,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest,
ASSERT_TRUE(notifications_.empty()); ASSERT_TRUE(notifications_.empty());
// 4) Report an empty SameSite cookie issue. // 4) Report an empty SameSite cookie issue.
WebContentsImpl* web_contents_impl = ReportDummyIssue(main_frame_host());
static_cast<WebContentsImpl*>(shell()->web_contents());
RenderFrameHostImpl* root = web_contents_impl->GetFrameTree()->GetMainFrame();
ReportDummyIssue(root);
// 5) Verify we have received the SameSite issue. // 5) Verify we have received the SameSite issue.
WaitForNotification("Audits.issueAdded", true); WaitForNotification("Audits.issueAdded", true);
...@@ -103,11 +104,9 @@ IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest, ...@@ -103,11 +104,9 @@ IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest,
EXPECT_TRUE(NavigateToURL(shell(), test_url)); EXPECT_TRUE(NavigateToURL(shell(), test_url));
// 2) Report an empty SameSite cookie issue in the iframe. // 2) Report an empty SameSite cookie issue in the iframe.
WebContentsImpl* web_contents_impl = RenderFrameHostImpl* main_frame = main_frame_host();
static_cast<WebContentsImpl*>(shell()->web_contents()); EXPECT_EQ(main_frame->child_count(), static_cast<unsigned>(1));
RenderFrameHostImpl* root = web_contents_impl->GetFrameTree()->GetMainFrame(); RenderFrameHostImpl* iframe = main_frame->child_at(0)->current_frame_host();
EXPECT_EQ(root->child_count(), static_cast<unsigned>(1));
RenderFrameHostImpl* iframe = root->child_at(0)->current_frame_host();
EXPECT_FALSE(iframe->is_main_frame()); EXPECT_FALSE(iframe->is_main_frame());
ReportDummyIssue(iframe); ReportDummyIssue(iframe);
...@@ -115,7 +114,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest, ...@@ -115,7 +114,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest,
// 3) Delete the iframe from the page. This should cause the issue to be // 3) Delete the iframe from the page. This should cause the issue to be
// re-assigned // re-assigned
// to the root frame. // to the root frame.
root->RemoveChild(iframe->frame_tree_node()); main_frame->RemoveChild(iframe->frame_tree_node());
// 4) Open DevTools and enable Audits domain. // 4) Open DevTools and enable Audits domain.
Attach(); Attach();
...@@ -131,10 +130,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest, ...@@ -131,10 +130,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest,
EXPECT_TRUE(NavigateToURL(shell(), GURL("about:blank"))); EXPECT_TRUE(NavigateToURL(shell(), GURL("about:blank")));
// 2) Report an empty SameSite cookie issue. // 2) Report an empty SameSite cookie issue.
WebContentsImpl* web_contents_impl = ReportDummyIssue(main_frame_host());
static_cast<WebContentsImpl*>(shell()->web_contents());
RenderFrameHostImpl* root = web_contents_impl->GetFrameTree()->GetMainFrame();
ReportDummyIssue(root);
// 3) Navigate to /devtools/navigation.html // 3) Navigate to /devtools/navigation.html
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
......
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