Skip to content

Commit 50fe363

Browse files
committed
more on error handling
1 parent e9c057a commit 50fe363

17 files changed

+73
-73
lines changed

src/test/java/org/htmlunit/html/DomNode2Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class DomNode2Test extends WebDriverTestCase {
3535
* @throws Exception on test failure
3636
*/
3737
@Test
38-
@Alerts({"exception", "0"})
38+
@Alerts({"HierarchyRequestError", "0"})
3939
public void appendChild_recursive() throws Exception {
4040
final String html = "<html><head>\n"
4141
+ "<script>\n"
@@ -44,7 +44,7 @@ public void appendChild_recursive() throws Exception {
4444
+ " var e = document.createElement('div');\n"
4545
+ " try {\n"
4646
+ " log(e.appendChild(e) === e);\n"
47-
+ " } catch(e) {log('exception');}\n"
47+
+ " } catch(e) {log(e.name);}\n"
4848
+ " log(e.childNodes.length);\n"
4949
+ "}\n"
5050
+ "</script>\n"
@@ -60,7 +60,7 @@ public void appendChild_recursive() throws Exception {
6060
* @throws Exception on test failure
6161
*/
6262
@Test
63-
@Alerts({"true", "exception", "1", "0"})
63+
@Alerts({"true", "HierarchyRequestError", "1", "0"})
6464
public void appendChild_recursive_parent() throws Exception {
6565
final String html = "<html><head>\n"
6666
+ "<script>\n"
@@ -71,7 +71,7 @@ public void appendChild_recursive_parent() throws Exception {
7171
+ " try {\n"
7272
+ " log(e1.appendChild(e2) === e2);\n"
7373
+ " log(e2.appendChild(e1) === e1);\n"
74-
+ " } catch(e) {log('exception');}\n"
74+
+ " } catch(e) {log(e.name);}\n"
7575
+ " log(e1.childNodes.length);\n"
7676
+ " log(e2.childNodes.length);\n"
7777
+ "}\n"

src/test/java/org/htmlunit/html/HtmlColorInputTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void defaultValues() throws Exception {
4949
+ " input = document.createElement('input');\n"
5050
+ " input.type = 'color';\n"
5151
+ " log(input.value + '-' + input.defaultValue + '-' + input.getAttribute('value'));\n"
52-
+ " } catch(e) { log('exception'); }\n"
52+
+ " } catch(e) { log(e.name); }\n"
5353

5454
+ " var builder = document.createElement('div');\n"
5555
+ " builder.innerHTML = '<input type=\"color\">';\n"
@@ -85,7 +85,7 @@ public void defaultValuesAfterClone() throws Exception {
8585
+ " input.type = 'color';\n"
8686
+ " input = input.cloneNode(false);\n"
8787
+ " log(input.value + '-' + input.defaultValue + '-' + input.getAttribute('value'));\n"
88-
+ " } catch(e) { log('exception'); }\n"
88+
+ " } catch(e) { log(e.name); }\n"
8989

9090
+ " var builder = document.createElement('div');\n"
9191
+ " builder.innerHTML = '<input type=\"color\">';\n"

src/test/java/org/htmlunit/html/HtmlDateInputTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void defaultValues() throws Exception {
5151
+ " input = document.createElement('input');\n"
5252
+ " input.type = 'date';\n"
5353
+ " log(input.value + '-' + input.defaultValue + '-' + input.getAttribute('value'));\n"
54-
+ " } catch(e) { log('exception'); }\n"
54+
+ " } catch(e) { log(e.name); }\n"
5555

5656
+ " var builder = document.createElement('div');\n"
5757
+ " builder.innerHTML = '<input type=\"date\">';\n"
@@ -87,7 +87,7 @@ public void defaultValuesAfterClone() throws Exception {
8787
+ " input.type = 'date';\n"
8888
+ " input = input.cloneNode(false);\n"
8989
+ " log(input.value + '-' + input.defaultValue + '-' + input.getAttribute('value'));\n"
90-
+ " } catch(e) { log('exception'); }\n"
90+
+ " } catch(e) { log(e.name); }\n"
9191

9292
+ " var builder = document.createElement('div');\n"
9393
+ " builder.innerHTML = '<input type=\"date\">';\n"

src/test/java/org/htmlunit/html/HtmlDateTimeInputTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void defaultValues() throws Exception {
5050
+ " input = document.createElement('input');\n"
5151
+ " input.type = 'datetime';\n"
5252
+ " log(input.value + '-' + input.defaultValue + '-' + input.getAttribute('value'));\n"
53-
+ " } catch(e) { log('exception'); }\n"
53+
+ " } catch(e) { log(e.name); }\n"
5454

5555
+ " var builder = document.createElement('div');\n"
5656
+ " builder.innerHTML = '<input type=\"datetime\">';\n"
@@ -86,7 +86,7 @@ public void defaultValuesAfterClone() throws Exception {
8686
+ " input.type = 'datetime';\n"
8787
+ " input = input.cloneNode(false);\n"
8888
+ " log(input.value + '-' + input.defaultValue + '-' + input.getAttribute('value'));\n"
89-
+ " } catch(e) { log('exception'); }\n"
89+
+ " } catch(e) { log(e.name); }\n"
9090

9191
+ " var builder = document.createElement('div');\n"
9292
+ " builder.innerHTML = '<input type=\"datetime\">';\n"

src/test/java/org/htmlunit/html/HtmlDateTimeLocalInputTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void defaultValues() throws Exception {
5050
+ " input = document.createElement('input');\n"
5151
+ " input.type = 'datetime-local';\n"
5252
+ " log(input.value + '-' + input.defaultValue + '-' + input.getAttribute('value'));\n"
53-
+ " } catch(e) { log('exception'); }\n"
53+
+ " } catch(e) { log(e.name); }\n"
5454

5555
+ " var builder = document.createElement('div');\n"
5656
+ " builder.innerHTML = '<input type=\"datetime-local\">';\n"
@@ -86,7 +86,7 @@ public void defaultValuesAfterClone() throws Exception {
8686
+ " input.type = 'datetime-local';\n"
8787
+ " input = input.cloneNode(false);\n"
8888
+ " log(input.value + '-' + input.defaultValue + '-' + input.getAttribute('value'));\n"
89-
+ " } catch(e) { log('exception'); }\n"
89+
+ " } catch(e) { log(e.name); }\n"
9090

9191
+ " var builder = document.createElement('div');\n"
9292
+ " builder.innerHTML = '<input type=\"datetime-local\">';\n"

src/test/java/org/htmlunit/html/HtmlEmailInputTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void defaultValues() throws Exception {
5252
+ " input = document.createElement('input');\n"
5353
+ " input.type = 'email';\n"
5454
+ " log(input.value + '-' + input.defaultValue + '-' + input.getAttribute('value'));\n"
55-
+ " } catch(e) { log('exception'); }\n"
55+
+ " } catch(e) { log(e.name); }\n"
5656

5757
+ " var builder = document.createElement('div');\n"
5858
+ " builder.innerHTML = '<input type=\"email\">';\n"
@@ -88,7 +88,7 @@ public void defaultValuesAfterClone() throws Exception {
8888
+ " input.type = 'email';\n"
8989
+ " input = input.cloneNode(false);\n"
9090
+ " log(input.value + '-' + input.defaultValue + '-' + input.getAttribute('value'));\n"
91-
+ " } catch(e) { log('exception'); }\n"
91+
+ " } catch(e) { log(e.name); }\n"
9292

9393
+ " var builder = document.createElement('div');\n"
9494
+ " builder.innerHTML = '<input type=\"email\">';\n"

src/test/java/org/htmlunit/html/HtmlFileInputTest.java

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public void getText() throws Exception {
179179
* @throws Exception if an error occurs
180180
*/
181181
@Test
182-
@Alerts({"exception", "-Hello world-Hello world-0", "-Hello world-Hello world-0"})
182+
@Alerts({"InvalidStateError", "-Hello world-Hello world-0", "-Hello world-Hello world-0"})
183183
public void setValueOnChange() throws Exception {
184184
final String html =
185185
"<html>\n"
@@ -190,14 +190,14 @@ public void setValueOnChange() throws Exception {
190190
+ " var input = document.getElementById('f');\n"
191191
+ " try{\n"
192192
+ " input.value = 'HtmlUnit';\n"
193-
+ " } catch(e) { log('exception'); }\n"
193+
+ " } catch(e) { log(e.name); }\n"
194194
+ " log(input.value + '-' + input.defaultValue "
195195
+ "+ '-' + input.getAttribute('value') "
196196
+ "+ '-' + input.files.length);\n"
197197

198198
+ " try{\n"
199199
+ " input.value = '';\n"
200-
+ " } catch(e) { log('exception'); }\n"
200+
+ " } catch(e) { log(e.name); }\n"
201201
+ " log(input.value + '-' + input.defaultValue "
202202
+ "+ '-' + input.getAttribute('value') "
203203
+ "+ '-' + input.files.length);\n"
@@ -234,14 +234,14 @@ public void setDefaultValueOnChange() throws Exception {
234234
+ " var input = document.getElementById('f');\n"
235235
+ " try{\n"
236236
+ " input.defaultValue = 'HtmlUnit';\n"
237-
+ " } catch(e) { log('exception'); }\n"
237+
+ " } catch(e) { log(e.name); }\n"
238238
+ " log(input.value + '-' + input.defaultValue "
239239
+ "+ '-' + input.getAttribute('value') "
240240
+ "+ '-' + input.files.length);\n"
241241

242242
+ " try{\n"
243243
+ " input.defaultValue = '';\n"
244-
+ " } catch(e) { log('exception'); }\n"
244+
+ " } catch(e) { log(e.name); }\n"
245245
+ " log(input.value + '-' + input.defaultValue "
246246
+ "+ '-' + input.getAttribute('value') "
247247
+ "+ '-' + input.files.length);\n"
@@ -336,7 +336,7 @@ public void defaultValuesAfterClone() throws Exception {
336336
*/
337337
@Test
338338
@Alerts({"-initial-initial", "-initial-initial",
339-
"exception", "-initial-initial", "-initial-initial",
339+
"InvalidStateError", "-initial-initial", "-initial-initial",
340340
"-newDefault-newDefault", "-newDefault-newDefault"})
341341
public void resetByClick() throws Exception {
342342
final String html = "<html><head>\n"
@@ -351,7 +351,7 @@ public void resetByClick() throws Exception {
351351

352352
+ " try{\n"
353353
+ " file.value = 'newValue';\n"
354-
+ " } catch(e) { log('exception'); }\n"
354+
+ " } catch(e) { log(e.name); }\n"
355355
+ " log(file.value + '-' + file.defaultValue + '-' + file.getAttribute('value'));\n"
356356

357357
+ " document.getElementById('testReset').click;\n"
@@ -379,7 +379,7 @@ public void resetByClick() throws Exception {
379379
*/
380380
@Test
381381
@Alerts({"-initial-initial", "-initial-initial",
382-
"exception", "-initial-initial", "-initial-initial",
382+
"InvalidStateError", "-initial-initial", "-initial-initial",
383383
"-newDefault-newDefault", "-newDefault-newDefault"})
384384
public void resetByJS() throws Exception {
385385
final String html = "<html><head>\n"
@@ -394,7 +394,7 @@ public void resetByJS() throws Exception {
394394

395395
+ " try{\n"
396396
+ " file.value = 'newValue';\n"
397-
+ " } catch(e) { log('exception'); }\n"
397+
+ " } catch(e) { log(e.name); }\n"
398398
+ " log(file.value + '-' + file.defaultValue + '-' + file.getAttribute('value'));\n"
399399

400400
+ " document.forms[0].reset;\n"
@@ -421,7 +421,7 @@ public void resetByJS() throws Exception {
421421
*/
422422
@Test
423423
@Alerts({"-initial-initial", "-default-default",
424-
"exception", "-default-default", "-attribValue-attribValue",
424+
"InvalidStateError", "-default-default", "-attribValue-attribValue",
425425
"-newDefault-newDefault"})
426426
public void value() throws Exception {
427427
final String html = "<html><head>\n"
@@ -436,7 +436,7 @@ public void value() throws Exception {
436436

437437
+ " try{\n"
438438
+ " file.value = 'newValue';\n"
439-
+ " } catch(e) { log('exception'); }\n"
439+
+ " } catch(e) { log(e.name); }\n"
440440
+ " log(file.value + '-' + file.defaultValue + '-' + file.getAttribute('value'));\n"
441441

442442
+ " file.setAttribute('value', 'attribValue');\n"
@@ -506,7 +506,7 @@ public void selection() throws Exception {
506506
+ " } catch(e) { log('ex end'); }\n"
507507
+ " try {\n"
508508
+ " return element.value.substring(element.selectionStart, element.selectionEnd);\n"
509-
+ " } catch(e) { log('exception'); }\n"
509+
+ " } catch(e) { log(e.name); }\n"
510510
+ " }\n"
511511
+ "</script></head>\n"
512512
+ "<body onload='test()'>\n"
@@ -519,9 +519,9 @@ public void selection() throws Exception {
519519
* @throws Exception if test fails
520520
*/
521521
@Test
522-
@Alerts({"null,null", "exception value", "null,null",
523-
"exception", "null,null",
524-
"exception", "null,null"})
522+
@Alerts({"null,null", "InvalidStateError", "null,null",
523+
"InvalidStateError", "null,null",
524+
"InvalidStateError", "null,null"})
525525
public void selection2_1() throws Exception {
526526
selection2(3, 10);
527527
}
@@ -530,9 +530,9 @@ public void selection2_1() throws Exception {
530530
* @throws Exception if test fails
531531
*/
532532
@Test
533-
@Alerts({"null,null", "exception value", "null,null",
534-
"exception", "null,null",
535-
"exception", "null,null"})
533+
@Alerts({"null,null", "InvalidStateError", "null,null",
534+
"InvalidStateError", "null,null",
535+
"InvalidStateError", "null,null"})
536536
public void selection2_2() throws Exception {
537537
selection2(-3, 15);
538538
}
@@ -541,9 +541,9 @@ public void selection2_2() throws Exception {
541541
* @throws Exception if test fails
542542
*/
543543
@Test
544-
@Alerts({"null,null", "exception value", "null,null",
545-
"exception", "null,null",
546-
"exception", "null,null"})
544+
@Alerts({"null,null", "InvalidStateError", "null,null",
545+
"InvalidStateError", "null,null",
546+
"InvalidStateError", "null,null"})
547547
public void selection2_3() throws Exception {
548548
selection2(10, 5);
549549
}
@@ -558,28 +558,28 @@ private void selection2(final int selectionStart, final int selectionEnd) throws
558558

559559
+ " try {\n"
560560
+ " log(input.selectionStart + ',' + input.selectionEnd);\n"
561-
+ " } catch(e) { log('exception'); }\n"
561+
+ " } catch(e) { log(e.name); }\n"
562562

563563
+ " try{\n"
564564
+ " input.value = '12345678900';\n"
565-
+ " } catch(e) { log('exception value'); }\n"
565+
+ " } catch(e) { log(e.name); }\n"
566566
+ " try {\n"
567567
+ " log(input.selectionStart + ',' + input.selectionEnd);\n"
568-
+ " } catch(e) { log('exception'); }\n"
568+
+ " } catch(e) { log(e.name); }\n"
569569

570570
+ " try {\n"
571571
+ " input.selectionStart = " + selectionStart + ";\n"
572-
+ " } catch(e) { log('exception'); }\n"
572+
+ " } catch(e) { log(e.name); }\n"
573573
+ " try {\n"
574574
+ " log(input.selectionStart + ',' + input.selectionEnd);\n"
575-
+ " } catch(e) { log('exception'); }\n"
575+
+ " } catch(e) { log(e.name); }\n"
576576

577577
+ " try {\n"
578578
+ " input.selectionEnd = " + selectionEnd + ";\n"
579-
+ " } catch(e) { log('exception'); }\n"
579+
+ " } catch(e) { log(e.name); }\n"
580580
+ " try {\n"
581581
+ " log(input.selectionStart + ',' + input.selectionEnd);\n"
582-
+ " } catch(e) { log('exception'); }\n"
582+
+ " } catch(e) { log(e.name); }\n"
583583
+ "</script>\n"
584584
+ "</body>\n"
585585
+ "</html>";
@@ -591,7 +591,7 @@ private void selection2(final int selectionStart, final int selectionEnd) throws
591591
* @throws Exception if test fails
592592
*/
593593
@Test
594-
@Alerts({"null,null", "exception"})
594+
@Alerts({"null,null", "InvalidStateError"})
595595
public void selectionOnUpdate() throws Exception {
596596
final String html = "<html>\n"
597597
+ "<body>\n"
@@ -617,7 +617,7 @@ public void selectionOnUpdate() throws Exception {
617617

618618
+ " input.value = 'a';\n"
619619
+ " log(input.selectionStart + ',' + input.selectionEnd);\n"
620-
+ " } catch(e) { log('exception'); }\n"
620+
+ " } catch(e) { log(e.name); }\n"
621621
+ "</script>\n"
622622
+ "</body>\n"
623623
+ "</html>";

src/test/java/org/htmlunit/html/HtmlInlineFrame2Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public void aboutSrc() throws Exception {
221221
+ " var frame = document.getElementById('tstFrame');\n"
222222
+ " try {"
223223
+ " log(frame.contentWindow.location.href);\n"
224-
+ " } catch(e) { log('exception'); }\n"
224+
+ " } catch(e) { log(e.name); }\n"
225225
+ " }\n"
226226
+ "</script>\n"
227227
+ "</head>\n"

src/test/java/org/htmlunit/html/HtmlMonthInputTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void defaultValues() throws Exception {
5454
+ " input = document.createElement('input');\n"
5555
+ " input.type = 'month';\n"
5656
+ " log(input.value + '-' + input.defaultValue + '-' + input.getAttribute('value'));\n"
57-
+ " } catch(e) { log('exception'); }\n"
57+
+ " } catch(e) { log(e.name); }\n"
5858

5959
+ " var builder = document.createElement('div');\n"
6060
+ " builder.innerHTML = '<input type=\"month\">';\n"
@@ -90,7 +90,7 @@ public void defaultValuesAfterClone() throws Exception {
9090
+ " input.type = 'month';\n"
9191
+ " input = input.cloneNode(false);\n"
9292
+ " log(input.value + '-' + input.defaultValue + '-' + input.getAttribute('value'));\n"
93-
+ " } catch(e) { log('exception'); }\n"
93+
+ " } catch(e) { log(e.name); }\n"
9494

9595
+ " var builder = document.createElement('div');\n"
9696
+ " builder.innerHTML = '<input type=\"month\">';\n"

0 commit comments

Comments
 (0)