Bug 998188 part.1 Add test for this crash on debug build r=ehsan

This commit is contained in:
Masayuki Nakano 2014-04-26 08:52:12 +09:00
parent bd1e85ccff
commit 6de1b7019c
5 changed files with 73 additions and 20 deletions

View File

@ -267,7 +267,7 @@ static uint32_t CountNewlinesInNativeLength(nsIContent* aContent,
return 0;
}
// For automated tests, we should abort on debug build.
NS_ABORT_IF_FALSE(
MOZ_ASSERT(
(aNativeLength == UINT32_MAX || aNativeLength <= text->GetLength() * 2),
"aNativeLength is unexpected value");
const uint32_t xpLength = text->GetLength();

View File

@ -98,6 +98,7 @@ skip-if = toolkit == 'android' || e10s
skip-if = os != "win"
[test_bug966552.html]
skip-if = os != "win"
[test_bug998188.html]
[test_contenteditable_focus.html]
[test_dom_input_event_on_htmleditor.html]
[test_keypress_untrusted_event.html]

View File

@ -0,0 +1,52 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=565392
-->
<head>
<title>Test for Bug 998188</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=998188">Mozilla Bug 998188</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="editor" contenteditable>abc</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 998188 **/
SimpleTest.waitForExplicitFinish();
function runTests()
{
var editor = document.getElementById("editor");
editor.focus();
var textNode1 = document.createTextNode("def");
var textNode2 = document.createTextNode("ghi");
editor.appendChild(textNode1);
editor.appendChild(textNode2);
window.getSelection().collapse(textNode2, 3);
for (var i = 0; i < 9; i++) {
var caretRect = synthesizeQueryCaretRect(i);
ok(caretRect.succeeded, "QueryCaretRect should succeeded (" + i + ")");
}
SimpleTest.finish();
}
SimpleTest.waitForFocus(runTests);
</script>
</pre>
</body>
</html>

View File

@ -33,25 +33,6 @@ function synthesizeQueryTextContent(aOffset, aLength, aWindow)
aOffset, aLength, 0, 0);
}
/**
* Synthesize a query caret rect event.
*
* @param aOffset The caret offset. 0 means left side of the first character
* in the selection root.
* @param aWindow Optional (If null, current |window| will be used)
* @return An nsIQueryContentEventResult object. If this failed,
* the result might be null.
*/
function synthesizeQueryCaretRect(aOffset, aWindow)
{
var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return nullptr;
}
return utils.sendQueryContentEvent(utils.QUERY_CARET_RECT,
aOffset, 0, 0, 0);
}
/**
* Synthesize a query text rect event.
*

View File

@ -988,6 +988,25 @@ function synthesizeQuerySelectedText(aWindow)
return utils.sendQueryContentEvent(utils.QUERY_SELECTED_TEXT, 0, 0, 0, 0);
}
/**
* Synthesize a query caret rect event.
*
* @param aOffset The caret offset. 0 means left side of the first character
* in the selection root.
* @param aWindow Optional (If null, current |window| will be used)
* @return An nsIQueryContentEventResult object. If this failed,
* the result might be null.
*/
function synthesizeQueryCaretRect(aOffset, aWindow)
{
var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return null;
}
return utils.sendQueryContentEvent(utils.QUERY_CARET_RECT,
aOffset, 0, 0, 0);
}
/**
* Synthesize a selection set event.
*