4 https://bugzilla.mozilla.org/show_bug.cgi?id=442186
7 <title>Test for Bug
442186</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=442186">Mozilla Bug
442186</a>
16 <h2> two
<div
> containers
</h2>
17 <section contenteditable
id=
"test1">
18 <div> First paragraph with some text.
</div>
19 <div> Second paragraph with some text.
</div>
22 <h2> two paragraphs
</h2>
23 <section contenteditable
id=
"test2">
24 <p> First paragraph with some text.
</p>
25 <p> Second paragraph with some text.
</p>
28 <h2> one text node, one paragraph
</h2>
29 <section contenteditable
id=
"test3">
30 First paragraph with some text.
31 <p> Second paragraph with some text.
</p>
36 <script type=
"application/javascript">
38 /** Test for Bug
442186 **/
39 SimpleTest.waitForExplicitFinish();
40 SimpleTest.waitForFocus(runTests);
42 function justify(textNode, pos) {
45 // put the caret on the requested character
46 var range = document.createRange();
47 var sel = window.getSelection();
48 range.setStart(textNode, pos);
49 range.setEnd(textNode, pos);
53 document.execCommand(
"justifyright", false, null);
57 document.execCommand(
"stylewithcss", false,
"true");
59 const test1 = document.getElementById(
"test1");
60 const test2 = document.getElementById(
"test2");
61 const test3 = document.getElementById(
"test3");
63 // #test1: two
<div> containers
64 const line1 = test1.querySelector(
"div").firstChild;
67 is(test1.querySelectorAll(
"*").length,
2,
68 "Aligning the first child should not create nor remove any element.");
69 is(line1.parentNode.nodeName.toLowerCase(),
"div",
70 "Aligning the first <div> should not modify its node type.");
71 is(line1.parentNode.style.textAlign,
"right",
72 "Aligning the first <div> should set a 'text-align: right' style rule.");
74 // #test2: two paragraphs
75 const line2 = test2.querySelector(
"p").firstChild;
78 is(test2.querySelectorAll(
"*").length,
2,
79 "Aligning the first child should not create nor remove any element.");
80 is(line2.parentNode.nodeName.toLowerCase(),
"p",
81 "Aligning the first paragraph should not modify its node type.");
82 is(line2.parentNode.style.textAlign,
"right",
83 "Aligning the first paragraph should set a 'text-align: right' style rule.");
85 // #test3: one text node, two paragraphs
86 const line3 = test3.firstChild;
89 is(test3.querySelectorAll(
"*").length,
2,
90 "Aligning the first child should create a block element.");
91 is(line3.parentNode.nodeName.toLowerCase(),
"div",
92 "Aligning the first child should create a block element.");
93 is(line3.parentNode.style.textAlign,
"right",
94 "Aligning the first line should set a 'text-align: right' style rule.");