/* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; // Test that the inspector is correctly updated when shadow roots are attached to // components after displaying them in the markup view. const TEST_URL = `data:text/html;charset=utf-8,` + encodeURIComponent(`
slot1-1
slot1-2
inline text
`); add_task(async function () { const { inspector } = await openInspectorForURL(TEST_URL); const tree = ` div test-component slot1-1 slot1-2 inline text`; await assertMarkupViewAsTree(tree, "#root", inspector); info("Attach a shadow root to test-component"); let mutated = waitForMutation(inspector, "shadowRootAttached"); SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () { content.wrappedJSObject.attachTestComponent(); }); await mutated; const treeAfterTestAttach = ` div test-component #shadow-root slot1-container slot div!slotted div!slotted other-component slot2-1 slot1-1 slot1-2 inline text`; await assertMarkupViewAsTree(treeAfterTestAttach, "#root", inspector); info("Attach a shadow root to other-component, nested in test-component"); mutated = waitForMutation(inspector, "shadowRootAttached"); SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () { content.wrappedJSObject.attachOtherComponent(); }); await mutated; const treeAfterOtherAttach = ` div test-component #shadow-root slot1-container slot div!slotted div!slotted other-component #shadow-root slot2-container slot div!slotted some-other-node slot2-1 slot1-1 slot1-2 inline text`; await assertMarkupViewAsTree(treeAfterOtherAttach, "#root", inspector); info( "Attach a shadow root to inline-component, check the inline text child." ); mutated = waitForMutation(inspector, "shadowRootAttached"); SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () { content.wrappedJSObject.attachInlineComponent(); }); await mutated; const treeAfterInlineAttach = ` div test-component #shadow-root slot1-container slot div!slotted div!slotted other-component #shadow-root slot2-container slot div!slotted some-other-node slot2-1 slot1-1 slot1-2 inline-component #shadow-root inline-component-content some-inline-content inline text`; await assertMarkupViewAsTree(treeAfterInlineAttach, "#root", inspector); });