| Index: Source/core/html/HTMLSelectElement.cpp
|
| diff --git a/Source/core/html/HTMLSelectElement.cpp b/Source/core/html/HTMLSelectElement.cpp
|
| index a1305e285839e0d4f038c3507a3a0a1f5e45925e..93af0b216963e078bdb62f8c9b3a07511ae8bae7 100644
|
| --- a/Source/core/html/HTMLSelectElement.cpp
|
| +++ b/Source/core/html/HTMLSelectElement.cpp
|
| @@ -51,6 +51,7 @@
|
| #include "core/html/HTMLOptionElement.h"
|
| #include "core/html/forms/FormController.h"
|
| #include "core/input/EventHandler.h"
|
| +#include "core/inspector/ConsoleMessage.h"
|
| #include "core/layout/HitTestRequest.h"
|
| #include "core/layout/HitTestResult.h"
|
| #include "core/layout/LayoutListBox.h"
|
| @@ -467,8 +468,11 @@ HTMLOptionElement* HTMLSelectElement::item(unsigned index)
|
|
|
| void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, ExceptionState& exceptionState)
|
| {
|
| - if (index > maxSelectItems - 1)
|
| - index = maxSelectItems - 1;
|
| + if (index >= length() && index >= maxSelectItems) {
|
| + document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel,
|
| + String::format("Blocked to expand the option list and set an option at index=%u. The maximum list length is %u.", index, maxSelectItems)));
|
| + return;
|
| + }
|
| int diff = index - length();
|
| HTMLOptionElementOrHTMLOptGroupElement element;
|
| element.setHTMLOptionElement(option);
|
| @@ -491,8 +495,11 @@ void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, Exc
|
|
|
| void HTMLSelectElement::setLength(unsigned newLen, ExceptionState& exceptionState)
|
| {
|
| - if (newLen > maxSelectItems)
|
| + if (newLen > length() && newLen > maxSelectItems) {
|
| + document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel,
|
| + String::format("Blocked to expand the option list to %u items. The maximum list length is %u.", newLen, maxSelectItems)));
|
| return;
|
| + }
|
| int diff = length() - newLen;
|
|
|
| if (diff < 0) { // Add dummy elements.
|
|
|