Bug 1078374 - Rename helper_shadowdom to helper_assert_tree;r=bgrins draft
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 21 Jun 2018 17:30:42 +0200
changeset 809498 42af079581844c46b7b65254a308e675ebe791b7
parent 809497 5c654b1879078c3be2c10e934cb66b10972e41be
push id113697
push userjdescottes@mozilla.com
push dateFri, 22 Jun 2018 09:09:11 +0000
reviewersbgrins
bugs1078374
milestone62.0a1
Bug 1078374 - Rename helper_shadowdom to helper_assert_tree;r=bgrins MozReview-Commit-ID: C3O5LjSfxqS
devtools/client/inspector/markup/test/browser.ini
devtools/client/inspector/markup/test/browser_markup_shadowdom.js
devtools/client/inspector/markup/test/browser_markup_shadowdom_clickreveal.js
devtools/client/inspector/markup/test/browser_markup_shadowdom_delete.js
devtools/client/inspector/markup/test/browser_markup_shadowdom_maxchildren.js
devtools/client/inspector/markup/test/browser_markup_shadowdom_mutations_shadow.js
devtools/client/inspector/markup/test/browser_markup_shadowdom_noslot.js
devtools/client/inspector/markup/test/browser_markup_shadowdom_slotupdate.js
devtools/client/inspector/markup/test/browser_markup_template.js
devtools/client/inspector/markup/test/head.js
devtools/client/inspector/markup/test/helper_assert_tree.js
devtools/client/inspector/markup/test/helper_shadowdom.js
--- a/devtools/client/inspector/markup/test/browser.ini
+++ b/devtools/client/inspector/markup/test/browser.ini
@@ -39,22 +39,22 @@ support-files =
   doc_markup_whitespace.html
   doc_markup_xul.xul
   doc_markup_update-on-navigtion_1.html
   doc_markup_update-on-navigtion_2.html
   events_bundle.js
   events_bundle.js.map
   events_original.js
   head.js
+  helper_assert_tree.js
   helper_attributes_test_runner.js
   helper_diff.js
   helper_events_test_runner.js
   helper_markup_accessibility_navigation.js
   helper_outerhtml_test_runner.js
-  helper_shadowdom.js
   helper_style_attr_test_runner.js
   lib_babel_6.21.0_min.js
   lib_jquery_1.0.js
   lib_jquery_1.1.js
   lib_jquery_1.2_min.js
   lib_jquery_1.3_min.js
   lib_jquery_1.4_min.js
   lib_jquery_1.6_min.js
--- a/devtools/client/inspector/markup/test/browser_markup_shadowdom.js
+++ b/devtools/client/inspector/markup/test/browser_markup_shadowdom.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/ */
 
-/* import-globals-from helper_shadowdom.js */
+/* import-globals-from helper_assert_tree.js */
 
 "use strict";
 
