|
37 | 37 | import org.htmlunit.javascript.configuration.JsxFunction; |
38 | 38 | import org.htmlunit.javascript.configuration.JsxGetter; |
39 | 39 | import org.htmlunit.javascript.configuration.JsxSetter; |
| 40 | +import org.htmlunit.javascript.host.dom.DOMException; |
40 | 41 | import org.htmlunit.javascript.host.dom.NodeList; |
41 | 42 | import org.htmlunit.javascript.host.event.Event; |
42 | 43 | import org.htmlunit.javascript.host.file.FileList; |
@@ -105,8 +106,11 @@ public void setValue(final Object newValue) { |
105 | 106 | final String val = JavaScriptEngine.toString(newValue); |
106 | 107 | if ("file".equalsIgnoreCase(getType())) { |
107 | 108 | if (StringUtils.isNotEmpty(val)) { |
108 | | - throw JavaScriptEngine.reportRuntimeError("InvalidStateError: " |
109 | | - + "Failed to set the 'value' property on 'HTMLInputElement'."); |
| 109 | + throw JavaScriptEngine.asJavaScriptException( |
| 110 | + getWindow(), |
| 111 | + new DOMException( |
| 112 | + "Failed to set the 'value' property on 'HTMLInputElement'.", |
| 113 | + DOMException.INVALID_STATE_ERR)); |
110 | 114 | } |
111 | 115 | return; |
112 | 116 | } |
@@ -237,18 +241,25 @@ public void setSelectionStart(final int start) { |
237 | 241 | final DomNode dom = getDomNodeOrDie(); |
238 | 242 | if (dom instanceof SelectableTextInput) { |
239 | 243 | if ("number".equalsIgnoreCase(getType())) { |
240 | | - throw JavaScriptEngine.reportRuntimeError("Failed to set the 'selectionStart' property" |
241 | | - + "from 'HTMLInputElement': " |
242 | | - + "The input element's type ('number') does not support selection."); |
| 244 | + throw JavaScriptEngine.asJavaScriptException( |
| 245 | + getWindow(), |
| 246 | + new DOMException( |
| 247 | + "Failed to set the 'selectionStart' property" |
| 248 | + + "from 'HTMLInputElement': " |
| 249 | + + "The input element's type ('number') does not support selection.", |
| 250 | + DOMException.INVALID_STATE_ERR)); |
243 | 251 | } |
244 | 252 |
|
245 | 253 | ((SelectableTextInput) dom).setSelectionStart(start); |
246 | 254 | return; |
247 | 255 | } |
248 | 256 |
|
249 | | - throw JavaScriptEngine.reportRuntimeError( |
250 | | - "Failed to set the 'selectionStart' property from 'HTMLInputElement': " |
251 | | - + "The input element's type (" + getType() + ") does not support selection."); |
| 257 | + throw JavaScriptEngine.asJavaScriptException( |
| 258 | + getWindow(), |
| 259 | + new DOMException( |
| 260 | + "Failed to set the 'selectionStart' property from 'HTMLInputElement': " |
| 261 | + + "The input element's type (" + getType() + ") does not support selection.", |
| 262 | + DOMException.INVALID_STATE_ERR)); |
252 | 263 | } |
253 | 264 |
|
254 | 265 | /** |
@@ -278,17 +289,25 @@ public void setSelectionEnd(final int end) { |
278 | 289 | final DomNode dom = getDomNodeOrDie(); |
279 | 290 | if (dom instanceof SelectableTextInput) { |
280 | 291 | if ("number".equalsIgnoreCase(getType())) { |
281 | | - throw JavaScriptEngine.reportRuntimeError("Failed to set the 'selectionEnd' property" |
282 | | - + "from 'HTMLInputElement': " |
283 | | - + "The input element's type ('number') does not support selection."); |
| 292 | + throw JavaScriptEngine.asJavaScriptException( |
| 293 | + getWindow(), |
| 294 | + new DOMException( |
| 295 | + "Failed to set the 'selectionEnd' property" |
| 296 | + + "from 'HTMLInputElement': " |
| 297 | + + "The input element's type ('number') does not support selection.", |
| 298 | + DOMException.INVALID_STATE_ERR)); |
284 | 299 | } |
285 | 300 |
|
286 | 301 | ((SelectableTextInput) dom).setSelectionEnd(end); |
287 | 302 | return; |
288 | 303 | } |
289 | 304 |
|
290 | | - throw JavaScriptEngine.reportRuntimeError("Failed to set the 'selectionEnd' property from 'HTMLInputElement': " |
291 | | - + "The input element's type (" + getType() + ") does not support selection."); |
| 305 | + throw JavaScriptEngine.asJavaScriptException( |
| 306 | + getWindow(), |
| 307 | + new DOMException( |
| 308 | + "Failed to set the 'selectionEnd' property from 'HTMLInputElement': " |
| 309 | + + "The input element's type (" + getType() + ") does not support selection.", |
| 310 | + DOMException.INVALID_STATE_ERR)); |
292 | 311 | } |
293 | 312 |
|
294 | 313 | /** |
|
0 commit comments