Bug 44598

Summary: DOM Selection: collapseToStart() and collapseToEnd() should throw INVALID_STATE_ERR if there's no selection
Product: WebKit Reporter: Andreas Kling <kling>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ap
Priority: P2 Keywords: HTML5
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Proposed patch none

Description Andreas Kling 2010-08-25 03:39:03 PDT
Selection.collapseToStart() and Selection.collapseToEnd() should throw INVALID_STATE_ERR if no selection is made.

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

Spec links:
http://www.whatwg.org/specs/web-apps/current-work/#dom-selection-collapsetostart
http://www.whatwg.org/specs/web-apps/current-work/#dom-selection-collapsetoend
Comment 1 Andreas Kling 2010-08-25 03:42:31 PDT
Created attachment 65396 [details]
Proposed patch
Comment 2 Alexey Proskuryakov 2010-08-25 09:57:03 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:03:02 PDT
(In reply to comment #2)
> Do these raise an exception in Firefox?

No, only IE9 implements this behavior so far AFAIK.
Comment 4 Andreas Kling 2010-09-01 03:23:30 PDT
Comment on attachment 65396 [details]
Proposed patch

Clearing flags on attachment: 65396

Committed r66590: <http://trac.webkit.org/changeset/66590>
Comment 5 Andreas Kling 2010-09-01 03:23:40 PDT
All reviewed patches have been landed.  Closing bug.