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

Unified Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2936723002: Report frequency of single page app navigations to UMA (Closed)
Patch Set: NOTREACHED Created 3 years, 5 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 | « third_party/WebKit/Source/core/loader/FrameLoaderTypes.h ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index e65cf9357daec829ee1d2389333465bbde87b233..b09a4a14f8ecaba219e92a08b7e883ed6606c468 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -112,6 +112,7 @@
#include "platform/scroll/ScrollbarTheme.h"
#include "platform/scroll/ScrollbarThemeMock.h"
#include "platform/scroll/ScrollbarThemeOverlayMock.h"
+#include "platform/testing/HistogramTester.h"
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "platform/testing/URLTestHelpers.h"
#include "platform/testing/UnitTestHelpers.h"
@@ -12025,4 +12026,45 @@ TEST_F(WebFrameTest, NavigatorPluginsClearedWhenPluginsDisabled) {
EXPECT_EQ(0, result->Int32Value());
}
+TEST_F(WebFrameTest, RecordSameDocumentNavigationToHistogram) {
+ const char* histogramName =
+ "RendererScheduler.UpdateForSameDocumentNavigationCount";
+ FrameTestHelpers::WebViewHelper web_view_helper;
+ HistogramTester tester;
+ web_view_helper.InitializeAndLoad("about:blank");
+ LocalFrame* frame =
+ ToLocalFrame(web_view_helper.WebView()->GetPage()->MainFrame());
+
+ FrameLoader& main_frame_loader =
+ web_view_helper.WebView()->MainFrameImpl()->GetFrame()->Loader();
+ RefPtr<SerializedScriptValue> message =
+ SerializeString("message", ToScriptStateForMainWorld(frame));
+ tester.ExpectTotalCount(histogramName, 0);
+ main_frame_loader.UpdateForSameDocumentNavigation(
+ ToKURL("about:blank"), kSameDocumentNavigationHistoryApi, message,
+ kScrollRestorationAuto, kFrameLoadTypeInitialHistoryLoad,
+ frame->GetDocument());
+ // The bucket index corresponds to the definition of
+ // |SinglePageAppNavigationType|.
+ tester.ExpectBucketCount(histogramName,
+ kSPANavTypeHistoryPushStateOrReplaceState, 1);
+ main_frame_loader.UpdateForSameDocumentNavigation(
+ ToKURL("about:blank"), kSameDocumentNavigationDefault, message,
+ kScrollRestorationManual, kFrameLoadTypeBackForward,
+ frame->GetDocument());
+ tester.ExpectBucketCount(histogramName,
+ kSPANavTypeSameDocumentBackwardOrForward, 1);
+ main_frame_loader.UpdateForSameDocumentNavigation(
+ ToKURL("about:blank"), kSameDocumentNavigationDefault, message,
+ kScrollRestorationManual, kFrameLoadTypeInitialHistoryLoad,
+ frame->GetDocument());
+ tester.ExpectBucketCount(histogramName, kSPANavTypeOtherFragmentNavigation,
+ 1);
+ // kSameDocumentNavigationHistoryApi and kFrameLoadTypeBackForward is an
+ // illegal combination, which has been caught by DCHECK in
+ // UpdateForSameDocumentNavigation().
+
+ tester.ExpectTotalCount(histogramName, 3);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameLoaderTypes.h ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698