Skip to content

Commit 56c8862

Browse files
danilsomsikovDevtools-frontend LUCI CQ
authored andcommitted
Don't record another repeated impressions of the same non-DOM loggable
Bug: 477550607 Change-Id: I7e7ab03f6856ee96e608466847d405d51571b640 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7499829 Auto-Submit: Danil Somsikov <dsv@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org> Commit-Queue: Danil Somsikov <dsv@chromium.org>
1 parent daa3291 commit 56c8862

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

front_end/ui/visual_logging/LoggingDriver.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,4 +1067,20 @@ describe('LoggingDriver', () => {
10671067
VisualLoggingTesting.NonDomState.getNonDomLoggables(parent),
10681068
{loggable, config: {ve: 1, context: '123'}, parent, size: undefined});
10691069
});
1070+
1071+
it('does not log a non-DOM impression twice for the same loggable', async () => {
1072+
addLoggableElements();
1073+
const loggable = {};
1074+
const parent = document.getElementById('parent')!;
1075+
VisualLoggingTesting.NonDomState.registerLoggable(loggable, {ve: 1, context: '123'}, parent);
1076+
VisualLoggingTesting.NonDomState.registerLoggable(loggable, {ve: 1, context: '123'}, parent);
1077+
await VisualLoggingTesting.LoggingDriver.startLogging();
1078+
sinon.assert.calledOnce(recordImpression);
1079+
1080+
assert.sameDeepMembers(recordImpression.firstCall.firstArg.impressions, [
1081+
{id: getVeId(loggable), type: 1, context: 123, parent: getVeId(parent), width: 0, height: 0},
1082+
{id: getVeId('#element'), type: 1, context: 42, parent: getVeId(parent), width: 300, height: 300},
1083+
{id: getVeId(parent), type: 1, width: 300, height: 300},
1084+
]);
1085+
});
10701086
});

front_end/ui/visual_logging/LoggingDriver.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ export async function process(): Promise<void> {
266266
const root = nonDomRoots[i];
267267
for (const {loggable, config, parent, size} of getNonDomLoggables(root)) {
268268
const loggingState = getOrCreateLoggingState(loggable, config, parent);
269+
if (loggingState.impressionLogged) {
270+
continue;
271+
}
269272
if (size) {
270273
loggingState.size = size;
271274
}

0 commit comments

Comments
 (0)