Skip to content

Commit

Permalink
Merge r180530 - Default value of HTMLSelectElement size IDL attribute…
Browse files Browse the repository at this point in the history
… should be 0.

https://bugs.webkit.org/show_bug.cgi?id=141795

Reviewed by Andreas Kling.

Source/WebCore:

Default value of HTMLSelectElement size IDL attribute should be 0.
As in spec: http://www.w3.org/html/wg/drafts/html/master/forms.html#the-select-element, also this matches the behavior of Chrome, IE and
Gecko.

Test: fast/dom/select-size.html

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::parseAttribute):

LayoutTests:

* fast/dom/select-size-expected.txt: Added.
* fast/dom/select-size.html: Added.
  • Loading branch information
Shivakumar J M authored and carlosgcampos committed Feb 28, 2015
1 parent e1fbb97 commit 530e741
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 1 deletion.
10 changes: 10 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
2015-02-23 Shivakumar JM <shiva.jm@samsung.com>

Default value of HTMLSelectElement size IDL attribute should be 0.
https://bugs.webkit.org/show_bug.cgi?id=141795

Reviewed by Andreas Kling.

* fast/dom/select-size-expected.txt: Added.
* fast/dom/select-size.html: Added.

2015-02-23 Said Abou-Hallawa <sabouhallawa@apple.com>

Drawing an SVG image into a canvas using drawImage() ignores globalAlpha.
Expand Down
36 changes: 36 additions & 0 deletions LayoutTests/fast/dom/select-size-expected.txt
@@ -0,0 +1,36 @@
Test HTMLSelectElement::size behavior.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS select.size is 0
PASS select.setAttribute("size", "1"); select.size is 1
PASS select.setAttribute("size", "2"); select.size is 2
PASS select.setAttribute("size", "3"); select.size is 3
PASS select.setAttribute("size", "4"); select.size is 4
PASS select.setAttribute("size", "0"); select.size is 0
PASS select.setAttribute("size", "-1"); select.size is 0
PASS select.setAttribute("size", "abc"); select.size is 0
PASS select.setAttribute("size", "3.14"); select.size is 3
PASS select.size is 2
PASS select.setAttribute("size", "1"); select.size is 1
PASS select.setAttribute("size", "0"); select.size is 0
PASS select.setAttribute("size", "-1"); select.size is 0
PASS select.setAttribute("size", "abc"); select.size is 0
PASS select.setAttribute("size", "3.14"); select.size is 3
PASS select.size is 0
PASS select.setAttribute("size", "1"); select.size is 1
PASS select.setAttribute("size", "0"); select.size is 0
PASS select.setAttribute("size", "-1"); select.size is 0
PASS select.setAttribute("size", "abc"); select.size is 0
PASS select.setAttribute("size", "3.14"); select.size is 3
PASS select.size is 1
PASS select.setAttribute("size", "2"); select.size is 2
PASS select.setAttribute("size", "0"); select.size is 0
PASS select.setAttribute("size", "-1"); select.size is 0
PASS select.setAttribute("size", "abc"); select.size is 0
PASS select.setAttribute("size", "3.14"); select.size is 3
PASS successfullyParsed is true

TEST COMPLETE

51 changes: 51 additions & 0 deletions LayoutTests/fast/dom/select-size.html
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<select id="test1"></select>
<select id="test2" size=2></select>
<select id="test3" multiple></select>
<select id="test4" multiple size=1></select>
<script>
description('Test HTMLSelectElement::size behavior.');

var select = document.getElementById('test1');
shouldBe('select.size', '0');
shouldBe('select.setAttribute("size", "1"); select.size', '1');
shouldBe('select.setAttribute("size", "2"); select.size', '2');
shouldBe('select.setAttribute("size", "3"); select.size', '3');
shouldBe('select.setAttribute("size", "4"); select.size', '4');
shouldBe('select.setAttribute("size", "0"); select.size', '0');
shouldBe('select.setAttribute("size", "-1"); select.size', '0');
shouldBe('select.setAttribute("size", "abc"); select.size', '0');
shouldBe('select.setAttribute("size", "3.14"); select.size', '3');

var select = document.getElementById('test2');
shouldBe('select.size', '2');
shouldBe('select.setAttribute("size", "1"); select.size', '1');
shouldBe('select.setAttribute("size", "0"); select.size', '0');
shouldBe('select.setAttribute("size", "-1"); select.size', '0');
shouldBe('select.setAttribute("size", "abc"); select.size', '0');
shouldBe('select.setAttribute("size", "3.14"); select.size', '3');

var select = document.getElementById('test3');
shouldBe('select.size', '0');
shouldBe('select.setAttribute("size", "1"); select.size', '1');
shouldBe('select.setAttribute("size", "0"); select.size', '0');
shouldBe('select.setAttribute("size", "-1"); select.size', '0');
shouldBe('select.setAttribute("size", "abc"); select.size', '0');
shouldBe('select.setAttribute("size", "3.14"); select.size', '3');

var select = document.getElementById('test4');
shouldBe('select.size', '1');
shouldBe('select.setAttribute("size", "2"); select.size', '2');
shouldBe('select.setAttribute("size", "0"); select.size', '0');
shouldBe('select.setAttribute("size", "-1"); select.size', '0');
shouldBe('select.setAttribute("size", "abc"); select.size', '0');
shouldBe('select.setAttribute("size", "3.14"); select.size', '3');

</script>
</body>
</html>
16 changes: 16 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,19 @@
2015-02-23 Shivakumar JM <shiva.jm@samsung.com>

Default value of HTMLSelectElement size IDL attribute should be 0.
https://bugs.webkit.org/show_bug.cgi?id=141795

Reviewed by Andreas Kling.

Default value of HTMLSelectElement size IDL attribute should be 0.
As in spec: http://www.w3.org/html/wg/drafts/html/master/forms.html#the-select-element, also this matches the behavior of Chrome, IE and
Gecko.

Test: fast/dom/select-size.html

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::parseAttribute):

2015-02-23 Said Abou-Hallawa <sabouhallawa@apple.com>

Drawing an SVG image into a canvas using drawImage() ignores globalAlpha.
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/html/HTMLSelectElement.cpp
Expand Up @@ -311,7 +311,7 @@ void HTMLSelectElement::parseAttribute(const QualifiedName& name, const AtomicSt
if (Attribute* sizeAttribute = ensureUniqueElementData().findAttributeByName(sizeAttr))
sizeAttribute->setValue(attrSize);
}
size = std::max(size, 1);
size = std::max(size, 0);

// Ensure that we've determined selectedness of the items at least once prior to changing the size.
if (oldSize != size)
Expand Down

0 comments on commit 530e741

Please sign in to comment.