Bug 1409520 - part 0: Add automated test r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 23 Oct 2017 22:01:58 +0900
changeset 684891 92f8145365566353c6dc65e01edb387fd5a5a7eb
parent 684511 ce1a86d3b4db161c95d1147676bbed839d7a4732
child 684892 437d72cb9353831721a3da8229cce45a3d32d009
push id85751
push usermasayuki@d-toybox.com
push dateMon, 23 Oct 2017 17:58:54 +0000
reviewersm_kato
bugs1409520
milestone58.0a1
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
editor/libeditor/tests/mochitest.ini
editor/libeditor/tests/test_bug1409520.html
--- 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>