зеркало из https://github.com/mozilla/gecko-dev.git
Bug 589621 - Throw the correct exception for Selection.getRangeAt called with out-of-bounds values; r=sicking a=bsmedberg
This commit is contained in:
Родитель
316e3b7984
Коммит
9d43bc33c9
|
@ -112,6 +112,8 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
|
|||
#include "nsIBidiKeyboard.h"
|
||||
#endif // IBMBIDI
|
||||
|
||||
#include "nsDOMError.h"
|
||||
|
||||
//#define DEBUG_TABLE 1
|
||||
|
||||
static NS_DEFINE_IID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
|
||||
|
@ -5022,13 +5024,13 @@ nsTypedSelection::GetIsCollapsed(PRBool* aIsCollapsed)
|
|||
*aIsCollapsed = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
if (cnt != 1)
|
||||
{
|
||||
*aIsCollapsed = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
*aIsCollapsed = mRanges[0].mRange->Collapsed();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -5046,7 +5048,7 @@ nsTypedSelection::GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn)
|
|||
{
|
||||
*aReturn = mRanges.SafeElementAt(aIndex, sEmptyData).mRange;
|
||||
if (!*aReturn) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aReturn);
|
||||
|
@ -5083,7 +5085,7 @@ nsTypedSelection::CopyRangeToAnchorFocus(nsIRange *aRange)
|
|||
return NS_ERROR_FAILURE;//???
|
||||
}
|
||||
else if (NS_FAILED(mAnchorFocusRange->SetEnd(endNode,endOffset)))
|
||||
return NS_ERROR_FAILURE;//???
|
||||
return NS_ERROR_FAILURE;//???
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ _TEST_FILES = \
|
|||
test_bug469613.xul \
|
||||
test_bug469774.xul \
|
||||
test_bug470212.html \
|
||||
$(warning test_bug488417.html temporarily disabled - see bug 489560) \
|
||||
test_bug496275.html \
|
||||
test_bug503813.html \
|
||||
test_bug508115.xul \
|
||||
|
@ -118,11 +119,10 @@ _TEST_FILES = \
|
|||
file_bug514732_1.html \
|
||||
file_bug514732_helper.html \
|
||||
test_bug522632.html \
|
||||
test_bug589621.html \
|
||||
$(srcdir)/../../reftests/backgrounds/blue-32x32.png \
|
||||
$(srcdir)/../../reftests/backgrounds/fuchsia-32x32.png \
|
||||
$(NULL)
|
||||
# disabled temporarily
|
||||
# test_bug488417.html \
|
||||
|
||||
_CHROME_FILES = \
|
||||
test_bug514732-2.xul \
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=589621
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 589621</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=589621">Mozilla Bug 589621</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script>
|
||||
/** Test for Bug 589621 **/
|
||||
var sel = getSelection();
|
||||
var range = document.createRange();
|
||||
sel.addRange(range);
|
||||
function t(n) {
|
||||
try {
|
||||
sel.getRangeAt(n);
|
||||
ok(false, "Should not be here");
|
||||
} catch(e) {
|
||||
ok(e instanceof DOMException, "Should be a DOMException");
|
||||
is(e.code, DOMException.INDEX_SIZE_ERR, "Should be an INDEX_SIZE_ERR");
|
||||
}
|
||||
}
|
||||
t(-1);
|
||||
t(1);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче