Bug 1883912: Enable Intl.ListFormat test for "unit" style. r=spidermonkey-reviewers...
[gecko.git] / editor / libeditor / tests / test_texteditor_textnode.html
blobd93f7146494c1b67acdb6038e9dca79933f76098
1 <!DOCTYPE html>
2 <meta charset="utf-8">
3 <title>Test for Bug 1713334</title>
4 <script src="/tests/SimpleTest/SimpleTest.js"></script>
5 <script src="/tests/SimpleTest/EventUtils.js"></script>
6 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
7 <input id="input">
8 <textarea id="textarea"></textarea>
9 <script>
10 "use strict";
12 function assertChild(div, content) {
13 const name = div.parentElement.localName;
14 is(div.firstChild.nodeType, Node.TEXT_NODE, `<${name}>: The first node of the root element must be a text node`);
15 is(div.firstChild.textContent, content, `<${name}>: The content of the text node is wrong`);
18 function test(element) {
19 element.focus();
21 const { rootElement } = SpecialPowers.wrap(element).editor;
22 assertChild(rootElement, "");
24 element.value = "";
25 assertChild(rootElement, "");
27 element.value = "foo"
28 assertChild(rootElement, "foo");
30 element.value = "";
31 assertChild(rootElement, "");
33 element.value = "foo";
34 const selection =
35 SpecialPowers.wrap(element).
36 editor.
37 selectionController.getSelection(
38 SpecialPowers.Ci.nsISelectionController.SELECTION_NORMAL
40 selection.setBaseAndExtent(rootElement, 0, rootElement, 1);
41 document.execCommand("delete");
42 assertChild(rootElement, "");
45 SimpleTest.waitForExplicitFinish();
46 SimpleTest.waitForFocus(() => {
47 test(document.all.input);
48 test(document.all.textarea);
50 SimpleTest.finish();
51 });
52 </script>