Bug 1874684 - Part 17: Fix uninitialised variable warnings from clang-tidy. r=allstarschh
[gecko.git] / editor / libeditor / tests / test_htmleditor_toggle_text_direction.html
blob9dfa80f1131aa816455d31850db822c292ff9dcf
1 <!doctype html>
2 <html>
3 <head>
4 <meta charset="utf-8">
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">
9 <script>
10 "use strict";
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]");
17 editingHost.focus();
18 SpecialPowers.doCommand(window, "cmd_switchTextDirection");
19 is(
20 editingHost.getAttribute("dir"),
21 "rtl",
22 "test_in_contenteditable: dir attr of the editing host should be set"
24 is(
25 editingHost.parentElement.getAttribute("dir"),
26 null,
27 "test_in_contenteditable: dir attr of the parent div of the editing host should not be set"
29 is(
30 document.body.getAttribute("dir"),
31 null,
32 "test_in_contenteditable: dir attr of the <body> should not be set",
34 is(
35 document.documentElement.getAttribute("dir"),
36 null,
37 "test_in_contenteditable: dir attr of the <html> should not be set",
39 })();
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");
46 is(
47 document.querySelector("div").getAttribute("dir"),
48 null,
49 "test_in_designMode: dir attr of the <div> should not be set",
51 is(
52 document.body.getAttribute("dir"),
53 "rtl",
54 "test_in_designMode: dir attr of the <body> should be set",
56 is(
57 document.documentElement.getAttribute("dir"),
58 null,
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");
65 })();
67 SimpleTest.finish();
68 });
69 </script>
70 </head>
71 <body>
72 </body>
73 </html>