Commit 5f5c5f30 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

https://bugs.webkit.org/show_bug.cgi?id=75799

Calling intersectsNode on a detached range should throw.

Source/WebCore:

INVALID_STATE_ERR exception should be thrown if intersectsNode is called on a detached Range.

Patch by Joe Thomas <joethomas@motorola.com> on 2012-01-23
Reviewed by Darin Adler.

Test: fast/dom/Range/range-intersectsNode-exception.html

* dom/Range.cpp:
(WebCore::Range::intersectsNode): Throwing INVALID_STATE_ERR exception if the range is detached.

LayoutTests:

Added test case to verify the exception thrown while calling intersectsNode on a detached range.

Patch by Joe Thomas <joethomas@motorola.com> on 2012-01-23
Reviewed by Darin Adler.

* fast/dom/Range/range-intersectsNode-exception-expected.txt: Added.
* fast/dom/Range/range-intersectsNode-exception.html: Added.
* fast/dom/Range/range-intersectsNode-expected.txt:
* fast/dom/Range/resources/intersectsNode.js:  Modified the test case to catch the exception.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105649 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ae86f2ab
2012-01-23 Joe Thomas <joethomas@motorola.com>
https://bugs.webkit.org/show_bug.cgi?id=75799
Calling intersectsNode on a detached range should throw.
Added test case to verify the exception thrown while calling intersectsNode on a detached range.
Reviewed by Darin Adler.
* fast/dom/Range/range-intersectsNode-exception-expected.txt: Added.
* fast/dom/Range/range-intersectsNode-exception.html: Added.
* fast/dom/Range/range-intersectsNode-expected.txt:
* fast/dom/Range/resources/intersectsNode.js: Modified the test case to catch the exception.
2012-01-23 Mike Lawther <mikelawther@chromium.org>
 
getComputedStyle margin percentage test for CSS calc
Test for Bug: 75799 - Calling intersectsNode on a detached range should throw
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS range.intersectsNode(document.getElementById('b1')) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<!-- hidden area to create the ranges being tested -->
<div style="visibility: hidden">
<div id=a1>a1
<div id=b1>b1</div>
</div>
</div>
<script>
description("Test for Bug: 75799 - Calling intersectsNode on a detached range should throw");
var range = document.createRange();
range.selectNode(document.getElementById("a1"));
range.detach();
shouldThrow("range.intersectsNode(document.getElementById('b1'))", '"Error: INVALID_STATE_ERR: DOM Exception 11"');
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
......@@ -44,7 +44,7 @@ PASS intersects is true
PASS intersects is true
2.1 Detached Range, attached node
PASS intersects is false
PASS detachedRange.intersectsNode(document.getElementById('a1')) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
2.2 attached range, detached node
PASS intersects is false
......
......@@ -95,8 +95,7 @@ debug("");
debug("2.1 Detached Range, attached node");
var detachedRange = document.createRange();
detachedRange.detach();
intersects = detachedRange.intersectsNode(document.getElementById("a1"));
shouldBeFalse("intersects");
shouldThrow("detachedRange.intersectsNode(document.getElementById('a1'))", '"Error: INVALID_STATE_ERR: DOM Exception 11"');
debug("");
debug("2.2 attached range, detached node");
......
2012-01-23 Joe Thomas <joethomas@motorola.com>
https://bugs.webkit.org/show_bug.cgi?id=75799
Calling intersectsNode on a detached range should throw.
INVALID_STATE_ERR exception should be thrown if intersectsNode is called on a detached Range.
Reviewed by Darin Adler.
Test: fast/dom/Range/range-intersectsNode-exception.html
* dom/Range.cpp:
(WebCore::Range::intersectsNode): Throwing INVALID_STATE_ERR exception if the range is detached.
2012-01-23 Daniel Cheng <dcheng@chromium.org>
 
Convert DataTransferItem/DataTransferItemList back into an interface class
......@@ -589,14 +589,17 @@ bool Range::intersectsNode(Node* refNode, ExceptionCode& ec)
// http://developer.mozilla.org/en/docs/DOM:range.intersectsNode
// Returns a bool if the node intersects the range.
// Throw exception if the range is already detached.
if (!m_start.container()) {
ec = INVALID_STATE_ERR;
return false;
}
if (!refNode) {
ec = NOT_FOUND_ERR;
return false;
}
if ((!m_start.container() && refNode->attached())
|| (m_start.container() && !refNode->attached())
|| refNode->document() != m_ownerDocument) {
if (!refNode->attached() || refNode->document() != m_ownerDocument) {
// Firefox doesn't throw an exception for these cases; it returns false.
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment