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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2936723002: Report frequency of single page app navigations to UMA (Closed)
Patch Set: add DCHECK, remove others as a category Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 #include "platform/loader/fetch/FetchParameters.h" 96 #include "platform/loader/fetch/FetchParameters.h"
97 #include "platform/loader/fetch/MemoryCache.h" 97 #include "platform/loader/fetch/MemoryCache.h"
98 #include "platform/loader/fetch/ResourceError.h" 98 #include "platform/loader/fetch/ResourceError.h"
99 #include "platform/loader/fetch/ResourceFetcher.h" 99 #include "platform/loader/fetch/ResourceFetcher.h"
100 #include "platform/loader/fetch/ResourceLoaderOptions.h" 100 #include "platform/loader/fetch/ResourceLoaderOptions.h"
101 #include "platform/scroll/Scrollbar.h" 101 #include "platform/scroll/Scrollbar.h"
102 #include "platform/scroll/ScrollbarTestSuite.h" 102 #include "platform/scroll/ScrollbarTestSuite.h"
103 #include "platform/scroll/ScrollbarTheme.h" 103 #include "platform/scroll/ScrollbarTheme.h"
104 #include "platform/scroll/ScrollbarThemeMock.h" 104 #include "platform/scroll/ScrollbarThemeMock.h"
105 #include "platform/scroll/ScrollbarThemeOverlayMock.h" 105 #include "platform/scroll/ScrollbarThemeOverlayMock.h"
106 #include "platform/testing/HistogramTester.h"
106 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 107 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
107 #include "platform/testing/URLTestHelpers.h" 108 #include "platform/testing/URLTestHelpers.h"
108 #include "platform/testing/UnitTestHelpers.h" 109 #include "platform/testing/UnitTestHelpers.h"
109 #include "platform/weborigin/KURLHash.h" 110 #include "platform/weborigin/KURLHash.h"
110 #include "platform/weborigin/SchemeRegistry.h" 111 #include "platform/weborigin/SchemeRegistry.h"
111 #include "platform/weborigin/SecurityOrigin.h" 112 #include "platform/weborigin/SecurityOrigin.h"
112 #include "platform/wtf/Forward.h" 113 #include "platform/wtf/Forward.h"
113 #include "platform/wtf/PtrUtil.h" 114 #include "platform/wtf/PtrUtil.h"
114 #include "platform/wtf/dtoa/utils.h" 115 #include "platform/wtf/dtoa/utils.h"
115 #include "public/platform/Platform.h" 116 #include "public/platform/Platform.h"
(...skipping 12065 matching lines...) Expand 10 before | Expand all | Expand 10 after
12181 for (LayoutObject* obj = layout_object; obj; obj = obj->NextInPreOrder()) { 12182 for (LayoutObject* obj = layout_object; obj; obj = obj->NextInPreOrder()) {
12182 if (obj->IsText()) { 12183 if (obj->IsText()) {
12183 LayoutText* layout_text = ToLayoutText(obj); 12184 LayoutText* layout_text = ToLayoutText(obj);
12184 text = layout_text->GetText(); 12185 text = layout_text->GetText();
12185 break; 12186 break;
12186 } 12187 }
12187 } 12188 }
12188 EXPECT_EQ("foo alt", text.Utf8()); 12189 EXPECT_EQ("foo alt", text.Utf8());
12189 } 12190 }
12190 12191
12192 TEST_F(WebFrameTest, RecordSameDocumentNavigationToHistogram) {
12193 const char* histogramName =
12194 "RendererScheduler.UpdateForSameDocumentNavigationCount";
12195 FrameTestHelpers::WebViewHelper web_view_helper;
12196 HistogramTester tester;
12197 web_view_helper.InitializeAndLoad("about:blank");
12198 LocalFrame* frame =
12199 ToLocalFrame(web_view_helper.WebView()->GetPage()->MainFrame());
12200
12201 FrameLoader& main_frame_loader =
12202 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->Loader();
12203 RefPtr<SerializedScriptValue> message =
12204 SerializeString("message", ToScriptStateForMainWorld(frame));
12205 tester.ExpectTotalCount(histogramName, 0);
12206 main_frame_loader.UpdateForSameDocumentNavigation(
12207 ToKURL("about:blank"), kSameDocumentNavigationHistoryApi, message,
12208 kScrollRestorationAuto, kFrameLoadTypeInitialHistoryLoad,
12209 frame->GetDocument());
12210 // The bucket index corresponds to the definition of
12211 // |SinglePageAppNavigationType|.
12212 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.
12213 main_frame_loader.UpdateForSameDocumentNavigation(
12214 ToKURL("about:blank"), kSameDocumentNavigationDefault, message,
12215 kScrollRestorationManual, kFrameLoadTypeBackForward,
12216 frame->GetDocument());
12217 tester.ExpectBucketCount(histogramName, 1, 1);
12218 main_frame_loader.UpdateForSameDocumentNavigation(
12219 ToKURL("about:blank"), kSameDocumentNavigationDefault, message,
12220 kScrollRestorationManual, kFrameLoadTypeInitialHistoryLoad,
12221 frame->GetDocument());
12222 tester.ExpectBucketCount(histogramName, 2, 1);
12223 // kSameDocumentNavigationHistoryApi and kFrameLoadTypeBackForward is an
12224 // illegal combination, which has been caught by DCHECK in
12225 // UpdateForSameDocumentNavigation().
12226
12227 tester.ExpectTotalCount(histogramName, 3);
12228 }
12229
12191 } // namespace blink 12230 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698