From 00f662531e0a1b070776edd1e8368c9da3980527 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 2 Jun 2023 23:25:55 +0200 Subject: [PATCH] Revert "fix(tracing): workaround chromium scrollTop slowness" (#23486) This commit reverts f6712ec43ae7b5f049311d72372dfd676546e968 I manually ran https://github.com/microsoft/playwright/issues/14037#issuecomment-1122256514 and made sure that the performance did not regress. ~same. Fixes https://github.com/microsoft/playwright/issues/23455 --- .../trace/recorder/snapshotterInjected.ts | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/packages/playwright-core/src/server/trace/recorder/snapshotterInjected.ts b/packages/playwright-core/src/server/trace/recorder/snapshotterInjected.ts index ce64da0775..ae8e3de5d5 100644 --- a/packages/playwright-core/src/server/trace/recorder/snapshotterInjected.ts +++ b/packages/playwright-core/src/server/trace/recorder/snapshotterInjected.ts @@ -311,28 +311,6 @@ export function frameSnapshotStreamer(snapshotStreamer: string) { // Ensure we are up to date. this._handleMutations(this._observer.takeRecords()); - // Restore scroll positions for all ancestors of action target elements - // that will show the highlight/red dot in the trace viewer. - // Workaround for chromium regression: - // https://bugs.chromium.org/p/chromium/issues/detail?id=1324419 - // https://github.com/microsoft/playwright/issues/14037 - // TODO: remove after chromium is fixed? - const elementsToRestoreScrollPosition = new Set(); - const findElementsToRestoreScrollPositionRecursively = (element: Element) => { - let shouldAdd = '__playwright_target__' in element; - for (let child = element.firstElementChild; child; child = child.nextElementSibling) - shouldAdd = shouldAdd || findElementsToRestoreScrollPositionRecursively(child); - if (element.shadowRoot) { - for (let child = element.shadowRoot.firstElementChild; child; child = child.nextElementSibling) - shouldAdd = shouldAdd || findElementsToRestoreScrollPositionRecursively(child); - } - if (shouldAdd) - elementsToRestoreScrollPosition.add(element); - return shouldAdd; - }; - if (document.documentElement) - findElementsToRestoreScrollPositionRecursively(document.documentElement); - const definedCustomElements = new Set(); const visitNode = (node: Node | ShadowRoot): { equals: boolean, n: NodeSnapshot } | undefined => { @@ -444,12 +422,12 @@ export function frameSnapshotStreamer(snapshotStreamer: string) { expectValue(value); attrs[kSelectedAttribute] = value; } - if (elementsToRestoreScrollPosition.has(element) && element.scrollTop) { + if (element.scrollTop) { expectValue(kScrollTopAttribute); expectValue(element.scrollTop); attrs[kScrollTopAttribute] = '' + element.scrollTop; } - if (elementsToRestoreScrollPosition.has(element) && element.scrollLeft) { + if (element.scrollLeft) { expectValue(kScrollLeftAttribute); expectValue(element.scrollLeft); attrs[kScrollLeftAttribute] = '' + element.scrollLeft;