Skip to content

Commit b671926

Browse files
Bug 1792387 - part 10: Make editor/libeditor/tests/test_inline_style_cache.html be aware of both split node directions r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D158108
1 parent 95251df commit b671926

File tree

1 file changed

+65
-13
lines changed

1 file changed

+65
-13
lines changed

editor/libeditor/tests/test_inline_style_cache.html

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
<script class="testbody" type="application/javascript">
1919
SimpleTest.waitForExplicitFinish();
2020
SimpleTest.waitForFocus(function() {
21+
const isTraditionalSplitDirection =!SpecialPowers.getBoolPref(
22+
"editor.join_split_direction.compatible_with_the_other_browsers"
23+
);
24+
2125
var editor = document.getElementById("editor");
2226
editor.focus();
2327

@@ -37,7 +41,6 @@
3741
"#01-01 At typing something after setting some styles, should cause inserting some nodes to apply the style");
3842

3943
// #01-02 Typing something after removing some characters after setting some styles should work as without removing some character.
40-
// XXX This behavior is different from Chromium.
4144
editor.innerHTML = "beforeafter";
4245
selection.collapse(editor.firstChild, "before".length);
4346
document.execCommand("bold");
@@ -46,8 +49,16 @@
4649
synthesizeKey("KEY_Delete");
4750
sendString("test");
4851

49-
is(editor.innerHTML, "before<strike><i><b>test</b></i></strike>fter",
50-
"#01-02-1 At typing something after Delete after setting style, should cause inserting some nodes to apply the style");
52+
todo_is(
53+
editor.innerHTML,
54+
"beforetestfter",
55+
"#01-02-1 At typing something after Delete after setting style, the style should not be preserved for compatibility with the other browsers"
56+
);
57+
is(
58+
editor.innerHTML,
59+
"before<strike><i><b>test</b></i></strike>fter",
60+
"#01-02-1 At typing something after Delete after setting style, the style should not be preserved, but it's okay to do it for backward compatibility"
61+
);
5162

5263
editor.innerHTML = "beforeafter";
5364
selection.collapse(editor.firstChild, "before".length);
@@ -84,7 +95,6 @@
8495
"#01-03-2 Typing Enter after setting style should not ignore the styles");
8596

8697
// #02-01 Replacing text with typing some text after setting some styles should work as just inserting text.
87-
// XXX Chromium works as expected.
8898
editor.innerHTML = "beforeselectionafter";
8999
selection.collapse(editor.firstChild, "before".length);
90100
selection.extend(editor.firstChild, "beforeselection".length);
@@ -93,11 +103,18 @@
93103
document.execCommand("strikethrough");
94104
sendString("test");
95105

96-
is(editor.innerHTML, "before<strike><i><b>test</b></i></strike>after",
97-
"#02-01 At replacing \"selection\" after setting some styles, should keep the styles at inserting text");
106+
todo_is(
107+
editor.innerHTML,
108+
"before<b><i><strike>test</strike></i></b>after",
109+
"#02-01 At replacing \"selection\" after setting some styles, should keep the styles at inserting text for compatibility with the other browsers"
110+
);
111+
is(
112+
editor.innerHTML,
113+
"before<strike><i><b>test</b></i></strike>after",
114+
"#02-01 At replacing \"selection\" after setting some styles, should keep the styles at inserting text, but it's okay to do it with reverted order for the backward compatibility"
115+
);
98116

99117
// #02-02 Inserting text after removing selected text after setting some styles should not keep the styles.
100-
// XXX Chromium keeps the style.
101118
editor.innerHTML = "beforeselectionafter";
102119
selection.collapse(editor.firstChild, "before".length);
103120
selection.extend(editor.firstChild, "beforeselection".length);
@@ -107,8 +124,24 @@
107124
synthesizeKey("KEY_Backspace");
108125
sendString("test");
109126

110-
is(editor.innerHTML, "beforetestafter",
111-
"#02-02 After removing \"selection\" after setting some styles, should not keep the styles");
127+
todo_is(
128+
editor.innerHTML,
129+
"before<b><i><strike>test</strike></i></b>after",
130+
"#02-02 After removing \"selection\" after setting some styles, should preserve the style for compatibility with the other browsers"
131+
);
132+
if (isTraditionalSplitDirection) {
133+
is(
134+
editor.innerHTML,
135+
"beforetestafter",
136+
"#02-02 After removing \"selection\" after setting some styles, should preserve the style, but it's okay not to do it for backward compatibility"
137+
);
138+
} else {
139+
is(
140+
editor.innerHTML,
141+
"before<strike><i><b>test</b></i></strike>after",
142+
"#02-02 After removing \"selection\" after setting some styles, should preserve the style, but it's okay to do it with reverted order for the backward compatibility"
143+
);
144+
}
112145

113146
// #02-03 Inserting text after replacing selected text after setting some styles should keep the styles.
114147
editor.innerHTML = "beforeselectionafter";
@@ -120,8 +153,24 @@
120153
synthesizeKey("KEY_Enter");
121154
sendString("test");
122155

123-
is(editor.innerHTML, "<div>before</div><div><strike><i><b>test</b></i></strike>after</div>",
124-
"#02-03-1 Typing Enter after setting style to selected text should keep the styles");
156+
todo_is(
157+
editor.innerHTML,
158+
"before<div><b><i><strike>test</strike></i></b>after</div>",
159+
"#02-03-1 Typing Enter after setting style to selected text should keep the styles and insert text into the new paragraph"
160+
);
161+
if (isTraditionalSplitDirection) {
162+
is(
163+
editor.innerHTML,
164+
"<div>before</div><div><strike><i><b>test</b></i></strike>after</div>",
165+
"#02-03-1 Typing Enter after setting style to selected text should keep the styles, it's okay to create left paragraph for backward compatibility"
166+
);
167+
} else {
168+
is(
169+
editor.innerHTML,
170+
"<div>before</div><div><strike><i><b>test</b></i></strike>after</div>",
171+
"#02-03-1 Typing Enter after setting style to selected text should keep the styles, it's okay to create left paragraph for backward compatibility"
172+
);
173+
}
125174

126175
editor.innerHTML = "<p>beforeselectionafter</p>";
127176
selection.collapse(editor.firstChild.firstChild, "before".length);
@@ -132,8 +181,11 @@
132181
synthesizeKey("KEY_Enter");
133182
sendString("test");
134183

135-
is(editor.innerHTML, "<p>before</p><p><strike><i><b>test</b></i></strike>after</p>",
136-
"#02-03-2 Typing Enter after setting style to selected text should keep the styles");
184+
is(
185+
editor.innerHTML,
186+
"<p>before</p><p><strike><i><b>test</b></i></strike>after</p>",
187+
"#02-03-2 Typing Enter after setting style to selected text should keep the styles"
188+
);
137189

138190
// #03-01 Replacing in <b style="font-weight: normal;"> shouldn't cause new <b>.
139191
editor.innerHTML = "<b style=\"font-weight: normal;\">beforeselectionafter</b>";

0 commit comments

Comments
 (0)