Bug 23300 - Selection functions should throw exceptions when used on buttons
Summary: Selection functions should throw exceptions when used on buttons
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-13 12:39 PST by Mads Ager
Modified: 2009-01-27 09:24 PST (History)
2 users (show)

See Also:


Attachments
Patch (7.19 KB, patch)
2009-01-13 12:44 PST, Mads Ager
no flags Details | Formatted Diff | Diff
Updated to throw exceptions in selectionStart and selectionEnd setters (8.11 KB, patch)
2009-01-15 12:33 PST, Mads Ager
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mads Ager 2009-01-13 12:39:54 PST
Firefox throws exceptions when using selection functions on HTMLInputElements that do not support selection.  Maybe WebKit should to?

Patch on its way.
Comment 1 Mads Ager 2009-01-13 12:44:10 PST
Created attachment 26680 [details]
Patch
Comment 2 Sam Weinig 2009-01-13 12:52:28 PST
Are there any known sites that require this?
Comment 3 Mads Ager 2009-01-13 13:11:51 PST
(In reply to comment #2)
> Are there any known sites that require this?

Not that I know of, no.

As far as I can tell, we have tried to be compatible with Firefox here. The selection-function test seemed to pass on Firefox but only because it throws exceptions along the way.

I like the fact that this gets rid of the custom getOwnPropertySlot implementation.  Come to think of it, that custom implementation will get in the way of changes to setSelectionRange on buttons:

  HTMLInputElement.prototype.setSelectionRange = function(){};
  var b = document.getElementById("button");
  b.setSelectionRange;   // <--- undefined

Also, returning undefined will probably lead to exceptions throw in the code anyway since people will most likely try to call the function or use the value of the attributes?
Comment 4 Sam Weinig 2009-01-13 14:15:57 PST
What does IE do?  I am always hesitant to throw exceptions as they can often break un-expecting scripts.
Comment 5 Mads Ager 2009-01-13 23:13:51 PST
IE does not support the selection attributes and functions on HTMLInputElements.  Therefore, I think that Firefox compatibility should be the goal for these functions. 
Comment 6 Darin Adler 2009-01-15 08:24:17 PST
This takes care of the getter for selectionStart, for selectionEnd, and the function setSelectionRange. What about the setters for selectionStart and selectionEnd? Is it appropriate for them to silently do nothing, or should they be throwing exceptions too?
Comment 7 Mads Ager 2009-01-15 12:11:26 PST
Good point, thanks!  The setters should be throwing exceptions as well.  I'll upload an updated patch ASAP.
Comment 8 Mads Ager 2009-01-15 12:33:26 PST
Created attachment 26768 [details]
Updated to throw exceptions in selectionStart and selectionEnd setters
Comment 9 Mads Ager 2009-01-22 22:55:42 PST
Darin and Sam, could one of you guys have a look at this again?  Thanks.
Comment 10 Darin Adler 2009-01-26 19:38:40 PST
Comment on attachment 26768 [details]
Updated to throw exceptions in selectionStart and selectionEnd setters

r=me
Comment 11 Dimitri Glazkov (Google) 2009-01-27 09:24:55 PST
Committed in http://trac.webkit.org/changeset/40293