Skip to content

Commit 5b18425

Browse files
szuenddevtools-frontend-scoped@luci-project-accounts.iam.gserviceaccount.com
authored andcommitted
[e2e] Attempt to deflake style-pane-properties test
Two changes to make the handling more robust: 1) We wait for the 'load' event on the iframe before we add the styles to the iframe. 2) We repeatedly try to expand the DOM tree node until the iframe shows up on the DevTools side. R=alexrudenko@chromium.org No-Tree-Checks: True Bug: None Change-Id: I562483bc165910b5e9bf6fa51c658b9de8d4be3c Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7865928 Commit-Queue: Simon Zünd <szuend@chromium.org> Auto-Submit: Simon Zünd <szuend@chromium.org> Commit-Queue: Alex Rudenko <alexrudenko@chromium.org> Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
1 parent 881a52b commit 5b18425

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

test/e2e/elements/style-pane-properties.test.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type * as puppeteer from 'puppeteer-core';
88
import {expectError} from '../../conductor/events.js';
99
import {
1010
editQueryRuleText,
11+
elementWithPartialText,
1112
expandSelectedNodeRecursively,
1213
focusCSSPropertyValue,
1314
getComputedStylesForDomNode,
@@ -1279,23 +1280,30 @@ describe('The Styles pane', () => {
12791280
await goToResourceAndWaitForStyleSection('elements/css-inject-stylesheet.html', devToolsPage, inspectedPage);
12801281
await prepareElementsTab(devToolsPage);
12811282

1282-
await inspectedPage.evaluate(async () => {
1283+
await inspectedPage.evaluate(() => {
12831284
const iframe = document.createElement('iframe');
1284-
iframe.src = 'css-inject-stylesheet-iframe-data.html';
12851285
document.getElementById('main')?.appendChild(iframe);
1286-
});
12871286

1288-
await expandSelectedNodeRecursively(devToolsPage);
1289-
await inspectedPage.evaluate(async () => {
1290-
const iframe = document.querySelector('iframe');
1291-
if (!iframe?.contentDocument) {
1292-
return;
1293-
}
1294-
const style = iframe.contentDocument.createElement('style');
1295-
style.textContent = '#iframeBody { background: red }';
1296-
iframe.contentDocument.head.append(style);
1287+
const {promise, resolve} = Promise.withResolvers<void>();
1288+
iframe.addEventListener('load', () => {
1289+
if (!iframe.contentDocument) {
1290+
return;
1291+
}
1292+
const style = iframe.contentDocument.createElement('style');
1293+
style.textContent = '#iframeBody { background: red }';
1294+
iframe.contentDocument.head.append(style);
1295+
1296+
resolve();
1297+
});
1298+
1299+
iframe.src = 'css-inject-stylesheet-iframe-data.html';
1300+
return promise;
12971301
});
12981302

1303+
await devToolsPage.waitForFunction(async () => {
1304+
await expandSelectedNodeRecursively(devToolsPage);
1305+
return await elementWithPartialText('id=\u200B"iframeBody"', devToolsPage);
1306+
});
12991307
await waitForAndClickTreeElementWithPartialText('id=\u200B"iframeBody"', devToolsPage);
13001308
await waitForStyleRule('#iframeBody', devToolsPage);
13011309
const inspectedRulesAfter = await getDisplayedStyleRulesCompact(devToolsPage);

0 commit comments

Comments
 (0)