Bug 1409520 - part 0: Add automated test r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 23 Oct 2017 22:01:58 +0900
changeset 685748 e04990f5e538e65d640c94078e340b7c168a88d0
parent 685747 51484f33898df80318c982ccc5bf8218c81185b0
child 685749 ef85fd3a802c2dd25bc4c67ef3d3ffb98fe2106f
push id86016
push userkgupta@mozilla.com
push dateWed, 25 Oct 2017 01:53:44 +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>