summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/tests/test_bug1026397.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /editor/libeditor/tests/test_bug1026397.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'editor/libeditor/tests/test_bug1026397.html')
-rw-r--r--editor/libeditor/tests/test_bug1026397.html103
1 files changed, 103 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_bug1026397.html b/editor/libeditor/tests/test_bug1026397.html
new file mode 100644
index 000000000..487f3e87f
--- /dev/null
+++ b/editor/libeditor/tests/test_bug1026397.html
@@ -0,0 +1,103 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1026397
+-->
+<head>
+ <title>Test for Bug 1026397</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/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=1026397">Mozilla Bug 1026397</a>
+<p id="display"></p>
+<div id="content">
+<input id="input">
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 1026397 **/
+SimpleTest.waitForExplicitFinish();
+
+function runTests()
+{
+ var input = document.getElementById("input");
+ input.focus();
+
+ function doTest(aMaxLength, aInitialValue, aCaretOffset,
+ aInsertString, aExpectedValueDuringComposition,
+ aExpectedValueAfterCompositionEnd, aAdditionalExplanation)
+ {
+ input.value = aInitialValue;
+ var maxLengthStr = "";
+ if (aMaxLength >= 0) {
+ input.maxLength = aMaxLength;
+ maxLengthStr = aMaxLength.toString();
+ } else {
+ input.removeAttribute("maxlength");
+ maxLengthStr = "not specified";
+ }
+ input.selectionStart = input.selectionEnd = aCaretOffset;
+ if (aAdditionalExplanation) {
+ aAdditionalExplanation = " " + aAdditionalExplanation;
+ } else {
+ aAdditionalExplanation = "";
+ }
+
+ synthesizeCompositionChange(
+ { "composition":
+ { "string": aInsertString,
+ "clauses":
+ [
+ { "length": aInsertString.length, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
+ ]
+ },
+ "caret": { "start": aInsertString.length, "length": 0 }
+ });
+ is(input.value, aExpectedValueDuringComposition,
+ "The value of input whose maxlength is " + maxLengthStr + " should be "
+ + aExpectedValueDuringComposition + " during composition" + aAdditionalExplanation);
+ synthesizeComposition({ type: "compositioncommitasis" });
+ is(input.value, aExpectedValueAfterCompositionEnd,
+ "The value of input whose maxlength is " + maxLengthStr + " should be "
+ + aExpectedValueAfterCompositionEnd + " after compositionend" + aAdditionalExplanation);
+ }
+
+ // maxlength hasn't been specified yet.
+ doTest(-1, "", 0, "\uD842\uDFB7\u91CE\u5BB6", "\uD842\uDFB7\u91CE\u5BB6", "\uD842\uDFB7\u91CE\u5BB6");
+
+ // maxlength="1"
+ doTest(1, "", 0, "\uD842\uDFB7\u91CE\u5BB6", "\uD842\uDFB7\u91CE\u5BB6", "");
+
+ // maxlength="2"
+ doTest(2, "", 0, "\uD842\uDFB7\u91CE\u5BB6", "\uD842\uDFB7\u91CE\u5BB6", "\uD842\uDFB7");
+ doTest(2, "X", 1, "\uD842\uDFB7\u91CE\u5BB6", "X\uD842\uDFB7\u91CE\u5BB6", "X");
+ doTest(2, "Y", 0, "\uD842\uDFB7\u91CE\u5BB6", "\uD842\uDFB7\u91CE\u5BB6Y", "Y");
+
+ // maxlength="3"
+ doTest(3, "", 0, "\uD842\uDFB7\u91CE\u5BB6", "\uD842\uDFB7\u91CE\u5BB6", "\uD842\uDFB7\u91CE");
+ doTest(3, "A", 1, "\uD842\uDFB7\u91CE\u5BB6", "A\uD842\uDFB7\u91CE\u5BB6", "A\uD842\uDFB7");
+ doTest(3, "B", 0, "\uD842\uDFB7\u91CE\u5BB6", "\uD842\uDFB7\u91CE\u5BB6B", "\uD842\uDFB7B");
+ doTest(3, "CD", 1, "\uD842\uDFB7\u91CE\u5BB6", "C\uD842\uDFB7\u91CE\u5BB6D", "CD");
+
+ // maxlength="4"
+ doTest(4, "EF", 1, "\uD842\uDFB7\u91CE\u5BB6", "E\uD842\uDFB7\u91CE\u5BB6F", "E\uD842\uDFB7F");
+ doTest(4, "GHI", 1, "\uD842\uDFB7\u91CE\u5BB6", "G\uD842\uDFB7\u91CE\u5BB6HI", "GHI");
+
+ // maxlength="1", inputting only high surrogate
+ doTest(1, "", 0, "\uD842", "\uD842", "\uD842", "even if input string is only a high surrogate");
+
+ // maxlength="1", inputting only low surrogate
+ doTest(1, "", 0, "\uDFB7", "\uDFB7", "\uDFB7", "even if input string is only a low surrogate");
+
+ SimpleTest.finish();
+}
+
+SimpleTest.waitForFocus(runTests);
+
+</script>
+</pre>
+</body>
+</html>