зеркало из https://github.com/mozilla/gecko-dev.git
Bug 589623 - Raise INVALID_STATE_ERR exceptions from Selection.collapseTo{Start|End}; r+a=jst
This commit is contained in:
Родитель
9d43bc33c9
Коммит
d3ebaf1d84
|
@ -4979,7 +4979,7 @@ nsTypedSelection::CollapseToStart()
|
|||
PRInt32 cnt;
|
||||
nsresult rv = GetRangeCount(&cnt);
|
||||
if (NS_FAILED(rv) || cnt <= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
|
||||
// Get the first range
|
||||
nsIRange* firstRange = mRanges[0].mRange;
|
||||
|
@ -4999,7 +4999,7 @@ nsTypedSelection::CollapseToEnd()
|
|||
PRInt32 cnt;
|
||||
nsresult rv = GetRangeCount(&cnt);
|
||||
if (NS_FAILED(rv) || cnt <= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
|
||||
// Get the last range
|
||||
nsIRange* lastRange = mRanges[cnt-1].mRange;
|
||||
|
|
|
@ -120,6 +120,7 @@ _TEST_FILES = \
|
|||
file_bug514732_helper.html \
|
||||
test_bug522632.html \
|
||||
test_bug589621.html \
|
||||
test_bug589623.html \
|
||||
$(srcdir)/../../reftests/backgrounds/blue-32x32.png \
|
||||
$(srcdir)/../../reftests/backgrounds/fuchsia-32x32.png \
|
||||
$(NULL)
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=589623
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 589623</title>
|
||||
<script src="/MochiKit/packed.js"></script>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=589623">Mozilla Bug 589623</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script>
|
||||
/** Test for Bug 589623 **/
|
||||
var sel = getSelection();
|
||||
sel.removeAllRanges();
|
||||
function t(m) {
|
||||
try {
|
||||
sel[m]();
|
||||
ok(false, "Should not be here");
|
||||
} catch(e) {
|
||||
ok(e instanceof DOMException, "Should be a DOMException");
|
||||
is(e.code, DOMException.INVALID_STATE_ERR, "Should be an INVALID_STATE_ERR");
|
||||
}
|
||||
}
|
||||
t("collapseToStart");
|
||||
t("collapseToEnd");
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче