Commit 9ecb5856 authored by bmcquade's avatar bmcquade Committed by Commit bot

Update https engagement browsertest to always use HTML resources.

A few https engagement tests used the test server resource at URL '/'.
It turns out that this resource gets served with mime type text/plain,
which we're planning to have page load metrics infrastructure ignore
in the future. This change switches those tests to use '/simple.html'
which is served with mime type text/html.

Additionally, this change adds a new test
Navigate_Both_NonHtmlMainResource, which we'll use to verify that we do
not track non-HTML resources.  The test currently asserts that we do
track these resources, with a comment explaining that we'll update it
to assert they are untracked as part of fixing bug 627536.

BUG=627536

Review-Url: https://codereview.chromium.org/2148473002
Cr-Commit-Position: refs/heads/master@{#405226}
parent 2096e291
...@@ -159,8 +159,8 @@ class HttpsEngagementPageLoadMetricsBrowserTest : public InProcessBrowserTest { ...@@ -159,8 +159,8 @@ class HttpsEngagementPageLoadMetricsBrowserTest : public InProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
Simple_Https) { Simple_Https) {
StartHttpsServer(false); StartHttpsServer(false);
base::TimeDelta upper_bound = base::TimeDelta upper_bound = NavigateInForegroundAndCloseWithTiming(
NavigateInForegroundAndCloseWithTiming(https_test_server_->GetURL("/")); https_test_server_->GetURL("/simple.html"));
histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 0); histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 0);
histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1); histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1);
int32_t bucket_min = int32_t bucket_min =
...@@ -172,8 +172,8 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, ...@@ -172,8 +172,8 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, Simple_Http) { IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, Simple_Http) {
StartHttpServer(); StartHttpServer();
base::TimeDelta upper_bound = base::TimeDelta upper_bound = NavigateInForegroundAndCloseWithTiming(
NavigateInForegroundAndCloseWithTiming(http_test_server_->GetURL("/")); http_test_server_->GetURL("/simple.html"));
histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 1); histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 1);
histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 0); histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 0);
int32_t bucket_min = int32_t bucket_min =
...@@ -211,7 +211,8 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, ...@@ -211,7 +211,8 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
UncommittedLoadWithError) { UncommittedLoadWithError) {
StartHttpsServer(true); StartHttpsServer(true);
TabStripModel* tab_strip_model = browser()->tab_strip_model(); TabStripModel* tab_strip_model = browser()->tab_strip_model();
ui_test_utils::NavigateToURL(browser(), https_test_server_->GetURL("/")); ui_test_utils::NavigateToURL(browser(),
https_test_server_->GetURL("/simple.html"));
content::WebContentsDestroyedWatcher destroyed_watcher( content::WebContentsDestroyedWatcher destroyed_watcher(
tab_strip_model->GetActiveWebContents()); tab_strip_model->GetActiveWebContents());
EXPECT_TRUE( EXPECT_TRUE(
...@@ -224,7 +225,7 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, ...@@ -224,7 +225,7 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
Navigate_Https) { Navigate_Https) {
StartHttpsServer(false); StartHttpsServer(false);
NavigateTwiceInTabAndClose(https_test_server_->GetURL("/"), NavigateTwiceInTabAndClose(https_test_server_->GetURL("/simple.html"),
GURL(chrome::kChromeUIVersionURL)); GURL(chrome::kChromeUIVersionURL));
histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 0); histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 0);
histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1); histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1);
...@@ -233,7 +234,7 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, ...@@ -233,7 +234,7 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
Navigate_Http) { Navigate_Http) {
StartHttpServer(); StartHttpServer();
NavigateTwiceInTabAndClose(http_test_server_->GetURL("/"), NavigateTwiceInTabAndClose(http_test_server_->GetURL("/simple.html"),
GURL(chrome::kChromeUIVersionURL)); GURL(chrome::kChromeUIVersionURL));
histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 1); histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 1);
histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 0); histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 0);
...@@ -243,8 +244,22 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, ...@@ -243,8 +244,22 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
Navigate_Both) { Navigate_Both) {
StartHttpServer(); StartHttpServer();
StartHttpsServer(false); StartHttpsServer(false);
NavigateTwiceInTabAndClose(http_test_server_->GetURL("/"), NavigateTwiceInTabAndClose(http_test_server_->GetURL("/simple.html"),
https_test_server_->GetURL("/")); https_test_server_->GetURL("/simple.html"));
histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 1);
histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1);
}
IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
Navigate_Both_NonHtmlMainResource) {
StartHttpServer();
StartHttpsServer(false);
NavigateTwiceInTabAndClose(http_test_server_->GetURL("/circle.svg"),
https_test_server_->GetURL("/circle.svg"));
// TODO(bmcquade): for the time being, the page load metrics infrastructure
// also tracks non-HTML resources. We should update these to expect 0
// histogram events once that gets fixed. See crbug.com/627536.
histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 1); histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 1);
histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1); histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1);
} }
...@@ -254,7 +269,7 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, ...@@ -254,7 +269,7 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
StartHttpsServer(false); StartHttpsServer(false);
base::TimeDelta upper_bound = base::TimeDelta upper_bound =
NavigateInForegroundAndCloseInBackgroundWithTiming( NavigateInForegroundAndCloseInBackgroundWithTiming(
https_test_server_->GetURL("/")); https_test_server_->GetURL("/simple.html"));
histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 0); histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 0);
histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1); histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1);
int32_t bucket_min = int32_t bucket_min =
...@@ -269,7 +284,7 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, ...@@ -269,7 +284,7 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
StartHttpServer(); StartHttpServer();
base::TimeDelta upper_bound = base::TimeDelta upper_bound =
NavigateInForegroundAndCloseInBackgroundWithTiming( NavigateInForegroundAndCloseInBackgroundWithTiming(
http_test_server_->GetURL("/")); http_test_server_->GetURL("/simple.html"));
histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 1); histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 1);
histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 0); histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 0);
int32_t bucket_min = int32_t bucket_min =
...@@ -284,7 +299,7 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, ...@@ -284,7 +299,7 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
StartHttpsServer(false); StartHttpsServer(false);
base::TimeDelta upper_bound = base::TimeDelta upper_bound =
NavigateInBackgroundAndCloseInForegroundWithTiming( NavigateInBackgroundAndCloseInForegroundWithTiming(
https_test_server_->GetURL("/")); https_test_server_->GetURL("/simple.html"));
histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 0); histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 0);
histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1); histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1);
int32_t bucket_min = int32_t bucket_min =
...@@ -299,7 +314,7 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, ...@@ -299,7 +314,7 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
StartHttpServer(); StartHttpServer();
base::TimeDelta upper_bound = base::TimeDelta upper_bound =
NavigateInBackgroundAndCloseInForegroundWithTiming( NavigateInBackgroundAndCloseInForegroundWithTiming(
http_test_server_->GetURL("/")); http_test_server_->GetURL("/simple.html"));
histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 1); histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 1);
histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 0); histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 0);
int32_t bucket_min = int32_t bucket_min =
...@@ -313,8 +328,8 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, ...@@ -313,8 +328,8 @@ IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
AlwaysInBackground) { AlwaysInBackground) {
StartHttpsServer(false); StartHttpsServer(false);
StartHttpServer(); StartHttpServer();
NavigateInBackgroundAndClose(https_test_server_->GetURL("/")); NavigateInBackgroundAndClose(https_test_server_->GetURL("/simple.html"));
NavigateInBackgroundAndClose(http_test_server_->GetURL("/")); NavigateInBackgroundAndClose(http_test_server_->GetURL("/simple.html"));
histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 0); histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 0);
histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 0); histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 0);
} }
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