Bug 1313986 - Part 1. Add test for inlineTableEditing and objectResizing. r=masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 24 Nov 2016 15:00:04 +0900
changeset 443365 8cb81a89f11d4092f2adaa8822733f861a71ace1
parent 443220 34fce7c12173bdd6dda54c2ebf6d344252f1ac48
child 443366 0c8e467bb0dfceaa25722b840842ecf90e4e0f6a
child 443428 9585214aa678c16905250265a75b817c90246fcc
push id36970
push userm_kato@ga2.so-net.ne.jp
push dateThu, 24 Nov 2016 09:43:59 +0000
reviewersmasayuki
bugs1313986
milestone53.0a1
Bug 1313986 - Part 1. Add test for inlineTableEditing and objectResizing. r=masayuki We have no mochitest for objectResizing and inlineTableEditing. So I add simple test for this. MozReview-Commit-ID: Hnjpopr3h5F
editor/libeditor/tests/mochitest.ini
editor/libeditor/tests/test_inlineTableEditing.html
editor/libeditor/tests/test_objectResizing.html
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -221,17 +221,19 @@ skip-if = toolkit == 'android' # bug 131
 subsuite = clipboard
 [test_composition_event_created_in_chrome.html]
 [test_contenteditable_focus.html]
 [test_dom_input_event_on_htmleditor.html]
 skip-if = toolkit == 'android' # bug 1054087
 [test_dom_input_event_on_texteditor.html]
 [test_dragdrop.html]
 skip-if = os == 'android'
+[test_inlineTableEditing.html]
 [test_keypress_untrusted_event.html]
+[test_objectResizing.html]
 [test_root_element_replacement.html]
 [test_select_all_without_body.html]
 [test_spellcheck_pref.html]
 skip-if = toolkit == 'android'
 [test_backspace_vs.html]
 [test_css_chrome_load_access.html]
 skip-if = toolkit == 'android' # chrome urls not available due to packaging
 [test_selection_move_commands.html]
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/tests/test_inlineTableEditing.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<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>
+<p id="display"></p>
+<div id="content" style="display: none;">
+
+</div>
+
+<div id="editable1" contenteditable="true">
+<table id="table1">
+<tr id="tr1"><td>ABCDEFG</td><td>HIJKLMN</td></tr>
+<tr id="tr2"><td>ABCDEFG</td><td>HIJKLMN</td></tr>
+<tr id="tr3"><td>ABCDEFG</td><td>HIJKLMN</td></tr>
+</table>
+</div>
+<pre id="test">
+
+<script class="testbody" type="application/javascript">
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function() {
+  document.execCommand("enableObjectResizing", false, "false");
+  document.execCommand("enableInlineTableEditing", false, "true");
+
+  let tableNode = document.getElementById("table1");
+  synthesizeMouseAtCenter(tableNode, {});
+  isnot(tableNode.getAttribute("_moz_resizing"), "true",
+         "_moz_resizing attribute shouldn't be true without object resizing");
+
+  ok(document.getElementById("tr2"), "id=tr2 should exist");
+  synthesizeMouse(tr2, 0, tr2.clientHeight / 2, {});
+  ok(!document.getElementById("tr2"),
+     "id=tr2 should be removed by a click in the row");
+
+  SimpleTest.finish();
+});
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/tests/test_objectResizing.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<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>
+<p id="display"></p>
+<div id="content" style="display: none;">
+
+</div>
+
+<div id="editable1" contenteditable="true">
+<table id="table1">
+<tr><td>ABCDEFG</td><td>HIJKLMN</td></tr>
+<tr><td>ABCDEFG</td><td>HIJKLMN</td></tr>
+</table>
+</div>
+<pre id="test">
+
+<script class="testbody" type="application/javascript">
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function() {
+  document.execCommand("enableObjectResizing", false, "true");
+
+  let tableNode = document.getElementById("table1");
+  synthesizeMouseAtCenter(tableNode, {});
+  is(tableNode.getAttribute("_moz_resizing"), "true",
+     "_moz_resizing attribute should be true with object resizing");
+
+  let originalHeight = tableNode.clientHeight;
+  synthesizeMouse(tableNode, 0, originalHeight, { type: "mousedown" });
+  synthesizeMouse(tableNode, 0, originalHeight + 100, { type: "mousemove" });
+  synthesizeMouse(tableNode, 0, originalHeight + 100, { type: "mouseup" });
+  isnot(originalHeight, tableNode.clientHeight,
+        "table height should be changed by dragging a resizer grip");
+
+  let originalWidth = tableNode.clientWidth;
+  synthesizeMouse(tableNode, originalWidth, 0, { type: "mousedown" });
+  synthesizeMouse(tableNode, originalWidth + 100, 0, { type: "mousemove" });
+  synthesizeMouse(tableNode, originalWidth + 100, 0, { type: "mouseup" });
+  isnot(originalWidth, tableNode.clientWidth,
+        "table width should be changed by dragging a resizer grip");
+
+  SimpleTest.finish();
+});
+</script>
+</pre>
+</body>
+</html>