summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/tests
diff options
context:
space:
mode:
Diffstat (limited to 'editor/libeditor/tests')
-rw-r--r--editor/libeditor/tests/mochitest.ini4
-rw-r--r--editor/libeditor/tests/test_bug1306532.html64
-rw-r--r--editor/libeditor/tests/test_bug1352799.html98
3 files changed, 166 insertions, 0 deletions
diff --git a/editor/libeditor/tests/mochitest.ini b/editor/libeditor/tests/mochitest.ini
index 447fb8b65..4df3f606b 100644
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -217,6 +217,9 @@ skip-if = toolkit == 'android'
[test_bug1258085.html]
[test_bug1268736.html]
[test_bug1270235.html]
+[test_bug1306532.html]
+subsuite = clipboard
+skip-if = toolkit == 'android'
[test_bug1310912.html]
skip-if = toolkit == 'android' # bug 1315898
[test_bug1314790.html]
@@ -224,6 +227,7 @@ skip-if = toolkit == 'android' # bug 1315898
[test_bug1328023.html]
[test_bug1330796.html]
[test_bug1332876.html]
+[test_bug1352799.html]
[test_CF_HTML_clipboard.html]
subsuite = clipboard
diff --git a/editor/libeditor/tests/test_bug1306532.html b/editor/libeditor/tests/test_bug1306532.html
new file mode 100644
index 000000000..1d7b3e7af
--- /dev/null
+++ b/editor/libeditor/tests/test_bug1306532.html
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML>
+<html><head>
+<title>Test for bug 1306532</title>
+<style src="/tests/SimpleTest/test.css" type="text/css"></style>
+<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+
+<script class="testbody" type="application/javascript">
+
+function runTest() {
+ // Copy content from table.
+ var selection = getSelection();
+ var startRange = document.createRange();
+ startRange.setStart(headingone, 0);
+ startRange.setEnd(celltwo, 0);
+ selection.removeAllRanges();
+ selection.addRange(startRange);
+ SpecialPowers.wrap(document).execCommand("copy", false, null);
+
+ // Paste content into "pasteframe"
+ var pasteContainer = pasteframe.contentDocument.body;
+ var pasteRange = pasteframe.contentDocument.createRange();
+ pasteRange.selectNodeContents(pasteContainer);
+ pasteRange.collapse(false);
+ selection.removeAllRanges();
+ selection.addRange(pasteRange);
+ SpecialPowers.wrap(pasteframe.contentDocument).execCommand("paste", false, null);
+
+ is(pasteContainer.querySelector("#headingone").textContent, "Month", "First heading should be 'Month'.");
+ is(pasteContainer.querySelector("#headingtwo").textContent, "Savings", "Second heading should be 'Savings'.");
+ is(pasteContainer.querySelector("#cellone").textContent, "January", "First cell should be 'January'.");
+ is(pasteContainer.querySelector("#celltwo").textContent, "$100", "Second cell should be '$100'.");
+
+ SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1306532">Mozilla Bug 1306532</a>
+<p id="display"></p>
+
+<pre id="test">
+</pre>
+
+<div id="container">
+<table border="1">
+ <tr>
+ <th id="headingone">Month</th>
+ <th id="headingtwo">Savings</th>
+ </tr>
+ <tr>
+ <td id="cellone">January</td>
+ <td id="celltwo">$100</td>
+ </tr>
+</table>
+</div>
+
+<iframe onload="runTest();" id="pasteframe" src="data:text/html,<html><body contenteditable='true'>"></iframe>
+
+</body>
+</html>
diff --git a/editor/libeditor/tests/test_bug1352799.html b/editor/libeditor/tests/test_bug1352799.html
new file mode 100644
index 000000000..daedc40fc
--- /dev/null
+++ b/editor/libeditor/tests/test_bug1352799.html
@@ -0,0 +1,98 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1352799
+-->
+<head>
+ <title>Test for Bug 1352799</title>
+ <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=1352799">Mozilla Bug 1352799</a>
+<p id="display"></p>
+<div id="content">
+<div id="input-container" style="display: none;">
+<input id="input" maxlength="1">
+</div>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 1352799 **/
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(() => {
+ var input = document.getElementById("input");
+
+ var inputcontainer = document.getElementById('input-container');
+ input.setAttribute('maxlength', 2);
+ inputcontainer.style.display = 'block';
+
+ input.focus();
+
+ synthesizeKey('1', {});
+ synthesizeKey('2', {});
+ synthesizeKey('3', {});
+
+ is(input.value, '12', 'value should be 12 with maxlength = 2');
+
+ input.value = '';
+ inputcontainer.style.display = 'none';
+
+ window.setTimeout(() => {
+ input.setAttribute('maxlength', 4);
+ inputcontainer.style.display = 'block';
+
+ input.focus();
+
+ synthesizeKey('4', {});
+ synthesizeKey('5', {});
+ synthesizeKey('6', {});
+ synthesizeKey('7', {});
+ synthesizeKey('8', {});
+
+ is(input.value, '4567', 'value should be 4567 with maxlength = 4');
+
+ inputcontainer.style.display = 'none';
+
+ window.setTimeout(() => {
+ input.setAttribute('maxlength', 2);
+ inputcontainer.style.display = 'block';
+
+ input.focus();
+
+ synthesizeKey('1', {});
+ synthesizeKey('2', {});
+
+ todo_is(input.value, '45', 'value should be 45 with maxlength = 2');
+
+ input.value = '';
+ inputcontainer.style.display = 'none';
+
+ window.setTimeout(() => {
+ input.removeAttribute('maxlength');
+ inputcontainer.style.display = 'block';
+
+ input.focus();
+
+ synthesizeKey('1', {});
+ synthesizeKey('2', {});
+ synthesizeKey('3', {});
+ synthesizeKey('4', {});
+ synthesizeKey('5', {});
+ synthesizeKey('6', {});
+ synthesizeKey('7', {});
+ synthesizeKey('8', {});
+
+ is(input.value, '12345678', 'value should be 12345678 without maxlength');
+
+ SimpleTest.finish();
+ }, 0);
+ }, 0);
+ }, 0);
+});
+</script>
+</pre>
+</body>
+</html>