5 <title>Text direction switch target of HTMLEditor
</title>
6 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
7 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
8 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
12 SimpleTest
.waitForExplicitFinish();
13 SimpleTest
.waitForFocus(async () => {
14 await (async
function test_in_contenteditable() {
15 document
.body
.innerHTML
= "<div><div contenteditable>editable text</div></div>";
16 const editingHost
= document
.querySelector("div[contenteditable]");
18 SpecialPowers
.doCommand(window
, "cmd_switchTextDirection");
20 editingHost
.getAttribute("dir"),
22 "test_in_contenteditable: dir attr of the editing host should be set"
25 editingHost
.parentElement
.getAttribute("dir"),
27 "test_in_contenteditable: dir attr of the parent div of the editing host should not be set"
30 document
.body
.getAttribute("dir"),
32 "test_in_contenteditable: dir attr of the <body> should not be set",
35 document
.documentElement
.getAttribute("dir"),
37 "test_in_contenteditable: dir attr of the <html> should not be set",
41 await (async
function test_in_designMode() {
42 document
.body
.innerHTML
= "<div>abc</div>";
43 document
.designMode
= "on";
44 getSelection().collapse(document
.querySelector("div").firstChild
, 0);
45 SpecialPowers
.doCommand(window
, "cmd_switchTextDirection");
47 document
.querySelector("div").getAttribute("dir"),
49 "test_in_designMode: dir attr of the <div> should not be set",
52 document
.body
.getAttribute("dir"),
54 "test_in_designMode: dir attr of the <body> should be set",
57 document
.documentElement
.getAttribute("dir"),
59 "test_in_designMode: dir attr of the <html> should not be set",
61 document
.designMode
= "off";
62 document
.body
.removeAttribute("dir");
63 document
.body
.innerHTML
= "";
64 document
.documentElement
.removeAttribute("dir");