Title: [124506] trunk
- Revision
- 124506
- Author
- [email protected]
- Date
- 2012-08-02 14:59:47 -0700 (Thu, 02 Aug 2012)
Log Message
Range::isPointInRange incorrectly throws WRONG_DOCUMENT_ERR
https://bugs.webkit.org/show_bug.cgi?id=93009
Reviewed by Ojan Vafai.
Source/WebCore:
The latest working draft of the DOM4 spec has all but killed the
WRONG_DOCUMENT_ERR exception. Update isPointInRange to return false
instead of throwing an exception when the range and point are in
different documents. This matches the Mozilla behavior.
Test: fast/html/range-point-in-range-for-different-documents.html
* dom/Range.cpp:
(WebCore::Range::isPointInRange):
Return false instead of throwing WRONG_DOCUMENT_ERR when the point is in
a different document.
LayoutTests:
Add test for Range::isPointInRange where the point is in a different
document than the range.
* fast/dom/move-nodes-across-documents.html: Change expectations for isPointInRange
* fast/html/range-point-in-range-for-different-documents-expected.txt: Added.
* fast/html/range-point-in-range-for-different-documents.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (124505 => 124506)
--- trunk/LayoutTests/ChangeLog 2012-08-02 21:58:51 UTC (rev 124505)
+++ trunk/LayoutTests/ChangeLog 2012-08-02 21:59:47 UTC (rev 124506)
@@ -1,3 +1,17 @@
+2012-08-02 Emil A Eklund <[email protected]>
+
+ Range::isPointInRange incorrectly throws WRONG_DOCUMENT_ERR
+ https://bugs.webkit.org/show_bug.cgi?id=93009
+
+ Reviewed by Ojan Vafai.
+
+ Add test for Range::isPointInRange where the point is in a different
+ document than the range.
+
+ * fast/dom/move-nodes-across-documents.html: Change expectations for isPointInRange
+ * fast/html/range-point-in-range-for-different-documents-expected.txt: Added.
+ * fast/html/range-point-in-range-for-different-documents.html: Added.
+
2012-08-02 Erik Arvidsson <[email protected]>
DOM4: className should be defined on Element and not on HTMLElement
Modified: trunk/LayoutTests/fast/dom/move-nodes-across-documents.html (124505 => 124506)
--- trunk/LayoutTests/fast/dom/move-nodes-across-documents.html 2012-08-02 21:58:51 UTC (rev 124505)
+++ trunk/LayoutTests/fast/dom/move-nodes-across-documents.html 2012-08-02 21:59:47 UTC (rev 124506)
@@ -201,12 +201,9 @@
runTest(function() {
rangeInIframe().setEndAfter(elementInCurrentDocument('setEndAfter'), 0);
});
-
- // FIXME: isPointInRange isn't specced anywhere, but Gecko doesn't throw an exception here.
- // It doesn't seem like we should either. Gecko returns false.
runTest(function() {
rangeInIframe().isPointInRange(elementInCurrentDocument('isPointInRange'), 0);
- }, 'WRONG_DOCUMENT_ERR');
+ });
}
</script>
Added: trunk/LayoutTests/fast/html/range-point-in-range-for-different-documents-expected.txt (0 => 124506)
--- trunk/LayoutTests/fast/html/range-point-in-range-for-different-documents-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/html/range-point-in-range-for-different-documents-expected.txt 2012-08-02 21:59:47 UTC (rev 124506)
@@ -0,0 +1,2 @@
+PASS range.isPointInRange(testNode, 1) is false
+This tests the behavior of Range::isPointInRange when the point and the range are in different documents.
Added: trunk/LayoutTests/fast/html/range-point-in-range-for-different-documents.html (0 => 124506)
--- trunk/LayoutTests/fast/html/range-point-in-range-for-different-documents.html (rev 0)
+++ trunk/LayoutTests/fast/html/range-point-in-range-for-different-documents.html 2012-08-02 21:59:47 UTC (rev 124506)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src=""
+ </head>
+ <body>
+ <p>
+ This tests the behavior of Range::isPointInRange when the point and
+ the range are in different documents.
+ </p>
+
+ <script>
+ var docType = document.implementation.createDocumentType ('html', '', '');
+ var doc = document.implementation.createDocument('', 'html', docType);
+ var body = document.createElement('body');
+ doc.documentElement.appendChild(body);
+ var testContainer = document.createElement('span');
+ testContainer.appendChild(document.createTextNode('Test container'));
+ body.appendChild(testContainer);
+
+ var range = document.createRange();
+ range.selectNode(testContainer);
+ var testNode = document.createElement('p');
+ testNode.appendChild(document.createTextNode('Test node'));
+ document.body.appendChild(testNode);
+
+ try {
+ shouldBeFalse("range.isPointInRange(testNode, 1)");
+ }
+ catch (error) {
+ testFailed('isPointInRange throw an exception of type ' + error.code + '.');
+ }
+
+ document.body.removeChild(testNode);
+ </script>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (124505 => 124506)
--- trunk/Source/WebCore/ChangeLog 2012-08-02 21:58:51 UTC (rev 124505)
+++ trunk/Source/WebCore/ChangeLog 2012-08-02 21:59:47 UTC (rev 124506)
@@ -1,3 +1,22 @@
+2012-08-02 Emil A Eklund <[email protected]>
+
+ Range::isPointInRange incorrectly throws WRONG_DOCUMENT_ERR
+ https://bugs.webkit.org/show_bug.cgi?id=93009
+
+ Reviewed by Ojan Vafai.
+
+ The latest working draft of the DOM4 spec has all but killed the
+ WRONG_DOCUMENT_ERR exception. Update isPointInRange to return false
+ instead of throwing an exception when the range and point are in
+ different documents. This matches the Mozilla behavior.
+
+ Test: fast/html/range-point-in-range-for-different-documents.html
+
+ * dom/Range.cpp:
+ (WebCore::Range::isPointInRange):
+ Return false instead of throwing WRONG_DOCUMENT_ERR when the point is in
+ a different document.
+
2012-08-02 Erik Arvidsson <[email protected]>
DOM4: className should be defined on Element and not on HTMLElement
Modified: trunk/Source/WebCore/dom/Range.cpp (124505 => 124506)
--- trunk/Source/WebCore/dom/Range.cpp 2012-08-02 21:58:51 UTC (rev 124505)
+++ trunk/Source/WebCore/dom/Range.cpp 2012-08-02 21:59:47 UTC (rev 124506)
@@ -303,16 +303,10 @@
return false;
}
- if (!refNode->attached()) {
- // Firefox doesn't throw an exception for this case; it returns false.
+ if (!refNode->attached() || refNode->document() != m_ownerDocument) {
return false;
}
- if (refNode->document() != m_ownerDocument) {
- ec = WRONG_DOCUMENT_ERR;
- return false;
- }
-
ec = 0;
checkNodeWOffset(refNode, offset, ec);
if (ec)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes