tor-browser

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

delete-in-last-list-item-when-parent-list-is-editing-host.html (3063B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <meta name="timeout" content="long">
      6 <meta name="variant" content="?list=ul&action=Backspace">
      7 <meta name="variant" content="?list=ul&action=Delete">
      8 <meta name="variant" content="?list=ol&action=Backspace">
      9 <meta name="variant" content="?list=ol&action=Delete">
     10 <title>Delete in last list item should not delete parent list if it's editing host</title>
     11 <script src="/resources/testharness.js"></script>
     12 <script src="/resources/testharnessreport.js"></script>
     13 <script src="/resources/testdriver.js"></script>
     14 <script src="/resources/testdriver-vendor.js"></script>
     15 <script src="/resources/testdriver-actions.js"></script>
     16 <script src="../include/editor-test-utils.js"></script>
     17 <script>
     18 "use strict";
     19 
     20 const params = new URLSearchParams(location.search.substring(1));
     21 const backspace = params.get("action") == "Backspace";
     22 const list = params.get("list");
     23 
     24 addEventListener("load", () => {
     25  document.body.innerHTML =`<${list} contenteditable></${list}>`;
     26  const editingHost = document.querySelector("[contenteditable]");
     27  const utils = new EditorTestUtils(editingHost);
     28 
     29  function addPromiseTest(aTest) {
     30    promise_test(async () => {
     31      editingHost.focus();
     32      utils.setupEditingHost(aTest.innerHTML);
     33      await (backspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
     34      utils.normalizeStyleAttributeValues();
     35      if (Array.isArray(aTest.expectedResult)) {
     36        assert_in_array(editingHost.innerHTML, aTest.expectedResult);
     37      } else {
     38        assert_equals(editingHost.innerHTML, aTest.expectedResult);
     39      }
     40      assert_equals(
     41        document.body.childNodes.length,
     42        1,
     43        `The editing host should be the only child of <body> (got: "${document.body.innerHTML}")`
     44      );
     45      assert_equals(
     46        document.body.firstChild,
     47        editingHost,
     48        `The editing host should be the only child of <body> (got: "${document.body.innerHTML}")`
     49      );
     50    }, `${backspace ? "Backspace" : "Delete"} in "<${list} contenteditable>${aTest.innerHTML}</${list}>"`);
     51  }
     52 
     53  addPromiseTest({
     54    innerHTML: "<li>{}</li>",
     55    expectedResult: ["<li></li>", "<li><br></li>"],
     56  });
     57  addPromiseTest({
     58    innerHTML: "<li><ul><li>{}</li></ul></li>",
     59    expectedResult: ["<li></li>", "<li><br></li>"],
     60  });
     61  addPromiseTest({
     62    innerHTML: "<li><ol><li>{}</li></ol></li>",
     63    expectedResult: ["<li></li>", "<li><br></li>"],
     64  });
     65  // If only sub-list in the editing host list element, the sub-list should be
     66  // replaced with a list item.
     67  addPromiseTest({
     68    innerHTML: "<ul><li>{}</li></ul>",
     69    expectedResult: ["<li></li>", "<li><br></li>"],
     70  });
     71  addPromiseTest({
     72    innerHTML: "<ol><li>{}</li></ol>",
     73    expectedResult: ["<li></li>", "<li><br></li>"],
     74  });
     75  addPromiseTest({
     76    innerHTML: "<dl><dt>{}</dt></dl>",
     77    expectedResult: ["<li></li>", "<li><br></li>"],
     78  });
     79  addPromiseTest({
     80    innerHTML: "<dl><dd>{}</dd></dl>",
     81    expectedResult: ["<li></li>", "<li><br></li>"],
     82  });
     83 }, {once:true});
     84 </script>
     85 </head>
     86 <body></body>
     87 </html>