Bug 1368544 - Part 2. Add setting empty value test whether creating trailing node. r=masayuki
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 30 May 2017 18:59:31 +0900
changeset 409599 85449d8e83daf91d14ce48ca6ceda40a751db5b8
parent 409598 0144d912dcf0bba914e62a67b5d34fe1403d06c7
child 409600 d29a7708e35770728bd88d3218c495a2b1bb71e6
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1368544
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1368544 - Part 2. Add setting empty value test whether creating trailing node. r=masayuki MozReview-Commit-ID: 3eAFkmUntv0
editor/libeditor/tests/mochitest.ini
editor/libeditor/tests/test_bug1368544.html
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -230,16 +230,17 @@ skip-if = toolkit == 'android' # bug 131
 [test_bug1316302.html]
 [test_bug1318312.html]
 [test_bug1328023.html]
 [test_bug1330796.html]
 [test_bug1332876.html]
 [test_bug1352799.html]
 [test_bug1355792.html]
 [test_bug1358025.html]
+[test_bug1368544.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_bug1368544.html
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi=id=1368544
+-->
+<html>
+<head>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.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=1368544">Mozilla Bug 1368544</a>
+<div id="display"></div>
+<textarea id=textarea></textarea>
+<pre id="test">
+</pre>
+
+<script class="testbody" type="application/javascript">
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(() => {
+  let textarea = document.getElementById("textarea");
+  let editor = SpecialPowers.wrap(textarea).editor;
+
+  let spellChecker =
+    SpecialPowers.Cc['@mozilla.org/editor/editorspellchecker;1']
+    .createInstance(SpecialPowers.Ci.nsIEditorSpellCheck);
+  spellChecker.InitSpellChecker(editor, false);
+
+  textarea.focus();
+
+  SpecialPowers.Cu.import(
+    "resource://testing-common/AsyncSpellCheckTestHelper.jsm")
+  .onSpellCheck(textarea, () => {
+
+    spellChecker.UpdateCurrentDictionary(() => {
+      textarea.value = "ABC";
+      ok(editor.rootElement.hasChildNodes(),
+         "editor of textarea has child nodes");
+      synthesizeKey("D", {});
+      is(textarea.value, "ABCD", "D is last character");
+      ok(editor.rootElement.hasChildNodes(),
+         "editor of textarea has child nodes");
+      textarea.value = "";
+      ok(editor.rootElement.hasChildNodes(),
+         "editor of textarea has child node even if value is empty");
+
+      synthesizeKey("A", {});
+      synthesizeKey("A", {});
+      synthesizeKey("A", {});
+      synthesizeKey("VK_BACK_SPACE", {});
+      synthesizeKey("VK_BACK_SPACE", {});
+      synthesizeKey("VK_BACK_SPACE", {});
+      is(textarea.value, "", "value is empty");
+      ok(editor.rootElement.hasChildNodes(),
+         "editor of textarea has child node even if value is empty");
+
+      textarea.value = "ABC";
+      SpecialPowers.wrap(textarea).setUserInput("");
+      ok(editor.rootElement.hasChildNodes(),
+         "editor of textarea has child node even if value is empty");
+
+      textarea.value = "ABC";
+      synthesizeKey("VK_RETURN", {});
+      synthesizeKey("VK_RETURN", {});
+      textarea.value = "";
+      ok(editor.rootElement.hasChildNodes(),
+         "editor of textarea has child node even if value is empty");
+
+      synthesizeKey("A", {});
+      synthesizeKey("A", {});
+      synthesizeKey("A", {});
+      is(textarea.value, "AAA", "value is AAA");
+      textarea.addEventListener("keyup", (e) => {
+        if (e.key == "Enter") {
+          textarea.value = "";
+          ok(editor.rootElement.hasChildNodes(),
+             "editor of textarea has child node even if value is empty");
+          SimpleTest.finish();
+        }
+      });
+
+      synthesizeKey("VK_RETURN", {});
+    });
+ });
+});
+</script>
+</body>
+</html>