Bug 719518 - Selection.extend() with no ranges should throw standard exception type; r=ehsan

This commit is contained in:
Aryeh Gregor 2012-03-14 14:27:30 -04:00
parent 0435827509
commit d0cb80ca7b
3 changed files with 26 additions and 1 deletions

View File

@ -5081,7 +5081,7 @@ nsTypedSelection::Extend(nsINode* aParentNode, PRInt32 aOffset)
// First, find the range containing the old focus point:
if (!mAnchorFocusRange)
return NS_ERROR_NOT_INITIALIZED;
return NS_ERROR_DOM_INVALID_STATE_ERR;
if (!mFrameSelection)
return NS_ERROR_NOT_INITIALIZED; // Can't do selection

View File

@ -128,6 +128,7 @@ _TEST_FILES = \
test_selection_splitText-normalize.html \
test_bug524925.html \
test_bug719503.html \
test_bug719518.html \
$(NULL)
_CHROME_FILES = \

View File

@ -0,0 +1,24 @@
<!doctype html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=719518
-->
<title>Test for Bug 719518</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=719518">Mozilla Bug 719518</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
<script>
var thrown = false;
try {
getSelection().extend(document.body, 0);
} catch(e) {
thrown = true;
ok(e instanceof DOMException,
"Need to throw DOMException for extend() with no ranges");
is(e.code, DOMException.INVALID_STATE_ERR,
"Need to throw INVALID_STATE_ERR for extend() with no ranges");
}
ok(thrown, "Need to throw exception for extend() with no ranges");
</script>