using a simple
// querySelector. However the click is simulated in the middle of the
// component, and will always hit the test which takes all the space.
const newInspector = await clickOnInspectMenuItem("test-outer");
info("Check again that the markup view is displayed as expected");
await assertMarkupView(newInspector);
});
async function assertMarkupView(inspector) {
const outerFront = await getNodeFront("test-outer", inspector);
const outerContainer = inspector.markup.getContainer(outerFront);
assertContainer(outerContainer, {
expanded: true,
text: "test-outer",
children: 1,
});
const outerShadowContainer = outerContainer.getChildContainers()[0];
assertContainer(outerShadowContainer, {
expanded: true,
text: "#shadow-root",
children: 1,
});
const innerContainer = outerShadowContainer.getChildContainers()[0];
assertContainer(innerContainer, {
expanded: true,
text: "test-inner",
children: 2,
});
const innerShadowContainer = innerContainer.getChildContainers()[0];
const imageContainer = innerContainer.getChildContainers()[1];
assertContainer(innerShadowContainer, {
expanded: false,
text: "#shadow-root",
});
assertContainer(imageContainer, {
expanded: true,
text: "test-image",
children: 1,
});
const imageShadowContainer = imageContainer.getChildContainers()[0];
assertContainer(imageShadowContainer, {
expanded: true,
text: "#shadow-root",
children: 1,
});
const redDivContainer = imageShadowContainer.getChildContainers()[0];
assertContainer(redDivContainer, { expanded: false, text: "div" });
is(redDivContainer.selected, true, "Div element is selected as expected");
}
/**
* Check if the provided markup container is expanded, has the expected text and the
* expected number of children.
*/
function assertContainer(container, { expanded, text, children }) {
is(container.expanded, expanded, "Container is expanded");
assertContainerHasText(container, text);
if (expanded) {
const childContainers = container.getChildContainers();
is(
childContainers.length,
children,
"Container has expected number of children"
);
}
}