tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_markup_dragdrop_invalidNodes.js (2675B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Check that pseudo-elements, anonymous nodes and slotted nodes are not draggable.
      7 
      8 const TEST_URL = URL_ROOT + "doc_markup_dragdrop.html";
      9 
     10 add_task(async function () {
     11  await pushPref("devtools.inspector.showAllAnonymousContent", true);
     12 
     13  const { inspector } = await openInspectorForURL(TEST_URL);
     14 
     15  info("Expanding nodes below #test");
     16  const parentFront = await getNodeFront("#test", inspector);
     17  await inspector.markup.expandNode(parentFront);
     18  await waitForMultipleChildrenUpdates(inspector);
     19 
     20  info("Getting the ::before pseudo element and selecting it");
     21  const parentContainer = await getContainerForNodeFront(
     22    parentFront,
     23    inspector
     24  );
     25  const beforePseudo = parentContainer.elt.children[1].firstChild.container;
     26  parentContainer.elt.scrollIntoView(true);
     27  await selectNode(beforePseudo.node, inspector);
     28 
     29  info("Simulate dragging the ::before pseudo element");
     30  await simulateNodeDrag(inspector, beforePseudo);
     31 
     32  ok(!beforePseudo.isDragging, "::before pseudo element isn't dragging");
     33 
     34  info("Expanding nodes below #anonymousParent");
     35  const inputFront = await getNodeFront("#anonymousParent", inspector);
     36  await inspector.markup.expandNode(inputFront);
     37  await waitForMultipleChildrenUpdates(inspector);
     38 
     39  info("Getting the anonymous node and selecting it");
     40  const inputContainer = await getContainerForNodeFront(inputFront, inspector);
     41  const anonymousDiv = inputContainer.elt.children[1].firstChild.container;
     42  inputContainer.elt.scrollIntoView(true);
     43  await selectNode(anonymousDiv.node, inspector);
     44 
     45  info("Simulate dragging the anonymous node");
     46  await simulateNodeDrag(inspector, anonymousDiv);
     47 
     48  ok(!anonymousDiv.isDragging, "anonymous node isn't dragging");
     49 
     50  info("Expanding all nodes below test-component");
     51  const testComponentFront = await getNodeFront("test-component", inspector);
     52  await inspector.markup.expandAll(testComponentFront);
     53  await waitForMultipleChildrenUpdates(inspector);
     54 
     55  info("Getting a slotted node and selecting it");
     56  // Directly use the markup getContainer API in order to retrieve the slotted container
     57  // for a given node front.
     58  const slotted1Front = await getNodeFront(".slotted1", inspector);
     59  const slottedContainer = inspector.markup.getContainer(slotted1Front, true);
     60  slottedContainer.elt.scrollIntoView(true);
     61  await selectNode(slotted1Front, inspector, "no-reason", true);
     62 
     63  info("Simulate dragging the slotted node");
     64  await simulateNodeDrag(inspector, slottedContainer);
     65 
     66  ok(!slottedContainer.isDragging, "slotted node isn't dragging");
     67 });