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 075bd61acf7c77cbfc5366e835515ee98c49d3f4..ad35b8306cbc91b3eff29d42645d999afcd9dd8b 100644 |
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
@@ -103,6 +103,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" |
@@ -12188,4 +12189,42 @@ TEST_F(WebFrameTest, AltTextOnAboutBlankPage) { |
EXPECT_EQ("foo alt", text.Utf8()); |
} |
+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, 0, 1); |
tdresser
2017/06/21 14:45:00
Can you index using the enum values?
Liquan (Max) Gu
2017/06/26 14:52:21
OK, I will put the enum in frameLoaderTypers.h.
|
+ main_frame_loader.UpdateForSameDocumentNavigation( |
+ ToKURL("about:blank"), kSameDocumentNavigationDefault, message, |
+ kScrollRestorationManual, kFrameLoadTypeBackForward, |
+ frame->GetDocument()); |
+ tester.ExpectBucketCount(histogramName, 1, 1); |
+ main_frame_loader.UpdateForSameDocumentNavigation( |
+ ToKURL("about:blank"), kSameDocumentNavigationDefault, message, |
+ kScrollRestorationManual, kFrameLoadTypeInitialHistoryLoad, |
+ frame->GetDocument()); |
+ tester.ExpectBucketCount(histogramName, 2, 1); |
+ // kSameDocumentNavigationHistoryApi and kFrameLoadTypeBackForward is an |
+ // illegal combination, which has been caught by DCHECK in |
+ // UpdateForSameDocumentNavigation(). |
+ |
+ tester.ExpectTotalCount(histogramName, 3); |
+} |
+ |
} // namespace blink |