Bug 61675

Summary: <input> size attribute should throw INDEX_SIZE_ERR when set to 0
Product: WebKit Reporter: rasamassen
Component: FormsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Minor CC: abarth, ap, ayg, ksakamoto, mifenton, ojan, tkent, webkit.review.bot
Priority: P2 Keywords: WebExposed
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch 2 none

Description rasamassen 2011-05-27 16:11:30 PDT
Per http://www.w3.org/TR/html5/common-input-element-attributes.html#attr-input-size: attribute is limited to only non-negative numbers greater than zero and has a default value of 20: If, on the other hand, it fails or returns an out of range value, or if the attribute is absent, the default value must be returned instead.

Setting attribute to 5147483649, 0, and -1 does not return 20 for property value.
Comment 1 Alexey Proskuryakov 2011-05-27 23:57:33 PDT
Duplicate of bug 44886?
Comment 2 Aryeh Gregor 2011-05-29 10:52:38 PDT
Getting input.size has the wrong value when the content attribute is missing/negative/out-of-range.  That's bug 44886, and also seems to be what comment #0 is talking about (comment #0 does not provide any test-case I can use to check).  The only further bug I see in input.size is that it should throw when set to 0, per spec, but doesn't in Chrome 13 dev.  My reflection tests cover this:

http://dvcs.w3.org/hg/html/raw-file/e24159ebba83/tests/submission/AryehGregor/reflection/reflection-original.html

The following test shows that IE9 and Firefox 5.0a2 throw when you set input.size to 0, Chrome 13 dev and Opera 11.10 don't:

http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!doctype%20html%3E%0A%3Cscript%3E%0Atry%20%7B%0Adocument.createElement(%22input%22).size%20%3D%200%3B%0Aw(%22No%20exception%22)%3B%0A%7D%20catch(e)%20%7B%20w(e)%20%7D%0A%3C%2Fscript%3E
Comment 3 Kunihiko Sakamoto 2012-10-03 22:54:08 PDT
Created attachment 167035 [details]
Patch
Comment 4 Build Bot 2012-10-03 23:01:35 PDT
Comment on attachment 167035 [details]
Patch

Attachment 167035 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/14152382
Comment 5 Kent Tamura 2012-10-03 23:16:07 PDT
Comment on attachment 167035 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=167035&action=review

> Source/WebCore/ChangeLog:3
> +        <input> size attribute does not return default when attribute outofrange

This is the bug title, but it doesn't match what you will fix.
It seems the original issue was already fixed, and you'll fix Comment #2, right?  If so, we should change the bug title.

> Source/WebCore/html/HTMLInputElement.h:210
> -    void setSize(unsigned);
> +    void setSize(unsigned, ExceptionCode&);

Unfortunately Objective-C binding needs setSize(unsigned).  We should have both.

> LayoutTests/ChangeLog:11
> +        * fast/forms/input-size-expected.txt: Added.
> +        * fast/forms/input-size.html: Added.

We already have fast/dom/HTMLInputElement/input-size-attribute.html.  Would you add your test case to it please?
Comment 6 Kent Tamura 2012-10-03 23:16:59 PDT
Comment on attachment 167035 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=167035&action=review

> Source/WebCore/ChangeLog:11
> +        According to the spec, the size IDL attribute of input elements is limited
> +        to only non-negative numbers greater than zero. It should throw INDEX_SIZE_ERR
> +        exception when set to 0.
> +        Spec: http://www.w3.org/TR/html5/common-input-element-attributes.html#the-size-attribute

good explanation.
It would be better if you add behavior of other browsers.
Comment 7 Kunihiko Sakamoto 2012-10-04 21:34:05 PDT
Created attachment 167243 [details]
Patch 2
Comment 8 Kunihiko Sakamoto 2012-10-04 21:36:37 PDT
Thank you for the comments.
Updated the patch reflecting your comments. It also fixes fast/forms/number/number-size.html.
Please take another look.
Comment 9 Kunihiko Sakamoto 2012-10-04 21:37:50 PDT
Comment on attachment 167035 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=167035&action=review

>> Source/WebCore/ChangeLog:3
>> +        <input> size attribute does not return default when attribute outofrange
> 
> This is the bug title, but it doesn't match what you will fix.
> It seems the original issue was already fixed, and you'll fix Comment #2, right?  If so, we should change the bug title.

I've changed this summary line in the new patch. How can we change the bug title on bugzilla as well?
Comment 10 Kent Tamura 2012-10-04 23:29:08 PDT
(In reply to comment #9)
> I've changed this summary line in the new patch. How can we change the bug title on bugzilla as well?

I think you don't have a EditBug permission. I'll update it.
Comment 11 Kent Tamura 2012-10-04 23:30:17 PDT
Comment on attachment 167243 [details]
Patch 2

View in context: https://bugs.webkit.org/attachment.cgi?id=167243&action=review

> Source/WebCore/ChangeLog:19
> +        * html/HTMLInputElement.cpp:
> +        (WebCore::HTMLInputElement::setSize):
> +        * html/HTMLInputElement.h:
> +        (HTMLInputElement):
> +        * html/HTMLInputElement.idl:

You had better add per-file / per-function comments as possible.
Comment 12 WebKit Review Bot 2012-10-04 23:41:21 PDT
Comment on attachment 167243 [details]
Patch 2

Clearing flags on attachment: 167243

Committed r130469: <http://trac.webkit.org/changeset/130469>
Comment 13 WebKit Review Bot 2012-10-04 23:41:25 PDT
All reviewed patches have been landed.  Closing bug.