Bug 1409520 - part 0: Add automated test r?m_kato
The bug is a report for hitting MOZ_ASSERT, but we should also check the result
of the call of execCommand.
MozReview-Commit-ID: FydZKAjI2Rl
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -250,16 +250,17 @@ skip-if = toolkit == 'android' # bug 131
[test_bug1355792.html]
[test_bug1358025.html]
[test_bug1361008.html]
[test_bug1368544.html]
[test_bug1385905.html]
[test_bug1390562.html]
[test_bug1394758.html]
[test_bug1399722.html]
+[test_bug1409520.html]
[test_CF_HTML_clipboard.html]
subsuite = clipboard
[test_composition_event_created_in_chrome.html]
[test_contenteditable_focus.html]
[test_documentCharacterSet.html]
[test_dom_input_event_on_htmleditor.html]
skip-if = toolkit == 'android' # bug 1054087
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/tests/test_bug1409520.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1409520
+-->
+<html>
+<head>
+ <title>Test for Bug 1409520</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1409520">Mozilla Bug 1409520</a>
+<p id="display"></p>
+<div id="content" style="display: none;">
+
+</div>
+
+<li contenteditable id="editor">
+ <select><option>option1</option></select>
+</li>
+
+<pre id="test">
+
+<script class="testbody" type="application/javascript">
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function() {
+ var selection = window.getSelection();
+ var editor = document.getElementById("editor");
+ editor.focus();
+ selection.collapse(editor, 0);
+ document.execCommand('insertText', false, 'A');
+ is(editor.firstChild.textContent, "A",
+ "'A' should be inserted at start of the editor");
+ is(editor.firstChild.nextSibling.tagName, "SELECT",
+ "<select> element shouldn't be removed by inserting 'A'");
+ is(selection.getRangeAt(0).startContainer, editor.firstChild,
+ "Caret should be moved after 'A'");
+ is(selection.getRangeAt(0).startOffset, 1,
+ "Caret should be moved after 'A'");
+ SimpleTest.finish();
+});
+</script>
+</pre>
+</body>
+</html>