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

Unified Diff: tracing/tracing/metrics/system_health/loading_metric_test.html

Issue 2862103002: Fix main frame detection in loading metrics. (Closed)
Patch Set: rebase Created 3 years, 7 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: tracing/tracing/metrics/system_health/loading_metric_test.html
diff --git a/tracing/tracing/metrics/system_health/loading_metric_test.html b/tracing/tracing/metrics/system_health/loading_metric_test.html
index 4f9e3c6c127f5fa5e7bc9e46d295c52f8b9dfc1b..9d13ca6737dea34b94ecb781508623349dd7eff6 100644
--- a/tracing/tracing/metrics/system_health/loading_metric_test.html
+++ b/tracing/tracing/metrics/system_health/loading_metric_test.html
@@ -31,6 +31,13 @@ tr.b.unittest.testSuite(function() {
frame: {id_ref: '0xdeadbeef'},
documentLoaderURL: 'http://example.com'
});
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
cat: 'loading,rail,devtools.timeline',
title: 'firstContentfulPaint',
@@ -72,6 +79,13 @@ tr.b.unittest.testSuite(function() {
frame: {id_ref: '0xdeadbeef'},
documentLoaderURL: 'http://example.com'
});
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
cat: 'loading,rail,devtools.timeline',
title: 'firstContentfulPaint',
@@ -100,6 +114,13 @@ tr.b.unittest.testSuite(function() {
frame: {id_ref: '0xdeadbeef'},
documentLoaderURL: 'http://example.com'
});
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 2100,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
cat: 'loading,rail,devtools.timeline',
title: 'firstContentfulPaint',
@@ -133,6 +154,13 @@ tr.b.unittest.testSuite(function() {
frame: {id_ref: '0xdeadbeef'},
documentLoaderURL: 'http://example.com'
});
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
cat: 'loading',
title: 'firstMeaningfulPaintCandidate',
@@ -182,6 +210,13 @@ tr.b.unittest.testSuite(function() {
frame: {id_ref: '0xdeadbeef'},
documentLoaderURL: 'http://example.com'
});
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
cat: 'loading',
title: 'firstMeaningfulPaintCandidate',
@@ -245,6 +280,13 @@ tr.b.unittest.testSuite(function() {
frame: {id_ref: '0xdeadbeef'},
documentLoaderURL: 'http://example.com'
});
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
cat: 'loading',
title: 'firstMeaningfulPaintCandidate',
@@ -315,6 +357,13 @@ tr.b.unittest.testSuite(function() {
frame: {id_ref: '0xdeadbeef'},
documentLoaderURL: 'http://example.com'
});
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
cat: 'loading',
title: 'firstMeaningfulPaintCandidate',
@@ -351,6 +400,13 @@ tr.b.unittest.testSuite(function() {
frame: {id_ref: '0xdeadbeef'},
documentLoaderURL: 'http://example.com'
});
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
cat: 'loading',
title: 'firstMeaningfulPaintCandidate',
@@ -407,6 +463,13 @@ tr.b.unittest.testSuite(function() {
frame: {id_ref: '0xdeadbeef'},
documentLoaderURL: 'http://example.com'
});
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
cat: 'loading',
@@ -499,6 +562,13 @@ tr.b.unittest.testSuite(function() {
frame: {id_ref: '0xdeadbeef'},
documentLoaderURL: 'http://example.com'
});
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
cat: 'loading',
title: 'firstMeaningfulPaintCandidate',
@@ -592,6 +662,13 @@ tr.b.unittest.testSuite(function() {
frame: {id_ref: '0xdeadbeef'},
documentLoaderURL: 'http://example.com'
});
+ rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
cat: 'loading,rail,devtools.timeline',
title: 'firstContentfulPaint',
@@ -715,5 +792,175 @@ tr.b.unittest.testSuite(function() {
[netEvent1, netEvent2],
partialNetworkEvents);
});
+
+ test('MainFrameHelper_isMainFrame_inLiveRange', function() {
+ // The FrameLoader loads a frame 0xdeadbeef at 300ms.
+ // The frame 0xdeadbeef is marked as the main frame at 300ms.
+ // The isMainFrame('0xdeadbeef', 300) check is expected to succeed.
+ const model = tr.c.TestUtils.newModel(function(model) {
+ const process = model.getOrCreateProcess(1);
+ const rendererThread = process.getOrCreateThread(2);
+ rendererThread.name = 'CrRendererMain';
+ process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
+ {
+ isLoadingMainFrame: true,
+ frame: {id_ref: '0xdeadbeef'},
+ documentLoaderURL: 'http://example.com'
+ });
+ rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
+ });
+ const rendererHelper = model.getOrCreateHelper(
+ tr.model.helpers.ChromeModelHelper).rendererHelpers[1];
+ const mainFrameHelper = new tr.metrics.sh.MainFrameHelper(rendererHelper);
+ assert(mainFrameHelper.isMainFrame('0xdeadbeef', 300));
+ });
+
+ test('MainFrameHelper_isMainFrame_outsideLiveRange', function() {
+ // The FrameLoader loads a frame 0xdeadbeef at 300ms.
+ // The frame 0xdeadbeef is marked as the main frame at 300ms.
+ // The isMainFrame('0xdeadbeef', 500) check is expected to fail.
+ const model = tr.c.TestUtils.newModel(function(model) {
+ const process = model.getOrCreateProcess(1);
+ const rendererThread = process.getOrCreateThread(2);
+ rendererThread.name = 'CrRendererMain';
+ process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
+ {
+ isLoadingMainFrame: true,
+ frame: {id_ref: '0xdeadbeef'},
+ documentLoaderURL: 'http://example.com'
+ });
+ rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
+ });
+ const rendererHelper = model.getOrCreateHelper(
+ tr.model.helpers.ChromeModelHelper).rendererHelpers[1];
+ const mainFrameHelper = new tr.metrics.sh.MainFrameHelper(rendererHelper);
+ assert.isFalse(mainFrameHelper.isMainFrame('0xdeadbeef', 500));
+ });
+
+ test('MainFrameHelper_isMainFrame_pluginFrame', function() {
+ // The FrameLoader loads a plugin frame 0xdeadbeef at 300ms.
+ // The frame 0xdeadbeef is marked as the main frame at 300ms.
+ // The isMainFrame('0xdeadbeef', 300) check is expected to fail because the
+ // frame is a plugin frame.
+ const model = tr.c.TestUtils.newModel(function(model) {
+ const process = model.getOrCreateProcess(1);
+ const rendererThread = process.getOrCreateThread(2);
+ rendererThread.name = 'CrRendererMain';
+ process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
+ {
+ isLoadingMainFrame: true,
+ frame: {id_ref: '0xdeadbeef'},
+ documentLoaderURL: 'data:text/html,pluginplaceholderdata'
+ });
+ rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
+ });
+ const rendererHelper = model.getOrCreateHelper(
+ tr.model.helpers.ChromeModelHelper).rendererHelpers[1];
+ const mainFrameHelper = new tr.metrics.sh.MainFrameHelper(rendererHelper);
+ assert.isFalse(mainFrameHelper.isMainFrame('0xdeadbeef', 300));
+ });
+
+ test('MainFrameHelper_isMainFrame_unmarked', function() {
+ // The FrameLoader loads a frame 0xdeadbeef at 300ms.
+ // A frame 0x00000000 is marked as the main frame at 300ms.
+ // The isMainFrame('0xdeadbeef', 300) check is expected to fail.
+ const model = tr.c.TestUtils.newModel(function(model) {
+ const process = model.getOrCreateProcess(1);
+ const rendererThread = process.getOrCreateThread(2);
+ rendererThread.name = 'CrRendererMain';
+ process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
+ {
+ isLoadingMainFrame: true,
+ frame: {id_ref: '0xdeadbeef'},
+ documentLoaderURL: 'http://example.com'
+ });
+ rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0x00000000'}
+ }));
+ });
+ const rendererHelper = model.getOrCreateHelper(
+ tr.model.helpers.ChromeModelHelper).rendererHelpers[1];
+ const mainFrameHelper = new tr.metrics.sh.MainFrameHelper(rendererHelper);
+ assert.isFalse(mainFrameHelper.isMainFrame('0xdeadbeef', 300));
+ });
+
+ test('MainFrameHelper_getURL', function() {
+ // The FrameLoader loads http://example.com to frame 0xdeadbeef at 300ms.
+ // The frame 0xdeadbeef is marked as the main frame at 300ms.
+ // getURL('0xdeadbeef', 300) is expected to return http://example.com.
+ const model = tr.c.TestUtils.newModel(function(model) {
+ const process = model.getOrCreateProcess(1);
+ const rendererThread = process.getOrCreateThread(2);
+ rendererThread.name = 'CrRendererMain';
+ process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
+ {
+ isLoadingMainFrame: true,
+ frame: {id_ref: '0xdeadbeef'},
+ documentLoaderURL: 'http://example.com'
+ });
+ rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
+ });
+ const rendererHelper = model.getOrCreateHelper(
+ tr.model.helpers.ChromeModelHelper).rendererHelpers[1];
+ const mainFrameHelper = new tr.metrics.sh.MainFrameHelper(rendererHelper);
+ assert.strictEqual(mainFrameHelper.getURL('0xdeadbeef', 300),
+ 'http://example.com');
+ });
+
+ test('MainFrameHelper_getURL_undefined', function() {
+ // The FrameLoader loads http://example.com to frame 0xdeadbeef at 300ms.
+ // The frame 0xdeadbeef is marked as the main frame at 300ms.
+ // getURL('0x00000000', 300) is expected to return the undefined value.
+ const model = tr.c.TestUtils.newModel(function(model) {
+ const process = model.getOrCreateProcess(1);
+ const rendererThread = process.getOrCreateThread(2);
+ rendererThread.name = 'CrRendererMain';
+ process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
+ {
+ isLoadingMainFrame: true,
+ frame: {id_ref: '0xdeadbeef'},
+ documentLoaderURL: 'http://example.com'
+ });
+ rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'loading',
+ title: 'markAsMainFrame',
+ start: 300,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
+ });
+ const rendererHelper = model.getOrCreateHelper(
+ tr.model.helpers.ChromeModelHelper).rendererHelpers[1];
+ const mainFrameHelper = new tr.metrics.sh.MainFrameHelper(rendererHelper);
+ assert.strictEqual(mainFrameHelper.getURL('0x00000000', 300), undefined);
+ });
});
</script>

Powered by Google App Engine
This is Rietveld 408576698