Bug 1313986 - Part 1. Add test for inlineTableEditing and objectResizing. r=masayuki
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 24 Nov 2016 15:00:04 +0900
changeset 324072 c72334e5c900c88684a083dc04e725873e428a67
parent 324071 4153ce5276d5f44c77a928836453343d89a78b5d
child 324073 4205c3ed2ce5999aad02cceb0a8917ddf4c0e831
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +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>