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

Unified Diff: chrome/browser/page_load_metrics/page_load_metrics_mojofication_browsertest.cc

Issue 2823523003: [Page Load Metrics] PageLoadMetrics Mojofication. (Closed)
Patch Set: Addressed comments, remove unnecessary RunUntilIdle, call OnTimingUpdated directly in unit tests Created 3 years, 8 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: chrome/browser/page_load_metrics/page_load_metrics_mojofication_browsertest.cc
diff --git a/chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc b/chrome/browser/page_load_metrics/page_load_metrics_mojofication_browsertest.cc
similarity index 66%
copy from chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc
copy to chrome/browser/page_load_metrics/page_load_metrics_mojofication_browsertest.cc
index 8d69c71e8ddf51c0cebb4c566fda09100271e219..aef526fea94b17ac0de2f1ca3cf17c9b6c4a64a6 100644
--- a/chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc
+++ b/chrome/browser/page_load_metrics/page_load_metrics_mojofication_browsertest.cc
@@ -5,6 +5,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
#include "base/test/histogram_tester.h"
+#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h"
#include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.h"
@@ -18,7 +19,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/common/page_load_metrics/page_load_metrics_messages.h"
+#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -29,18 +30,34 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/download_test_observer.h"
+#include "content/public/test/web_contents_binding_set_test_binder.h"
+#include "mojo/public/cpp/bindings/associated_binding.h"
#include "net/http/failing_http_transaction_factory.h"
#include "net/http/http_cache.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/url_request/url_request_failed_job.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
+#include "testing/gmock/include/gmock/gmock.h"
namespace {
-// Waits until a PageLoadMetricsMsg_TimingUpdated message IPC is received
-// matching a PageLoadTiming. See WaitForMatchingIPC for details.
-class TimingUpdatedObserver : public content::BrowserMessageFilter {
+void FailAllNetworkTransactions(net::URLRequestContextGetter* getter) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ net::HttpCache* cache(
+ getter->GetURLRequestContext()->http_transaction_factory()->GetCache());
+ DCHECK(cache);
+ std::unique_ptr<net::FailingHttpTransactionFactory> factory(
+ new net::FailingHttpTransactionFactory(cache->GetSession(),
+ net::ERR_FAILED));
+ // Throw away old version; since this is a browser test, there is no
+ // need to restore the old state.
+ cache->SetHttpNetworkTransactionFactoryForTesting(std::move(factory));
+}
+
+// Wait until we dispatch PageLoadTiming through UpdateTiming.
+// matching a PageLoadTiming. See WaitForTimingUpdated for details.
+class PageLoadTimingObserver {
public:
// A bitvector to express which timing fields to match on.
enum ExpectedTimingFields {
@@ -49,20 +66,19 @@ class TimingUpdatedObserver : public content::BrowserMessageFilter {
STYLE_UPDATE_BEFORE_FCP = 1 << 2
};
- explicit TimingUpdatedObserver(content::RenderWidgetHost* render_widget_host)
- : content::BrowserMessageFilter(PageLoadMetricsMsgStart) {
- render_widget_host->GetProcess()->AddFilter(this);
-
+ PageLoadTimingObserver() {
// Roundtrip to the IO thread, to ensure that the filter is properly
// installed.
content::BrowserThread::PostTaskAndReply(
- content::BrowserThread::IO, FROM_HERE, base::BindOnce(&base::DoNothing),
- base::BindOnce(&TimingUpdatedObserver::Quit, this));
+ content::BrowserThread::IO, FROM_HERE, base::Bind(&base::DoNothing),
+ base::Bind(&PageLoadTimingObserver::Quit, base::Unretained(this)));
run_loop_.reset(new base::RunLoop());
run_loop_->Run();
run_loop_.reset(nullptr);
}
+ ~PageLoadTimingObserver() {}
+
// Add the given timing fields to the set of fields to match on.
void AddMatchingFields(ExpectedTimingFields fields) {
matching_fields_ |= fields;
@@ -74,10 +90,10 @@ class TimingUpdatedObserver : public content::BrowserMessageFilter {
match_document_write_block_reload_ = count;
}
+ // Waits for a PageLoadTiming that matches the fields set by
// Waits for a TimingUpdated IPC that matches the fields set by
- // |AddMatchingFields|. All matching fields must be set in a TimingUpdated
- // IPC for it to end this wait.
- void WaitForMatchingIPC() {
+ // UpdateTiming to end this wait.
+ void WaitForTimingUpdated() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (matched_timing_update_)
return;
@@ -87,19 +103,8 @@ class TimingUpdatedObserver : public content::BrowserMessageFilter {
run_loop_.reset(nullptr);
}
- private:
- bool OnMessageReceived(const IPC::Message& message) override {
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
-
- IPC_BEGIN_MESSAGE_MAP(TimingUpdatedObserver, message)
- IPC_MESSAGE_HANDLER(PageLoadMetricsMsg_TimingUpdated, OnTimingUpdated)
- IPC_END_MESSAGE_MAP()
-
- return false;
- }
-
- bool OnTimingUpdated(const page_load_metrics::PageLoadTiming& timing,
- const page_load_metrics::PageLoadMetadata& metadata) {
+ void UpdateTiming(const page_load_metrics::PageLoadTiming& timing,
+ const page_load_metrics::PageLoadMetadata& metadata) {
if (match_document_write_block_reload_ > 0 &&
metadata.behavior_flags &
blink::WebLoadingBehaviorFlag::
@@ -108,7 +113,7 @@ class TimingUpdatedObserver : public content::BrowserMessageFilter {
}
if (match_document_write_block_reload_ > 0) {
- return true;
+ return;
}
if ((!(matching_fields_ & FIRST_PAINT) ||
@@ -122,17 +127,17 @@ class TimingUpdatedObserver : public content::BrowserMessageFilter {
// this waiter unblocks.
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
- base::BindOnce(&TimingUpdatedObserver::BounceTimingUpdate, this,
- timing, metadata));
+ base::Bind(&PageLoadTimingObserver::BounceTimingUpdate,
+ base::Unretained(this)));
}
- return true;
}
- void BounceTimingUpdate(const page_load_metrics::PageLoadTiming& timing,
- const page_load_metrics::PageLoadMetadata& metadata) {
+ private:
+ void BounceTimingUpdate() {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
- base::BindOnce(&TimingUpdatedObserver::SetTimingUpdatedAndQuit, this));
+ base::Bind(&PageLoadTimingObserver::SetTimingUpdatedAndQuit,
+ base::Unretained(this)));
}
void Quit() {
@@ -147,8 +152,6 @@ class TimingUpdatedObserver : public content::BrowserMessageFilter {
Quit();
}
- ~TimingUpdatedObserver() override {}
-
std::unique_ptr<base::RunLoop> run_loop_;
int matching_fields_ = 0; // A bitvector composed from ExpectedTimingFields.
bool matched_timing_update_ = false;
@@ -157,10 +160,80 @@ class TimingUpdatedObserver : public content::BrowserMessageFilter {
} // namespace
-class PageLoadMetricsBrowserTest : public InProcessBrowserTest {
+namespace page_load_metrics {
+
+class FakePageLoadMetrics : public mojom::PageLoadMetrics {
+ public:
+ explicit FakePageLoadMetrics(content::RenderFrameHost* render_frame_host) {
+ metrics_observer_ = content::WebContentsUserData<
+ page_load_metrics::MetricsWebContentsObserver>::
+ FromWebContents(
+ content::WebContents::FromRenderFrameHost(render_frame_host));
+ metrics_observer_->page_load_metrics_binding_for_testing()
+ .SetCurrentTargetFrameForTesting(render_frame_host);
+ }
+
+ ~FakePageLoadMetrics() override {}
+
+ void AddObserver(PageLoadTimingObserver* observer) {
Bryan McQuade 2017/04/26 16:04:34 ah, I see now why you have this class and this met
Ken Rockot(use gerrit already) 2017/04/26 16:11:41 The messages are always going to be dispatched to
Bryan McQuade 2017/04/26 20:41:51 I decided that adding testing hooks to the non-tes
lpy 2017/04/27 10:58:35 It looks good.
+ observers_.push_back(base::WrapUnique(observer));
+ }
+
+ private:
+ void UpdateTiming(const PageLoadTiming& timing,
+ const PageLoadMetadata& metadata) override {
+ metrics_observer_->UpdateTiming(timing, metadata);
+ for (auto& observer : observers_) {
+ observer->UpdateTiming(timing, metadata);
+ }
+ }
+
+ MetricsWebContentsObserver* metrics_observer_;
+ std::vector<std::unique_ptr<PageLoadTimingObserver>> observers_;
+};
+
+} // namespace page_load_metrics
+
+namespace {
+
+class FakePageLoadMetricsBinder
+ : public content::WebContentsBindingSetTestBinder<
+ page_load_metrics::mojom::PageLoadMetrics> {
+ public:
+ FakePageLoadMetricsBinder(
+ page_load_metrics::mojom::PageLoadMetrics* page_load_metrics)
+ : page_load_metrics_(page_load_metrics) {}
+ ~FakePageLoadMetricsBinder() override {}
+
+ void BindRequest(content::RenderFrameHost* frame_host,
+ page_load_metrics::mojom::PageLoadMetricsAssociatedRequest
+ request) override {
+ bindings_.AddBinding(page_load_metrics_, std::move(request), frame_host);
+ }
+
+ private:
+ page_load_metrics::mojom::PageLoadMetrics* page_load_metrics_;
+ mojo::AssociatedBindingSet<page_load_metrics::mojom::PageLoadMetrics,
+ content::RenderFrameHost*>
+ bindings_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakePageLoadMetricsBinder);
+};
+
+} // namespace
+
+class PageLoadMetricsMojoficationBrowserTest : public InProcessBrowserTest {
public:
- PageLoadMetricsBrowserTest() {}
- ~PageLoadMetricsBrowserTest() override {}
+ PageLoadMetricsMojoficationBrowserTest() {}
+ ~PageLoadMetricsMojoficationBrowserTest() override {}
+
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ // We need to set the feature state before the render process is created,
+ // in order for it to inherit the feature state from the browser process.
+ // SetUp() runs too early, and SetUpOnMainThread() runs too late.
+ scoped_feature_list_.InitAndEnableFeature(
+ features::kPageLoadMetricsMojofication);
+ }
protected:
void NavigateToUntrackedUrl() {
@@ -178,39 +251,41 @@ class PageLoadMetricsBrowserTest : public InProcessBrowserTest {
return total_pageload_histograms - total_internal_histograms == 0;
}
- scoped_refptr<TimingUpdatedObserver> CreateTimingUpdatedObserver() {
- content::WebContents* web_contents =
- browser()->tab_strip_model()->GetActiveWebContents();
- scoped_refptr<TimingUpdatedObserver> observer(new TimingUpdatedObserver(
- web_contents->GetRenderViewHost()->GetWidget()));
+ PageLoadTimingObserver* CreatePageLoadTimingObserver() {
+ if (!fake_page_load_metrics_) {
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ fake_page_load_metrics_.reset(new page_load_metrics::FakePageLoadMetrics(
+ web_contents->GetMainFrame()));
+ content::WebContentsBindingSet::GetForWebContents<
+ page_load_metrics::mojom::PageLoadMetrics>(web_contents)
+ ->SetBinderForTesting(base::MakeUnique<FakePageLoadMetricsBinder>(
+ fake_page_load_metrics_.get()));
+ }
+ PageLoadTimingObserver* observer = new PageLoadTimingObserver();
+ fake_page_load_metrics_->AddObserver(observer);
return observer;
}
+ base::test::ScopedFeatureList scoped_feature_list_;
+ std::unique_ptr<page_load_metrics::FakePageLoadMetrics>
+ fake_page_load_metrics_;
base::HistogramTester histogram_tester_;
private:
- DISALLOW_COPY_AND_ASSIGN(PageLoadMetricsBrowserTest);
+ DISALLOW_COPY_AND_ASSIGN(PageLoadMetricsMojoficationBrowserTest);
};
-void FailAllNetworkTransactions(net::URLRequestContextGetter* getter) {
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- net::HttpCache* cache(
- getter->GetURLRequestContext()->http_transaction_factory()->GetCache());
- DCHECK(cache);
- std::unique_ptr<net::FailingHttpTransactionFactory> factory(
- new net::FailingHttpTransactionFactory(cache->GetSession(),
- net::ERR_FAILED));
- // Throw away old version; since this is a browser test, there is no
- // need to restore the old state.
- cache->SetHttpNetworkTransactionFactoryForTesting(std::move(factory));
-}
-
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoNavigation) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest, NoNavigation) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
EXPECT_TRUE(NoPageLoadMetricsRecorded());
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NewPage) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest, NewPage) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
@@ -234,7 +309,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NewPage) {
EXPECT_FALSE(NoPageLoadMetricsRecorded());
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SameDocumentNavigation) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ SameDocumentNavigation) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
@@ -248,7 +326,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SameDocumentNavigation) {
histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SameUrlNavigation) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ SameUrlNavigation) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
@@ -263,7 +344,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SameUrlNavigation) {
histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 2);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NonHtmlMainResource) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ NonHtmlMainResource) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
@@ -272,7 +356,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NonHtmlMainResource) {
EXPECT_TRUE(NoPageLoadMetricsRecorded());
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NonHttpOrHttpsUrl) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ NonHttpOrHttpsUrl) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIVersionURL));
@@ -280,7 +367,9 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NonHttpOrHttpsUrl) {
EXPECT_TRUE(NoPageLoadMetricsRecorded());
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, HttpErrorPage) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest, HttpErrorPage) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(
@@ -289,7 +378,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, HttpErrorPage) {
EXPECT_TRUE(NoPageLoadMetricsRecorded());
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, ChromeErrorPage) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ ChromeErrorPage) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
// Configure the network stack to fail all attempted loads with a network
@@ -298,8 +390,8 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, ChromeErrorPage) {
browser()->profile()->GetRequestContext();
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
- base::BindOnce(&FailAllNetworkTransactions,
- base::RetainedRef(url_request_context_getter)));
+ base::Bind(&FailAllNetworkTransactions,
+ base::RetainedRef(url_request_context_getter)));
ui_test_utils::NavigateToURL(browser(),
embedded_test_server()->GetURL("/title1.html"));
@@ -307,7 +399,9 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, ChromeErrorPage) {
EXPECT_TRUE(NoPageLoadMetricsRecorded());
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, Ignore204Pages) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest, Ignore204Pages) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
@@ -316,7 +410,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, Ignore204Pages) {
EXPECT_TRUE(NoPageLoadMetricsRecorded());
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, IgnoreDownloads) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ IgnoreDownloads) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
base::ScopedTempDir downloads_directory;
@@ -336,24 +433,29 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, IgnoreDownloads) {
EXPECT_TRUE(NoPageLoadMetricsRecorded());
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PreloadDocumentWrite) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ PreloadDocumentWrite) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
- scoped_refptr<TimingUpdatedObserver> fcp_observer =
- CreateTimingUpdatedObserver();
+ PageLoadTimingObserver* fcp_observer = CreatePageLoadTimingObserver();
fcp_observer->AddMatchingFields(
- TimingUpdatedObserver::FIRST_CONTENTFUL_PAINT);
+ PageLoadTimingObserver::FIRST_CONTENTFUL_PAINT);
ui_test_utils::NavigateToURL(
browser(), embedded_test_server()->GetURL(
"/page_load_metrics/document_write_external_script.html"));
- fcp_observer->WaitForMatchingIPC();
+ fcp_observer->WaitForTimingUpdated();
histogram_tester_.ExpectTotalCount(
internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 1);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoPreloadDocumentWrite) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ NoPreloadDocumentWrite) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(
@@ -365,17 +467,19 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoPreloadDocumentWrite) {
internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 0);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoDocumentWrite) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ NoDocumentWrite) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
- scoped_refptr<TimingUpdatedObserver> fcp_observer =
- CreateTimingUpdatedObserver();
+ PageLoadTimingObserver* fcp_observer = CreatePageLoadTimingObserver();
fcp_observer->AddMatchingFields(
- TimingUpdatedObserver::FIRST_CONTENTFUL_PAINT);
+ PageLoadTimingObserver::FIRST_CONTENTFUL_PAINT);
ui_test_utils::NavigateToURL(browser(),
embedded_test_server()->GetURL("/title1.html"));
- fcp_observer->WaitForMatchingIPC();
+ fcp_observer->WaitForTimingUpdated();
histogram_tester_.ExpectTotalCount(
internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 0);
@@ -384,33 +488,36 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoDocumentWrite) {
histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 0);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteBlock) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ DocumentWriteBlock) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
- scoped_refptr<TimingUpdatedObserver> fcp_observer =
- CreateTimingUpdatedObserver();
+ PageLoadTimingObserver* fcp_observer = CreatePageLoadTimingObserver();
fcp_observer->AddMatchingFields(
- TimingUpdatedObserver::FIRST_CONTENTFUL_PAINT);
+ PageLoadTimingObserver::FIRST_CONTENTFUL_PAINT);
ui_test_utils::NavigateToURL(
browser(), embedded_test_server()->GetURL(
"/page_load_metrics/document_write_script_block.html"));
- fcp_observer->WaitForMatchingIPC();
+ fcp_observer->WaitForTimingUpdated();
histogram_tester_.ExpectTotalCount(
internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1);
histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 1);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteReload) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ DocumentWriteReload) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
- scoped_refptr<TimingUpdatedObserver> fcp_observer =
- CreateTimingUpdatedObserver();
+ PageLoadTimingObserver* fcp_observer = CreatePageLoadTimingObserver();
fcp_observer->AddMatchingFields(
- TimingUpdatedObserver::FIRST_CONTENTFUL_PAINT);
- scoped_refptr<TimingUpdatedObserver> reload_observer =
- CreateTimingUpdatedObserver();
+ PageLoadTimingObserver::FIRST_CONTENTFUL_PAINT);
+ PageLoadTimingObserver* reload_observer = CreatePageLoadTimingObserver();
reload_observer->MatchDocumentWriteBlockReload(2);
ui_test_utils::NavigateToURL(
@@ -429,8 +536,8 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteReload) {
histogram_tester_.ExpectTotalCount(
internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1);
- fcp_observer->WaitForMatchingIPC();
- reload_observer->WaitForMatchingIPC();
+ fcp_observer->WaitForTimingUpdated();
+ reload_observer->WaitForTimingUpdated();
histogram_tester_.ExpectTotalCount(
internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1);
@@ -440,7 +547,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteReload) {
histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 1);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteAsync) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ DocumentWriteAsync) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(
@@ -453,7 +563,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteAsync) {
histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 0);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteSameDomain) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ DocumentWriteSameDomain) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(
@@ -466,7 +579,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteSameDomain) {
histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 0);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoDocumentWriteScript) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ NoDocumentWriteScript) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(
@@ -479,18 +595,13 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoDocumentWriteScript) {
histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 0);
}
-// TODO(crbug.com/712935): Flaky on Linux dbg.
-#if defined(OS_LINUX) && !defined(NDEBUG)
-#define MAYBE_BadXhtml DISABLED_BadXhtml
-#else
-#define MAYBE_BadXhtml BadXhtml
-#endif
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, MAYBE_BadXhtml) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest, BadXhtml) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
- scoped_refptr<TimingUpdatedObserver> timing_observer =
- CreateTimingUpdatedObserver();
- timing_observer->AddMatchingFields(TimingUpdatedObserver::FIRST_PAINT);
+ PageLoadTimingObserver* timing_observer = CreatePageLoadTimingObserver();
+ timing_observer->AddMatchingFields(PageLoadTimingObserver::FIRST_PAINT);
// When an XHTML page contains invalid XML, it causes a paint of the error
// message without a layout. Page load metrics currently treats this as an
@@ -501,7 +612,7 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, MAYBE_BadXhtml) {
browser(),
embedded_test_server()->GetURL("/page_load_metrics/badxml.xhtml"));
- timing_observer->WaitForMatchingIPC();
+ timing_observer->WaitForTimingUpdated();
histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 0);
histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 0);
@@ -521,7 +632,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, MAYBE_BadXhtml) {
// Test code that aborts provisional navigations.
// TODO(csharrison): Move these to unit tests once the navigation API in content
// properly calls NavigationHandle/NavigationThrottle methods.
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortNewNavigation) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ AbortNewNavigation) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
GURL url(embedded_test_server()->GetURL("/title1.html"));
@@ -544,7 +658,9 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortNewNavigation) {
internal::kHistogramAbortNewNavigationBeforeCommit, 1);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortReload) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest, AbortReload) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
GURL url(embedded_test_server()->GetURL("/title1.html"));
@@ -571,7 +687,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortReload) {
#else
#define MAYBE_AbortClose AbortClose
#endif
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, MAYBE_AbortClose) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
+ MAYBE_AbortClose) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
GURL url(embedded_test_server()->GetURL("/title1.html"));
@@ -590,7 +709,9 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, MAYBE_AbortClose) {
1);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortMultiple) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest, AbortMultiple) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
GURL url(embedded_test_server()->GetURL("/title1.html"));
@@ -625,8 +746,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortMultiple) {
internal::kHistogramAbortNewNavigationBeforeCommit, 2);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
NoAbortMetricsOnClientRedirect) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
GURL first_url(embedded_test_server()->GetURL("/title1.html"));
@@ -655,8 +778,10 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
.empty());
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
FirstMeaningfulPaintRecorded) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
@@ -670,33 +795,34 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
kNetworkIdleTime + kMargin);
bool result;
EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
- browser()->tab_strip_model()->GetActiveWebContents(),
- javascript, &result));
+ browser()->tab_strip_model()->GetActiveWebContents(), javascript,
+ &result));
EXPECT_TRUE(result);
NavigateToUntrackedUrl();
histogram_tester_.ExpectUniqueSample(
internal::kHistogramFirstMeaningfulPaintStatus,
internal::FIRST_MEANINGFUL_PAINT_RECORDED, 1);
- histogram_tester_.ExpectTotalCount(
- internal::kHistogramFirstMeaningfulPaint, 1);
+ histogram_tester_.ExpectTotalCount(internal::kHistogramFirstMeaningfulPaint,
+ 1);
histogram_tester_.ExpectTotalCount(
internal::kHistogramParseStartToFirstMeaningfulPaint, 1);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
FirstMeaningfulPaintNotRecorded) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
- scoped_refptr<TimingUpdatedObserver> fcp_observer =
- CreateTimingUpdatedObserver();
+ PageLoadTimingObserver* fcp_observer = CreatePageLoadTimingObserver();
fcp_observer->AddMatchingFields(
- TimingUpdatedObserver::FIRST_CONTENTFUL_PAINT);
+ PageLoadTimingObserver::FIRST_CONTENTFUL_PAINT);
ui_test_utils::NavigateToURL(
browser(), embedded_test_server()->GetURL(
"/page_load_metrics/page_with_active_connections.html"));
- fcp_observer->WaitForMatchingIPC();
+ fcp_observer->WaitForTimingUpdated();
// Navigate away before a FMP is reported.
NavigateToUntrackedUrl();
@@ -704,25 +830,26 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
histogram_tester_.ExpectUniqueSample(
internal::kHistogramFirstMeaningfulPaintStatus,
internal::FIRST_MEANINGFUL_PAINT_DID_NOT_REACH_NETWORK_STABLE, 1);
- histogram_tester_.ExpectTotalCount(
- internal::kHistogramFirstMeaningfulPaint, 0);
+ histogram_tester_.ExpectTotalCount(internal::kHistogramFirstMeaningfulPaint,
+ 0);
histogram_tester_.ExpectTotalCount(
internal::kHistogramParseStartToFirstMeaningfulPaint, 0);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
NoStatePrefetchObserverCacheable) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
- scoped_refptr<TimingUpdatedObserver> fcp_observer =
- CreateTimingUpdatedObserver();
+ PageLoadTimingObserver* fcp_observer = CreatePageLoadTimingObserver();
fcp_observer->AddMatchingFields(
- TimingUpdatedObserver::FIRST_CONTENTFUL_PAINT);
+ PageLoadTimingObserver::FIRST_CONTENTFUL_PAINT);
ui_test_utils::NavigateToURL(browser(),
embedded_test_server()->GetURL("/title1.html"));
- fcp_observer->WaitForMatchingIPC();
+ fcp_observer->WaitForTimingUpdated();
histogram_tester_.ExpectTotalCount(
"Prerender.none_PrefetchTTFCP.Reference.NoStore.Visible", 0);
@@ -730,19 +857,20 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
"Prerender.none_PrefetchTTFCP.Reference.Cacheable.Visible", 1);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest,
NoStatePrefetchObserverNoStore) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
- scoped_refptr<TimingUpdatedObserver> fcp_observer =
- CreateTimingUpdatedObserver();
+ PageLoadTimingObserver* fcp_observer = CreatePageLoadTimingObserver();
fcp_observer->AddMatchingFields(
- TimingUpdatedObserver::FIRST_CONTENTFUL_PAINT);
+ PageLoadTimingObserver::FIRST_CONTENTFUL_PAINT);
ui_test_utils::NavigateToURL(browser(),
embedded_test_server()->GetURL("/nostore.html"));
- fcp_observer->WaitForMatchingIPC();
+ fcp_observer->WaitForTimingUpdated();
histogram_tester_.ExpectTotalCount(
"Prerender.none_PrefetchTTFCP.Reference.NoStore.Visible", 1);
@@ -750,13 +878,14 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
"Prerender.none_PrefetchTTFCP.Reference.Cacheable.Visible", 0);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, CSSTiming) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest, CSSTiming) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
- scoped_refptr<TimingUpdatedObserver> fcp_observer =
- CreateTimingUpdatedObserver();
+ PageLoadTimingObserver* fcp_observer = CreatePageLoadTimingObserver();
fcp_observer->AddMatchingFields(
- TimingUpdatedObserver::STYLE_UPDATE_BEFORE_FCP);
+ PageLoadTimingObserver::STYLE_UPDATE_BEFORE_FCP);
// Careful: Blink code clamps timestamps to 5us, so any CSS parsing we do here
// must take >> 5us, otherwise we'll log 0 for the value and it will remain
@@ -765,7 +894,7 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, CSSTiming) {
browser(),
embedded_test_server()->GetURL("/page_load_metrics/page_with_css.html"));
NavigateToUntrackedUrl();
- fcp_observer->WaitForMatchingIPC();
+ fcp_observer->WaitForTimingUpdated();
histogram_tester_.ExpectTotalCount(internal::kHistogramFirstContentfulPaint,
1);
@@ -777,7 +906,9 @@ IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, CSSTiming) {
"PageLoad.CSSTiming.ParseAndUpdate.BeforeFirstContentfulPaint", 1);
}
-IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PayloadSize) {
+IN_PROC_BROWSER_TEST_F(PageLoadMetricsMojoficationBrowserTest, PayloadSize) {
+ ASSERT_TRUE(
+ base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication));
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL(

Powered by Google App Engine
This is Rietveld 408576698