Bug 33510

Summary: selection.modify() should throw an exception if the selection does not have a range or is detached
Product: WebKit Reporter: Justin Lebar <justin.lebar+bug>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WONTFIX    
Severity: Normal CC: ap, ishermandom+bugs, justin.lebar+bug, matspal, mitz, morrita, ojan, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   

Description Justin Lebar 2010-01-11 19:56:11 PST
If we call selection.removeAllRanges() or selection.getRangeAt(0).detach(), then perhaps selection.modify() should throw an exception, indicating that there's no selection to modify.  selection.modify() currently silently fails in this case.
Comment 1 Mats Palmgren 2010-01-11 20:20:14 PST
DOMException INVALID_STATE_ERR is used in HTML5 Selection
when there's something wrong with the selection range:
http://www.whatwg.org/specs/web-apps/current-work/#selection-0

and in DOM-Level-2-Traversal-Range when using a detached range:
http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html#Level-2-Range-idl

so INVALID_STATE_ERR seems like the appropriate exception to use here.
Comment 2 Alexey Proskuryakov 2010-01-11 20:59:29 PST
I don't think we should do that. There is a significant chance that raising an exception where we didn't do that previously will break some pages - and the potential benefit is extremely minor.
Comment 3 Ryosuke Niwa 2010-10-27 23:19:35 PDT
I agree with Alexey.  Throwing an exception at this point will break existing web pages.  Does Firefox 4 throws an exception in such cases?
Comment 4 Hajime Morrita 2010-10-27 23:52:47 PDT
FYI, Bug 33509 had similar discussion and concludes not to throw an exception.
Comment 5 Ryosuke Niwa 2010-10-27 23:55:48 PDT
(In reply to comment #4)
> FYI, Bug 33509 had similar discussion and concludes not to throw an exception.

Ok.  We should close these bugs as invalid.
Comment 6 Ryosuke Niwa 2010-10-27 23:56:04 PDT
Oops, I meant wontfix.
Comment 7 Justin Lebar 2010-10-28 01:29:25 PDT
(In reply to comment #3)
> I agree with Alexey.  Throwing an exception at this point will break existing web pages.  Does Firefox 4 throws an exception in such cases?

We silently fail.  +1 on the WONTFIX.