Bug 44595

Summary: DOM Selection: collapse() and selectAllChildren() should throw WRONG_DOCUMENT_ERR if node belongs to other document
Product: WebKit Reporter: Andreas Kling <kling>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED LATER    
Severity: Normal CC: abarth, ap, eric, webkit.review.bot
Priority: P2 Keywords: HTML5
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on: 45104    
Bug Blocks:    
Attachments:
Description Flags
Proposed patch none

Description Andreas Kling 2010-08-25 02:37:04 PDT
Selection.collapse() and Selection.selectAllChildren() should throw WRONG_DOCUMENT_ERR if the input node doesn't belong to the same document at the Selection.

This would cause us to pass the following test on IE Test Center:
http://samples.msdn.microsoft.com/ietestcenter/html5/selection/selection_wrongDocErr.htm

Spec links:
http://www.whatwg.org/specs/web-apps/current-work/#dom-selection-collapse
http://www.whatwg.org/specs/web-apps/current-work/#dom-selection-selectallchildren
Comment 1 Andreas Kling 2010-08-25 02:43:17 PDT
Created attachment 65387 [details]
Proposed patch
Comment 2 Alexey Proskuryakov 2010-08-25 09:58:00 PDT
Do these raise an exception in Firefox?

Raising exceptions where we didn't use to can be a significant compatibility issue, because if any page depended on the old behavior, it often stops working completely.
Comment 3 Andreas Kling 2010-08-25 10:04:28 PDT
(In reply to comment #2)
> Do these raise an exception in Firefox?

No, only IE9 implements this behavior so far AFAIK.
Comment 4 Antonio Gomes 2010-08-25 23:05:43 PDT
Comment on attachment 65387 [details]
Proposed patch

Gerally it also looks good to me. We need to find out the impact of such a change in existing web contents, witch is hard :-(
Comment 5 Darin Adler 2010-08-29 11:44:24 PDT
Comment on attachment 65387 [details]
Proposed patch

> +    const Document* selectionDocument = m_frame ? m_frame->document() : 0;
> +    const Document* nodeDocument = node ? node->document() : 0;

The const here does no good.

> +    const Document* selectionDocument = m_frame ? m_frame->document() : 0;

Same here.

I’d like this even better if the regression test covered the null frame and null node cases. I can't tell if it does.

r=me
Comment 6 Andreas Kling 2010-09-02 03:50:39 PDT
Committed r66655: <http://trac.webkit.org/changeset/66655>
Comment 7 WebKit Review Bot 2010-09-02 04:37:24 PDT
http://trac.webkit.org/changeset/66655 might have broken Leopard Intel Release (Tests)
Comment 8 Andreas Kling 2010-09-02 04:49:49 PDT
Reopening due to editing test breakage.
Comment 9 Alexey Proskuryakov 2010-09-08 13:34:50 PDT
What is the status of this bug? The patch been rolled out, correct?

See also: https://bugzilla.mozilla.org/show_bug.cgi?id=418755.
Comment 10 Andreas Kling 2010-09-08 13:40:21 PDT
(In reply to comment #9)
> What is the status of this bug? The patch been rolled out, correct?
> 
> See also: https://bugzilla.mozilla.org/show_bug.cgi?id=418755.

It was rolled out indeed (with r66661)

Interesting link, I'll close this. We can revisit the issue at a later time.