/* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; requestLongerTimeout(2); // Test a few static pages using webcomponents and check that they are displayed as // expected in the markup view. const TEST_DATA = [ { // Test that expanding a shadow host shows a shadow root node and direct children. // Test that expanding a shadow root shows the shadow dom. // Test that slotted elements are visible in the shadow dom. title: "generic shadow dom test", url: `data:text/html;charset=utf-8,
slotted-1
inner
slotted-2
inner
no-slot-text
inner
`, tree: ` test-component #shadow-root name="slot1" div!slotted name="slot2" div!slotted slot div!slotted slot="slot1" slotted-1 inner slot="slot2" slotted-2 inner class="no-slot-class" no-slot-text inner`, }, { // Test that components without any direct children still display a shadow root node, // if a shadow root is attached to the host. title: "shadow root without direct children", url: `data:text/html;charset=utf-8, `, tree: ` test-component #shadow-root slot fallback-content`, }, { // Test that markup view is correctly displayed for non-trivial shadow DOM nesting. title: "nested components", url: `data:text/html;charset=utf-8,
slot1-1
`, tree: ` test-component #shadow-root test-container slot div!slotted slot third-component!slotted other-component #shadow-root div slot div!slotted div div third-component #shadow-root div`, }, { // Test that ::before and ::after pseudo elements are correctly displayed in host // components and in slot elements. title: "pseudo elements", url: `data:text/html;charset=utf-8,
`, tree: ` test-component #shadow-root style slot { display: block } slot ::before div!slotted default content ::after ::before class="light-dom" ::after`, }, { // Test empty web components are still displayed correctly. title: "empty components", url: `data:text/html;charset=utf-8, `, tree: ` test-component #shadow-root`, }, { // Test shadow hosts show their shadow root even if they contain just a short text. title: "shadow host with inline-text-child", url: `data:text/html;charset=utf-8, short-text-outside `, tree: ` test-component #shadow-root div slot inner-component!slotted inner-component #shadow-root short-text-inside short-text-outside`, }, { // Test for Bug 1537877, crash with nested custom elements without slot. title: "nested components without slot", url: `data:text/html;charset=utf-8, `, tree: ` test-component #shadow-root div inner-component #shadow-root inner-component-content`, }, ]; for (const { url, tree, title } of TEST_DATA) { // Test each configuration in both open and closed modes add_task(async function () { info(`Testing: [${title}] in OPEN mode`); const { inspector, tab } = await openInspectorForURL( url.replace(/#MODE#/g, "open") ); await assertMarkupViewAsTree(tree, "test-component", inspector); await removeTab(tab); }); add_task(async function () { info(`Testing: [${title}] in CLOSED mode`); const { inspector, tab } = await openInspectorForURL( url.replace(/#MODE#/g, "closed") ); await assertMarkupViewAsTree(tree, "test-component", inspector); await removeTab(tab); }); }