Changeset 105649 in webkit


Ignore:
Timestamp:
Jan 23, 2012 3:46:15 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

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.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r105647 r105649  
     12012-01-23  Joe Thomas  <joethomas@motorola.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=75799
     4        Calling intersectsNode on a detached range should throw.
     5
     6        Added test case to verify the exception thrown while calling intersectsNode on a detached range.
     7
     8        Reviewed by Darin Adler.
     9
     10        * fast/dom/Range/range-intersectsNode-exception-expected.txt: Added.
     11        * fast/dom/Range/range-intersectsNode-exception.html: Added.
     12        * fast/dom/Range/range-intersectsNode-expected.txt:
     13        * fast/dom/Range/resources/intersectsNode.js:  Modified the test case to catch the exception.
     14
    1152012-01-23  Mike Lawther  <mikelawther@chromium.org>
    216
  • trunk/LayoutTests/fast/dom/Range/range-intersectsNode-expected.txt

    r30635 r105649  
    4545
    46462.1 Detached Range, attached node
    47 PASS intersects is false
     47PASS detachedRange.intersectsNode(document.getElementById('a1')) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
    4848
    49492.2 attached range, detached node
  • trunk/LayoutTests/fast/dom/Range/resources/intersectsNode.js

    r98407 r105649  
    9696var detachedRange = document.createRange();
    9797detachedRange.detach();
    98 intersects = detachedRange.intersectsNode(document.getElementById("a1"));
    99 shouldBeFalse("intersects");
     98shouldThrow("detachedRange.intersectsNode(document.getElementById('a1'))", '"Error: INVALID_STATE_ERR: DOM Exception 11"');
    10099debug("");
    101100
  • trunk/Source/WebCore/ChangeLog

    r105648 r105649  
     12012-01-23  Joe Thomas  <joethomas@motorola.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=75799
     4        Calling intersectsNode on a detached range should throw.
     5
     6        INVALID_STATE_ERR exception should be thrown if intersectsNode is called on a detached Range.
     7
     8        Reviewed by Darin Adler.
     9
     10        Test: fast/dom/Range/range-intersectsNode-exception.html
     11
     12        * dom/Range.cpp:
     13        (WebCore::Range::intersectsNode): Throwing INVALID_STATE_ERR exception if the range is detached.
     14
    1152012-01-23  Daniel Cheng  <dcheng@chromium.org>
    216
  • trunk/Source/WebCore/dom/Range.cpp

    r97480 r105649  
    590590    // Returns a bool if the node intersects the range.
    591591
     592    // Throw exception if the range is already detached.
     593    if (!m_start.container()) {
     594        ec = INVALID_STATE_ERR;
     595        return false;
     596    }
    592597    if (!refNode) {
    593598        ec = NOT_FOUND_ERR;
    594599        return false;
    595600    }
    596    
    597     if ((!m_start.container() && refNode->attached())
    598             || (m_start.container() && !refNode->attached())
    599             || refNode->document() != m_ownerDocument) {
     601
     602    if (!refNode->attached() || refNode->document() != m_ownerDocument) {
    600603        // Firefox doesn't throw an exception for these cases; it returns false.
    601604        return false;
Note: See TracChangeset for help on using the changeset viewer.