| Index: Source/core/html/HTMLInputElement.cpp
|
| diff --git a/Source/core/html/HTMLInputElement.cpp b/Source/core/html/HTMLInputElement.cpp
|
| index c35f154fd81cdb6d015e4ea478b9121db9dec279..d46737676653e43d7ed6dfc2a01447812542f224 100644
|
| --- a/Source/core/html/HTMLInputElement.cpp
|
| +++ b/Source/core/html/HTMLInputElement.cpp
|
| @@ -32,6 +32,7 @@
|
| #include "CSSPropertyNames.h"
|
| #include "HTMLNames.h"
|
| #include "RuntimeEnabledFeatures.h"
|
| +#include "bindings/v8/ExceptionMessages.h"
|
| #include "bindings/v8/ExceptionState.h"
|
| #include "bindings/v8/ScriptEventListener.h"
|
| #include "core/accessibility/AXObjectCache.h"
|
| @@ -524,7 +525,7 @@ bool HTMLInputElement::canHaveSelection() const
|
| int HTMLInputElement::selectionStartForBinding(ExceptionState& exceptionState) const
|
| {
|
| if (!canHaveSelection()) {
|
| - exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| + exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToGet("selectionStart", "HTMLInputElement", "The input element's type ('" + m_inputType->formControlType() + "') does not support selection."));
|
| return 0;
|
| }
|
| return HTMLTextFormControlElement::selectionStart();
|
| @@ -533,7 +534,7 @@ int HTMLInputElement::selectionStartForBinding(ExceptionState& exceptionState) c
|
| int HTMLInputElement::selectionEndForBinding(ExceptionState& exceptionState) const
|
| {
|
| if (!canHaveSelection()) {
|
| - exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| + exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToGet("selectionEnd", "HTMLInputElement", "The input element's type ('" + m_inputType->formControlType() + "') does not support selection."));
|
| return 0;
|
| }
|
| return HTMLTextFormControlElement::selectionEnd();
|
| @@ -542,7 +543,7 @@ int HTMLInputElement::selectionEndForBinding(ExceptionState& exceptionState) con
|
| String HTMLInputElement::selectionDirectionForBinding(ExceptionState& exceptionState) const
|
| {
|
| if (!canHaveSelection()) {
|
| - exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| + exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToGet("selectionDirection", "HTMLInputElement", "The input element's type ('" + m_inputType->formControlType() + "') does not support selection."));
|
| return String();
|
| }
|
| return HTMLTextFormControlElement::selectionDirection();
|
| @@ -551,7 +552,7 @@ String HTMLInputElement::selectionDirectionForBinding(ExceptionState& exceptionS
|
| void HTMLInputElement::setSelectionStartForBinding(int start, ExceptionState& exceptionState)
|
| {
|
| if (!canHaveSelection()) {
|
| - exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| + exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToSet("selectionStart", "HTMLInputElement", "The input element's type ('" + m_inputType->formControlType() + "') does not support selection."));
|
| return;
|
| }
|
| HTMLTextFormControlElement::setSelectionStart(start);
|
| @@ -560,7 +561,7 @@ void HTMLInputElement::setSelectionStartForBinding(int start, ExceptionState& ex
|
| void HTMLInputElement::setSelectionEndForBinding(int end, ExceptionState& exceptionState)
|
| {
|
| if (!canHaveSelection()) {
|
| - exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| + exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToSet("selectionEnd", "HTMLInputElement", "The input element's type ('" + m_inputType->formControlType() + "') does not support selection."));
|
| return;
|
| }
|
| HTMLTextFormControlElement::setSelectionEnd(end);
|
| @@ -569,7 +570,7 @@ void HTMLInputElement::setSelectionEndForBinding(int end, ExceptionState& except
|
| void HTMLInputElement::setSelectionDirectionForBinding(const String& direction, ExceptionState& exceptionState)
|
| {
|
| if (!canHaveSelection()) {
|
| - exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| + exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToSet("selectionDirection", "HTMLInputElement", "The input element's type ('" + m_inputType->formControlType() + "') does not support selection."));
|
| return;
|
| }
|
| HTMLTextFormControlElement::setSelectionDirection(direction);
|
| @@ -578,7 +579,7 @@ void HTMLInputElement::setSelectionDirectionForBinding(const String& direction,
|
| void HTMLInputElement::setSelectionRangeForBinding(int start, int end, ExceptionState& exceptionState)
|
| {
|
| if (!canHaveSelection()) {
|
| - exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| + exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToSet("selectionRange", "HTMLInputElement", "The input element's type ('" + m_inputType->formControlType() + "') does not support selection."));
|
| return;
|
| }
|
| HTMLTextFormControlElement::setSelectionRange(start, end);
|
| @@ -587,7 +588,7 @@ void HTMLInputElement::setSelectionRangeForBinding(int start, int end, Exception
|
| void HTMLInputElement::setSelectionRangeForBinding(int start, int end, const String& direction, ExceptionState& exceptionState)
|
| {
|
| if (!canHaveSelection()) {
|
| - exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| + exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToSet("selectionRange", "HTMLInputElement", "The input element's type ('" + m_inputType->formControlType() + "') does not support selection."));
|
| return;
|
| }
|
| HTMLTextFormControlElement::setSelectionRange(start, end, direction);
|
| @@ -1001,7 +1002,7 @@ void HTMLInputElement::setEditingValue(const String& value)
|
| void HTMLInputElement::setValue(const String& value, ExceptionState& exceptionState, TextFieldEventBehavior eventBehavior)
|
| {
|
| if (isFileUpload() && !value.isEmpty()) {
|
| - exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| + exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToSet("value", "HTMLInputElement", "This input element accepts a filename, which may only be programatically set to the empty string."));
|
| return;
|
| }
|
| setValue(value, eventBehavior);
|
| @@ -1057,7 +1058,7 @@ double HTMLInputElement::valueAsNumber() const
|
| void HTMLInputElement::setValueAsNumber(double newValue, ExceptionState& exceptionState, TextFieldEventBehavior eventBehavior)
|
| {
|
| if (!std::isfinite(newValue)) {
|
| - exceptionState.throwUninformativeAndGenericDOMException(NotSupportedError);
|
| + exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::failedToSet("valueAsNumber", "HTMLInputElement", ExceptionMessages::notAFiniteNumber(newValue)));
|
| return;
|
| }
|
| m_inputType->setValueAsDouble(newValue, eventBehavior, exceptionState);
|
| @@ -1292,7 +1293,7 @@ int HTMLInputElement::maxLength() const
|
| void HTMLInputElement::setMaxLength(int maxLength, ExceptionState& exceptionState)
|
| {
|
| if (maxLength < 0)
|
| - exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError);
|
| + exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::failedToSet("maxLength", "HTMLInputElement", "The value provided (" + String::number(maxLength) + ") is negative."));
|
| else
|
| setIntegralAttribute(maxlengthAttr, maxLength);
|
| }
|
| @@ -1310,7 +1311,7 @@ void HTMLInputElement::setSize(unsigned size)
|
| void HTMLInputElement::setSize(unsigned size, ExceptionState& exceptionState)
|
| {
|
| if (!size)
|
| - exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError);
|
| + exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::failedToSet("size", "HTMLInputElement", "The value provided is 0, which is an invalid size."));
|
| else
|
| setSize(size);
|
| }
|
| @@ -1793,7 +1794,7 @@ void ListAttributeTargetObserver::idTargetChanged()
|
| void HTMLInputElement::setRangeText(const String& replacement, ExceptionState& exceptionState)
|
| {
|
| if (!m_inputType->supportsSelectionAPI()) {
|
| - exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| + exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecute("setRangeText", "HTMLInputElement", "The input element's type ('" + m_inputType->formControlType() + "') does not support selection."));
|
| return;
|
| }
|
|
|
| @@ -1803,7 +1804,7 @@ void HTMLInputElement::setRangeText(const String& replacement, ExceptionState& e
|
| void HTMLInputElement::setRangeText(const String& replacement, unsigned start, unsigned end, const String& selectionMode, ExceptionState& exceptionState)
|
| {
|
| if (!m_inputType->supportsSelectionAPI()) {
|
| - exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| + exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecute("setRangeText", "HTMLInputElement", "The input element's type ('" + m_inputType->formControlType() + "') does not support selection."));
|
| return;
|
| }
|
|
|
|
|