-loadHelperScript("helper_shadowdom.js");
+loadHelperScript("helper_assert_tree.js");
 
 // Test a few static pages using webcomponents and check that they are displayed as
 // expected in the markup view.
 
 add_task(async function() {
   await enableWebComponents();
 
   // Test that expanding a shadow host shows a shadow root node and direct host children.
@@ -55,17 +55,17 @@ add_task(async function() {
       slot="slot2"
         slotted-2
         inner
       class="no-slot-class"
         no-slot-text
         inner`;
 
   const {inspector} = await openInspectorForURL(TEST_URL);
-  await checkTreeFromRootSelector(EXPECTED_TREE, "test-component", inspector);
+  await assertMarkupViewAsTree(EXPECTED_TREE, "test-component", inspector);
 });
 
 add_task(async function() {
   await enableWebComponents();
 
   // Test that components without any direct children still display a shadow root node, if
   // a shadow root is attached to the host.
 
@@ -84,17 +84,17 @@ add_task(async function() {
 
   const EXPECTED_TREE = `
     test-component
       #shadow-root
         slot
           fallback-content`;
 
   const {inspector} = await openInspectorForURL(TEST_URL);
-  await checkTreeFromRootSelector(EXPECTED_TREE, "test-component", inspector);
+  await assertMarkupViewAsTree(EXPECTED_TREE, "test-component", inspector);
 });
 
 add_task(async function() {
   await enableWebComponents();
 
   // Test that the markup view is correctly displayed for non-trivial shadow DOM nesting.
 
   const TEST_URL = `data:text/html;charset=utf-8,
@@ -144,17 +144,17 @@ add_task(async function() {
                   div!slotted
             div
       div
       third-component
         #shadow-root
           div`;
 
   const {inspector} = await openInspectorForURL(TEST_URL);
-  await checkTreeFromRootSelector(EXPECTED_TREE, "test-component", inspector);
+  await assertMarkupViewAsTree(EXPECTED_TREE, "test-component", inspector);
 });
 
 add_task(async function() {
   await enableWebComponents();
 
   // Test that ::before and ::after pseudo elements are correctly displayed in host
   // components and in slot elements.
 
@@ -195,17 +195,17 @@ add_task(async function() {
           ::before
           div!slotted
           ::after
       ::before
       class="light-dom"
       ::after`;
 
   const {inspector} = await openInspectorForURL(TEST_URL);
-  await checkTreeFromRootSelector(EXPECTED_TREE, "test-component", inspector);
+  await assertMarkupViewAsTree(EXPECTED_TREE, "test-component", inspector);
 });
 
 add_task(async function() {
   await enableWebComponents();
 
   // Test empty web components are still displayed correctly.
 
   const TEST_URL = `data:text/html;charset=utf-8,
@@ -222,10 +222,10 @@ add_task(async function() {
       });
     </script>`;
 
   const EXPECTED_TREE = `
     test-component
       #shadow-root`;
 
   const {inspector} = await openInspectorForURL(TEST_URL);
-  await checkTreeFromRootSelector(EXPECTED_TREE, "test-component", inspector);
+  await assertMarkupViewAsTree(EXPECTED_TREE, "test-component", inspector);
 });
--- a/devtools/client/inspector/markup/test/browser_markup_shadowdom_clickreveal.js
+++ b/devtools/client/inspector/markup/test/browser_markup_shadowdom_clickreveal.js
@@ -1,18 +1,14 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/ */
 
-/* import-globals-from helper_shadowdom.js */
-
 "use strict";
 
-loadHelperScript("helper_shadowdom.js");
-
 // Test that the corresponding non-slotted node container gets selected when clicking on
 // the reveal link for a slotted node.
 
 const TEST_URL = `data:text/html;charset=utf-8,
   <test-component>
     <div slot="slot1" id="el1">slot1-1</div>
     <div slot="slot1" id="el2">slot1-2</div>
   </test-component>
--- a/devtools/client/inspector/markup/test/browser_markup_shadowdom_delete.js
+++ b/devtools/client/inspector/markup/test/browser_markup_shadowdom_delete.js
@@ -1,18 +1,14 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/ */
 
-/* import-globals-from helper_shadowdom.js */
-
 "use strict";
 
-loadHelperScript("helper_shadowdom.js");
-
 // Test that slot elements are correctly updated when slotted elements are being removed
 // from the DOM.
 
 const TEST_URL = `data:text/html;charset=utf-8,
   <test-component>
     <div slot="slot1" id="el1">slot1-1</div>
     <div slot="slot1" id="el2">slot1-2</div>
   </test-component>
@@ -40,40 +36,40 @@ add_task(async function() {
   await waitForMultipleChildrenUpdates(inspector);
 
   info("Test that expanding a shadow host shows shadow root and direct host children.");
   const {markup} = inspector;
   const hostContainer = markup.getContainer(hostFront);
   const childContainers = hostContainer.getChildContainers();
 
   is(childContainers.length, 3, "Expecting 3 children: shadowroot, 2 host children");
-  checkText(childContainers[0], "#shadow-root");
-  checkText(childContainers[1], "div");
-  checkText(childContainers[2], "div");
+  assertContainerHasText(childContainers[0], "#shadow-root");
+  assertContainerHasText(childContainers[1], "div");
+  assertContainerHasText(childContainers[2], "div");
 
   info("Expand the shadow root");
   const shadowRootContainer = childContainers[0];
   await expandContainer(inspector, shadowRootContainer);
 
   const shadowChildContainers = shadowRootContainer.getChildContainers();
   is(shadowChildContainers.length, 1, "Expecting 1 child slot");
-  checkText(shadowChildContainers[0], "slot");
+  assertContainerHasText(shadowChildContainers[0], "slot");
 
   info("Expand the slot");
   const slotContainer = shadowChildContainers[0];
   await expandContainer(inspector, slotContainer);
 
   let slotChildContainers = slotContainer.getChildContainers();
   is(slotChildContainers.length, 2, "Expecting 2 slotted children");
-  slotChildContainers.forEach(container => checkSlotted(container));
+  slotChildContainers.forEach(container => assertContainerSlotted(container));
 
   await deleteNode(inspector, "#el1");
   slotChildContainers = slotContainer.getChildContainers();
   is(slotChildContainers.length, 1, "Expecting 1 slotted child");
-  checkSlotted(slotChildContainers[0]);
+  assertContainerSlotted(slotChildContainers[0]);
 
   await deleteNode(inspector, "#el2");
   slotChildContainers = slotContainer.getChildContainers();
   // After deleting the last host direct child we expect the slot to show the default
   // content <div>default</div>
   is(slotChildContainers.length, 1, "Expecting 1 child");
   ok(!slotChildContainers[0].isSlotted(), "Container is a not slotted container");
 });
--- a/devtools/client/inspector/markup/test/browser_markup_shadowdom_maxchildren.js
+++ b/devtools/client/inspector/markup/test/browser_markup_shadowdom_maxchildren.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/ */
 
-/* import-globals-from helper_shadowdom.js */
+/* import-globals-from helper_assert_tree.js */
 
 "use strict";
 
-loadHelperScript("helper_shadowdom.js");
+loadHelperScript("helper_assert_tree.js");
 
 // Test that the markup view properly displays the "more nodes" button both for host
 // elements and for slot elements.
 
 const TEST_URL = `data:text/html;charset=utf-8,
 <test-component>
   <div>node 1</div><div>node 2</div><div>node 3</div>
   <div>node 4</div><div>node 5</div><div>node 6</div>
@@ -43,61 +43,61 @@ add_task(async function() {
   await waitForMultipleChildrenUpdates(inspector);
 
   info("Test that expanding a shadow host shows shadow root and direct host children.");
   const {markup} = inspector;
   const hostContainer = markup.getContainer(hostFront);
   let childContainers = hostContainer.getChildContainers();
 
   is(childContainers.length, 6, "Expecting 6 children: shadowroot, 5 host children");
-  checkText(childContainers[0], "#shadow-root");
+  assertContainerHasText(childContainers[0], "#shadow-root");
   for (let i = 1; i < 6; i++) {
-    checkText(childContainers[i], "div");
-    checkText(childContainers[i], "node " + i);
+    assertContainerHasText(childContainers[i], "div");
+    assertContainerHasText(childContainers[i], "node " + i);
   }
 
   info("Click on the more nodes button under the host element");
   let moreNodesLink = hostContainer.elt.querySelector(".more-nodes");
   ok(!!moreNodesLink, "A 'more nodes' button is displayed in the host container");
   moreNodesLink.querySelector("button").click();
   await inspector.markup._waitForChildren();
 
   childContainers = hostContainer.getChildContainers();
   is(childContainers.length, 7, "Expecting one additional host child");
-  checkText(childContainers[6], "div");
-  checkText(childContainers[6], "node 6");
+  assertContainerHasText(childContainers[6], "div");
+  assertContainerHasText(childContainers[6], "node 6");
 
   info("Expand the shadow root");
   const shadowRootContainer = childContainers[0];
   const shadowRootFront = shadowRootContainer.node;
   await inspector.markup.expandNode(shadowRootFront);
   await waitForMultipleChildrenUpdates(inspector);
 
   const shadowChildContainers = shadowRootContainer.getChildContainers();
   is(shadowChildContainers.length, 1, "Expecting 1 slot child");
-  checkText(shadowChildContainers[0], "slot");
+  assertContainerHasText(shadowChildContainers[0], "slot");
 
   info("Expand the slot");
   const slotContainer = shadowChildContainers[0];
   const slotFront = slotContainer.node;
   await inspector.markup.expandNode(slotFront);
   await waitForMultipleChildrenUpdates(inspector);
 
   let slotChildContainers = slotContainer.getChildContainers();
   is(slotChildContainers.length, 5, "Expecting 5 slotted children");
   for (const slotChildContainer of slotChildContainers) {
-    checkText(slotChildContainer, "div");
+    assertContainerHasText(slotChildContainer, "div");
     ok(slotChildContainer.elt.querySelector(".reveal-link"),
       "Slotted container has a reveal link element");
   }
 
   info("Click on the more nodes button under the slot element");
   moreNodesLink = slotContainer.elt.querySelector(".more-nodes");
   ok(!!moreNodesLink, "A 'more nodes' button is displayed in the host container");
   EventUtils.sendMouseEvent({type: "click"}, moreNodesLink.querySelector("button"));
   await inspector.markup._waitForChildren();
 
   slotChildContainers = slotContainer.getChildContainers();
   is(slotChildContainers.length, 6, "Expecting one additional slotted element");
-  checkText(slotChildContainers[5], "div");
+  assertContainerHasText(slotChildContainers[5], "div");
   ok(slotChildContainers[5].elt.querySelector(".reveal-link"),
     "Slotted container has a reveal link element");
 });
--- a/devtools/client/inspector/markup/test/browser_markup_shadowdom_mutations_shadow.js
+++ b/devtools/client/inspector/markup/test/browser_markup_shadowdom_mutations_shadow.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/ */
 
-/* import-globals-from helper_shadowdom.js */
+/* import-globals-from helper_assert_tree.js */
 
 "use strict";
 
-loadHelperScript("helper_shadowdom.js");
+loadHelperScript("helper_assert_tree.js");
 
 // Test that the markup view is correctly updated when elements under a shadow root are
 // deleted or updated.
 
 const TEST_URL = `data:text/html;charset=utf-8,
   <test-component>
     <div slot="slot1" id="el1">slot1-1</div>
     <div slot="slot1" id="el2">slot1-2</div>
@@ -41,44 +41,44 @@ add_task(async function() {
       #shadow-root
         slot1-container
           slot
             div!slotted
             div!slotted
         another-div
       div
       div`;
-  await checkTreeFromRootSelector(tree, "test-component", inspector);
+  await assertMarkupViewAsTree(tree, "test-component", inspector);
 
   info("Delete a shadow dom element and check the updated markup view");
   let mutated = waitForMutation(inspector, "childList");
   ContentTask.spawn(gBrowser.selectedBrowser, {}, function() {
     const shadowRoot = content.document.querySelector("test-component").shadowRoot;
     const slotContainer = shadowRoot.getElementById("slot1-container");
     slotContainer.remove();
   });
   await mutated;
 
   const treeAfterDelete = `
     test-component
       #shadow-root
         another-div
       div
       div`;
-  await checkTreeFromRootSelector(treeAfterDelete, "test-component", inspector);
+  await assertMarkupViewAsTree(treeAfterDelete, "test-component", inspector);
 
   mutated = inspector.once("markupmutation");
   ContentTask.spawn(gBrowser.selectedBrowser, {}, function() {
     const shadowRoot = content.document.querySelector("test-component").shadowRoot;
     const shadowDiv = shadowRoot.getElementById("another-div");
     shadowDiv.setAttribute("random-attribute", "1");
   });
   await mutated;
 
   info("Add an attribute on a shadow dom element and check the updated markup view");
   const treeAfterAttrChange = `
     test-component
       #shadow-root
         random-attribute
       div
       div`;
-  await checkTreeFromRootSelector(treeAfterAttrChange, "test-component", inspector);
+  await assertMarkupViewAsTree(treeAfterAttrChange, "test-component", inspector);
 });
--- a/devtools/client/inspector/markup/test/browser_markup_shadowdom_noslot.js
+++ b/devtools/client/inspector/markup/test/browser_markup_shadowdom_noslot.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/ */
 
-/* import-globals-from helper_shadowdom.js */
+/* import-globals-from helper_assert_tree.js */
 
 "use strict";
 
-loadHelperScript("helper_shadowdom.js");
+loadHelperScript("helper_assert_tree.js");
 
 // Test that the markup view is correctly displayed when a component has children but no
 // slots are available under the shadow root.
 
 const TEST_URL = `data:text/html;charset=utf-8,
   <style>
     .has-before::before { content: "before-content" }
   </style>
@@ -69,17 +69,17 @@ add_task(async function() {
       #shadow-root
         slot
           div!slotted
           div!slotted
       class="not-nested"
       class="nested"
         class="has-before"
           ::before`;
-  await checkTreeFromRootSelector(beforeTree, ".root", inspector);
+  await assertMarkupViewAsTree(beforeTree, ".root", inspector);
 
   info("Move the non-slotted element with class has-before and check the pseudo appears");
   const mutated = waitForNMutations(inspector, "childList", 2);
   const pseudoMutated = waitForMutation(inspector, "nativeAnonymousChildList");
   ContentTask.spawn(gBrowser.selectedBrowser, {}, function() {
     const root = content.document.querySelector(".root");
     const hasBeforeEl = content.document.querySelector("no-slot-component .has-before");
     root.appendChild(hasBeforeEl);
@@ -103,10 +103,10 @@ add_task(async function() {
             div!slotted
             div!slotted
         class="not-nested"
         class="nested"
           class="has-before"
             ::before
       class="has-before"
         ::before`;
-  await checkTreeFromRootSelector(afterTree, ".root", inspector);
+  await assertMarkupViewAsTree(afterTree, ".root", inspector);
 });
--- a/devtools/client/inspector/markup/test/browser_markup_shadowdom_slotupdate.js
+++ b/devtools/client/inspector/markup/test/browser_markup_shadowdom_slotupdate.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/ */
 
-/* import-globals-from helper_shadowdom.js */
+/* import-globals-from helper_assert_tree.js */
 
 "use strict";
 
-loadHelperScript("helper_shadowdom.js");
+loadHelperScript("helper_assert_tree.js");
 
 // Test that slotted elements are correctly updated when the slot attribute is modified
 // on already slotted elements.
 
 const TEST_URL = `data:text/html;charset=utf-8,
   <test-component>
     <div slot="slot1">slot1-1</div>
     <div slot="slot1">slot1-2</div>
@@ -43,17 +43,17 @@ add_task(async function() {
           div!slotted
         name="slot2"
           div!slotted
           div!slotted
       slot1-1
       slot1-2
       slot2-1
       slot2-2`;
-  await checkTreeFromRootSelector(tree, "test-component", inspector);
+  await assertMarkupViewAsTree(tree, "test-component", inspector);
 
   info("Listening for the markupmutation event");
   const mutated = inspector.once("markupmutation");
   ContentTask.spawn(gBrowser.selectedBrowser, {}, function() {
     content.document.getElementById("to-update").setAttribute("slot", "slot1");
   });
   await mutated;
 
@@ -66,10 +66,10 @@ add_task(async function() {
           div!slotted
           div!slotted
         name="slot2"
           div!slotted
       slot1-1
       slot1-2
       slot2-1
       slot2-2`;
-  await checkTreeFromRootSelector(mutatedTree, "test-component", inspector);
+  await assertMarkupViewAsTree(mutatedTree, "test-component", inspector);
 });
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/markup/test/browser_markup_template.js
@@ -0,0 +1,55 @@
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* import-globals-from helper_assert_tree.js */
+
+"use strict";
+
+// Import shadowdom helpers to reuse the markup view assertion utilities.
+loadHelperScript("helper_assert_tree.js");
+
+// Test the markup view displaying the content of a <template> tag.
+
+add_task(async function() {
+  const TEST_URL = `data:text/html;charset=utf-8,` + encodeURIComponent(`
+    <div id="root">
+      <template>
+        <p>template content</p>
+      </template>
+
+      <div id="template-container" style="border: 1px solid black"></div>
+    </div>
+    <script>
+      "use strict";
+
+      const template = document.querySelector("template");
+      const clone = document.importNode(template.content, true);
+      document.querySelector("#template-container").appendChild(clone);
+    </script>`);
+
+  const EXPECTED_TREE = `
+    root
+      template
+        #document-fragment
+          p
+      template-container
+        p`;
+
+  const {inspector} = await openInspectorForURL(TEST_URL);
+  const {markup} = inspector;
+
+  await assertMarkupViewAsTree(EXPECTED_TREE, "#root", inspector);
+
+  info("Select the p element under the template .");
+  const templateFront = await getNodeFront("template", inspector);
+  const templateContainer = markup.getContainer(templateFront);
+  const documentFragmentContainer = templateContainer.getChildContainers()[0];
+  const pContainer = documentFragmentContainer.getChildContainers()[0];
+
+  await selectNode(pContainer.node, inspector, "no-reason", false);
+
+  const ruleView = inspector.getPanel("ruleview").view;
+  is(ruleView.element.querySelectorAll("#ruleview-no-results").length, 1,
+    "No rules are displayed for this p element");
+});
--- a/devtools/client/inspector/markup/test/head.js
+++ b/devtools/client/inspector/markup/test/head.js
@@ -608,8 +608,34 @@ async function checkDeleteAndSelection(i
   let node = await getNodeFront(selector, inspector);
   ok(!node, "The node can't be found in the page anymore");
 
   info("Undo the deletion to restore the original markup");
   await undoChange(inspector);
   node = await getNodeFront(selector, inspector);
   ok(node, "The node is back");
 }
+
+/**
+ * Temporarily flip all the preferences needed to enable web components.
+ */
+async function enableWebComponents() {
+  await pushPref("dom.webcomponents.shadowdom.enabled", true);
+  await pushPref("dom.webcomponents.customelements.enabled", true);
+}
+
+/**
+ * Assert whether the provided container is slotted.
+ */
+function assertContainerSlotted(container) {
+  ok(container.isSlotted(), "Container is a slotted container");
+  ok(container.elt.querySelector(".reveal-link"),
+     "Slotted container has a reveal link element");
+}
+
+/**
+ * Check if the provided text can be matched anywhere in the text content for the provided
+ * container.
+ */
+function assertContainerHasText(container, expectedText) {
+  const textContent = container.elt.textContent;
+  ok(textContent.includes(expectedText), "Container has expected text: " + expectedText);
+}
rename from devtools/client/inspector/markup/test/helper_shadowdom.js
rename to devtools/client/inspector/markup/test/helper_assert_tree.js
--- a/devtools/client/inspector/markup/test/helper_shadowdom.js
+++ b/devtools/client/inspector/markup/test/helper_assert_tree.js
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* eslint no-unused-vars: [2, {"vars": "local"}] */
 
 /* import-globals-from head.js */
 
 "use strict";
 
-async function checkTreeFromRootSelector(tree, selector, inspector) {
+async function assertMarkupViewAsTree(tree, selector, inspector) {
   const {markup} = inspector;
 
   info(`Find and expand the shadow DOM host matching selector ${selector}.`);
   const rootFront = await getNodeFront(selector, inspector);
   const rootContainer = markup.getContainer(rootFront);
 
   const parsedTree = parseTree(tree);
   const treeRoot = parsedTree.children[0];
@@ -22,19 +22,21 @@ async function checkTreeFromRootSelector
 
 async function checkNode(treeNode, container, inspector) {
   const {node, children, path} = treeNode;
   info("Checking [" + path + "]");
   info("Checking node: " + node);
 
   const slotted = node.includes("!slotted");
   if (slotted) {
-    checkSlotted(container, node.replace("!slotted", ""));
+    const nodeName = node.replace("!slotted", "");
+    assertContainerHasText(container, nodeName);
+    assertContainerSlotted(container);
   } else {
-    checkText(container, node);
+    assertContainerHasText(container, node);
   }
 
   if (!children.length) {
     ok(!container.canExpand, "Container for [" + path + "] has no children");
     return;
   }
 
   // Expand the container if not already done.
@@ -97,28 +99,16 @@ function parseTree(inputString) {
 
     parent.children.push(node);
     currentNode = node;
   }
 
   return tree;
 }
 
-function checkSlotted(container, expectedType = "div") {
-  checkText(container, expectedType);
-  ok(container.isSlotted(), "Container is a slotted container");
-  ok(container.elt.querySelector(".reveal-link"),
-     "Slotted container has a reveal link element");
-}
-
-function checkText(container, expectedText) {
-  const textContent = container.elt.textContent;
-  ok(textContent.includes(expectedText), "Container has expected text: " + expectedText);
-}
-
 function waitForMutation(inspector, type) {
   return waitForNMutations(inspector, type, 1);
 }
 
 function waitForNMutations(inspector, type, count) {
   info(`Expecting ${count} markupmutation of type ${type}`);
   let receivedMutations = 0;
   return new Promise(resolve => {
@@ -127,16 +117,8 @@ function waitForNMutations(inspector, ty
       receivedMutations = receivedMutations + validMutations;
       if (receivedMutations == count) {
         inspector.off("markupmutation", onMutation);
         resolve();
       }
     });
   });
 }
-
-/**
- * Temporarily flip all the preferences needed to enable web components.
- */
-async function enableWebComponents() {
-  await pushPref("dom.webcomponents.shadowdom.enabled", true);
-  await pushPref("dom.webcomponents.customelements.enabled", true);
-}