blob: bf8561b2d8c149a78dd849586396e9f60dfe41c1 [file] [edit]
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {assert} from 'chai';
import {describe, it} from '../conductor/mocha-interface.js';
import {
expandSelectedNodeRecursively,
getDisplayedCSSDeclarations,
waitForAndClickTreeElementWithPartialText,
waitForChildrenOfSelectedElementNode,
waitForCSSPropertyValue,
waitForElementsStyleSection,
waitForElementWithPartialText,
waitForPartialContentOfSelectedElementsNode,
} from '../helpers/elements-helpers.js';
describe('The Elements tab', () => {
it('shows OOPIF frame error inline', async ({devToolsPage, inspectedPage}) => {
await inspectedPage.goToResource('elements/page-error.html');
await waitForElementsStyleSection(devToolsPage, null);
await expandSelectedNodeRecursively(devToolsPage);
await waitForElementWithPartialText(devToolsPage, '<iframe src=');
await waitForElementWithPartialText(devToolsPage, '404 - File not found');
});
it('inspects style properties of elements in cross-domain iframes', async ({devToolsPage, inspectedPage}) => {
await inspectedPage.goToResource('elements/page-with-oopif.html', {waitUntil: 'networkidle0'});
const frame = await inspectedPage.page.waitForFrame(frame => frame.url().includes('devtools.oopif.test'));
await frame.waitForSelector('body');
await frame.evaluate(() => {
document.body.id = 'iframe-body';
document.body.setAttribute('style', 'background:green;');
});
await waitForElementsStyleSection(devToolsPage, null);
await expandSelectedNodeRecursively(devToolsPage);
await waitForElementWithPartialText(devToolsPage, 'devtools.oopif.test');
await waitForAndClickTreeElementWithPartialText(devToolsPage, '#document');
await waitForPartialContentOfSelectedElementsNode(devToolsPage, '#document');
// #document cannot be expanded via expandSelectedNodeRecursively. Using keyboard nav as a workaround.
await devToolsPage.click('.selected[role="treeitem"]', {clickOptions: {count: 2}});
await waitForChildrenOfSelectedElementNode(devToolsPage);
await devToolsPage.pressKey('ArrowDown');
await devToolsPage.pressKey('ArrowDown');
await devToolsPage.pressKey('ArrowDown');
await expandSelectedNodeRecursively(devToolsPage);
await waitForAndClickTreeElementWithPartialText(devToolsPage, 'id=\u200B"iframe-body"');
await waitForPartialContentOfSelectedElementsNode(devToolsPage, 'iframe-body');
await waitForCSSPropertyValue(devToolsPage, 'element.style', 'background', 'green', undefined);
const declarations = await getDisplayedCSSDeclarations(devToolsPage);
assert.include(declarations, 'background: green;');
});
});