RESOLVED FIXED 61675
<input> size attribute should throw INDEX_SIZE_ERR when set to 0
https://bugs.webkit.org/show_bug.cgi?id=61675
Summary <input> size attribute should throw INDEX_SIZE_ERR when set to 0
rasamassen
Reported 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.
Attachments
Patch (5.06 KB, patch)
2012-10-03 22:54 PDT, Kunihiko Sakamoto
no flags
Patch 2 (7.02 KB, patch)
2012-10-04 21:34 PDT, Kunihiko Sakamoto
no flags
Alexey Proskuryakov
Comment 1 2011-05-27 23:57:33 PDT
Duplicate of bug 44886?
Aryeh Gregor
Comment 2 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
Kunihiko Sakamoto
Comment 3 2012-10-03 22:54:08 PDT
Build Bot
Comment 4 2012-10-03 23:01:35 PDT
Kent Tamura
Comment 5 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?
Kent Tamura
Comment 6 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.
Kunihiko Sakamoto
Comment 7 2012-10-04 21:34:05 PDT
Kunihiko Sakamoto
Comment 8 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.
Kunihiko Sakamoto
Comment 9 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?
Kent Tamura
Comment 10 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.
Kent Tamura
Comment 11 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.
WebKit Review Bot
Comment 12 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>
WebKit Review Bot
Comment 13 2012-10-04 23:41:25 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.