Skip to content

Commit 8f25586

Browse files
committed
more on error handling
1 parent 1c88428 commit 8f25586

35 files changed

+260
-251
lines changed

src/test/java/org/htmlunit/javascript/host/html/EnumeratorTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void basicEmptyEnumerator() throws Exception {
4848
+ " log(en.moveNext());\n"
4949
+ " log(en.item());\n"
5050
+ " log(en.atEnd());\n"
51-
+ " } catch(e) { log('exception'); }\n"
51+
+ " } catch(e) { log(e.name); }\n"
5252
+ " } else {\n"
5353
+ " log('Enumerator not supported');\n"
5454
+ " }\n"
@@ -79,7 +79,7 @@ public void basicEnumerator() throws Exception {
7979
+ " log(en.moveNext());\n"
8080
+ " log(en.item());\n"
8181
+ " log(en.atEnd());\n"
82-
+ " } catch(e) { log('exception'); }\n"
82+
+ " } catch(e) { log(e.name); }\n"
8383
+ " } else {\n"
8484
+ " log('Enumerator not supported');\n"
8585
+ " }\n"
@@ -105,7 +105,7 @@ public void basicEnumeratorWrongType() throws Exception {
105105
+ " if (typeof(Enumerator) != 'undefined') {\n"
106106
+ " try {\n"
107107
+ " var en = new Enumerator(window);\n"
108-
+ " } catch(e) { log('exception'); }\n"
108+
+ " } catch(e) { log(e.name); }\n"
109109
+ " } else {\n"
110110
+ " log('Enumerator not supported');\n"
111111
+ " }\n"
@@ -144,7 +144,7 @@ public void formEnumerator() throws Exception {
144144
+ " for( ; !e.atEnd(); e.moveNext()) {\n"
145145
+ " log(e.item().id);\n"
146146
+ " }\n"
147-
+ " } catch(e) { log('exception'); }\n"
147+
+ " } catch(e) { log(e.name); }\n"
148148
+ " } else {\n"
149149
+ " log('Enumerator not supported');\n"
150150
+ " }\n"
@@ -170,7 +170,7 @@ public void item() throws Exception {
170170
+ " if (typeof(Enumerator) != 'undefined') {\n"
171171
+ " try {\n"
172172
+ " log(new Enumerator(form).item().TyPe);\n"
173-
+ " } catch(e) { log('exception'); }\n"
173+
+ " } catch(e) { log(e.name); }\n"
174174
+ " } else {\n"
175175
+ " log('Enumerator not supported');\n"
176176
+ " }\n"

src/test/java/org/htmlunit/javascript/host/html/HTMLAllCollectionTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ private void item(final String name) throws Exception {
305305
+ " try {\n"
306306
+ " var item = document.all.item(" + name + ");\n"
307307
+ " report(item);\n"
308-
+ " } catch(e) { log('exception'); }\n"
308+
+ " } catch(e) { log(e.name); }\n"
309309
+ " document.title = alerts;"
310310
+ " }\n"
311311
+ "</script></head>\n"
@@ -423,7 +423,7 @@ private void arrayIndex(final String name) throws Exception {
423423
+ " try {\n"
424424
+ " var item = document.all[" + name + "];\n"
425425
+ " report(item);\n"
426-
+ " } catch(e) { log('exception'); }\n"
426+
+ " } catch(e) { log(e.name); }\n"
427427
+ " document.title = alerts;"
428428
+ " }\n"
429429
+ "</script></head>\n"
@@ -541,7 +541,7 @@ private void functionIndex(final String name) throws Exception {
541541
+ " try {\n"
542542
+ " var item = document.all(" + name + ");\n"
543543
+ " report(item);\n"
544-
+ " } catch(e) { log('exception'); }\n"
544+
+ " } catch(e) { log(e.name); }\n"
545545
+ " document.title = alerts;"
546546
+ " }\n"
547547
+ "</script></head>\n"
@@ -567,7 +567,7 @@ public void type() throws Exception {
567567
+ " try {\n"
568568
+ " log(document.all);\n"
569569
+ " log(HTMLAllCollection);\n"
570-
+ " } catch(e) { log('exception'); }\n"
570+
+ " } catch(e) { log(e.name); }\n"
571571
+ " }\n"
572572
+ "</script>\n"
573573
+ "</head>\n"

src/test/java/org/htmlunit/javascript/host/html/HTMLAnchorElement2Test.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ public void typeof() throws Exception {
618618
+ " log(document.links[0]);\n"
619619
+ " log(typeof document.links[0]);\n"
620620
+ " log(HTMLAnchorElement);\n"
621-
+ " } catch(e) { log('exception'); }\n"
621+
+ " } catch(e) { log(e.name); }\n"
622622
+ " }\n"
623623
+ "</script>\n"
624624
+ "</head>\n"
@@ -1080,7 +1080,7 @@ public void relList() throws Exception {
10801080
+ " for (var i = 0; i < a2.relList.length; i++) {\n"
10811081
+ " log(a2.relList[i]);\n"
10821082
+ " }\n"
1083-
+ "} catch(e) { log('exception'); }\n"
1083+
+ "} catch(e) { log(e.name); }\n"
10841084

10851085
+ "</script></body></html>";
10861086
loadPageVerifyTitle2(html);
@@ -1117,7 +1117,7 @@ public void setRelListString() throws Exception {
11171117

11181118
+ " log(a1.rel);\n"
11191119
+ " log(a2.rel);\n"
1120-
+ "} catch(e) { log('exception'); }\n"
1120+
+ "} catch(e) { log(e.name); }\n"
11211121

11221122
+ "</script></body></html>";
11231123
loadPageVerifyTitle2(html);
@@ -1146,7 +1146,7 @@ public void setRelListStringBlank() throws Exception {
11461146

11471147
+ " log(a1.rel);\n"
11481148
+ " log(a2.rel);\n"
1149-
+ "} catch(e) { log('exception'); }\n"
1149+
+ "} catch(e) { log(e.name); }\n"
11501150

11511151
+ "</script></body></html>";
11521152
loadPageVerifyTitle2(html);
@@ -1183,7 +1183,7 @@ public void setRelListNull() throws Exception {
11831183

11841184
+ " log(a1.rel);\n"
11851185
+ " log(a2.rel);\n"
1186-
+ "} catch(e) { log('exception'); }\n"
1186+
+ "} catch(e) { log(e.name); }\n"
11871187

11881188
+ "</script></body></html>";
11891189
loadPageVerifyTitle2(html);
@@ -1220,7 +1220,7 @@ public void setRelListUndefined() throws Exception {
12201220

12211221
+ " log(a1.rel);\n"
12221222
+ " log(a2.rel);\n"
1223-
+ "} catch(e) { log('exception'); }\n"
1223+
+ "} catch(e) { log(e.name); }\n"
12241224

12251225
+ "</script></body></html>";
12261226
loadPageVerifyTitle2(html);

src/test/java/org/htmlunit/javascript/host/html/HTMLAreaElementTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void type() throws Exception {
7575
+ " try {\n"
7676
+ " log(elem);\n"
7777
+ " log(HTMLAreaElement);\n"
78-
+ " } catch(e) { log('exception'); }\n"
78+
+ " } catch(e) { log(e.name); }\n"
7979
+ " }\n"
8080
+ "</script>\n"
8181
+ "</head>\n"
@@ -211,7 +211,7 @@ public void relList() throws Exception {
211211
+ " for (var i = 0; i < a2.relList.length; i++) {\n"
212212
+ " log(a2.relList[i]);\n"
213213
+ " }\n"
214-
+ "} catch(e) { log('exception'); }\n"
214+
+ "} catch(e) { log(e.name); }\n"
215215

216216
+ "</script></body></html>";
217217
loadPageVerifyTitle2(html);

src/test/java/org/htmlunit/javascript/host/html/HTMLAudioElementTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void prototype() throws Exception {
4444
+ LOG_TITLE_FUNCTION
4545
+ "try {\n"
4646
+ "log(HTMLAudioElement.prototype == null);\n"
47-
+ "} catch (e) { log('exception'); }\n"
47+
+ "} catch (e) { log(e.name); }\n"
4848
+ "</script>\n"
4949
+ "</body></html>";
5050

@@ -67,7 +67,7 @@ public void type() throws Exception {
6767
+ " try {\n"
6868
+ " log(elem);\n"
6969
+ " log(HTMLAudioElement);\n"
70-
+ " } catch(e) { log('exception'); }\n"
70+
+ " } catch(e) { log(e.name); }\n"
7171
+ " }\n"
7272
+ "</script>\n"
7373
+ "</head>\n"
@@ -93,7 +93,7 @@ public void nodeTypeName() throws Exception {
9393
+ " var audio = document.getElementById('a');\n"
9494
+ " log(audio.nodeType);"
9595
+ " log(audio.nodeName);"
96-
+ "} catch (e) { log('exception'); }\n"
96+
+ "} catch (e) { log(e.name); }\n"
9797
+ "</script>\n"
9898
+ "</body></html>";
9999

@@ -475,7 +475,7 @@ public void src() throws Exception {
475475
+ " audio.src = 'cow.mp3';\n"
476476
+ " log(audio.src);"
477477
+ " log(audio.outerHTML);"
478-
+ "} catch (e) { log('exception'); }\n"
478+
+ "} catch (e) { log(e.name); }\n"
479479
+ "</script>\n"
480480
+ "</body></html>";
481481

@@ -503,7 +503,7 @@ public void srcChild() throws Exception {
503503
+ " audio.src = 'cow.mp3';\n"
504504
+ " log(audio.src);"
505505
+ " log(audio.outerHTML);"
506-
+ "} catch (e) { log('exception'); }\n"
506+
+ "} catch (e) { log(e.name); }\n"
507507
+ "</script>\n"
508508
+ "</body></html>";
509509

@@ -526,7 +526,7 @@ public void srcNotDefined() throws Exception {
526526
+ " var src = document.getElementById('a').src;\n"
527527
+ " log(typeof src);"
528528
+ " log(src);"
529-
+ "} catch (e) { log('exception'); }\n"
529+
+ "} catch (e) { log(e.name); }\n"
530530
+ "</script>\n"
531531
+ "</body></html>";
532532

@@ -548,7 +548,7 @@ public void currentSrc() throws Exception {
548548
+ " var currentSrc = document.getElementById('a').currentSrc;\n"
549549
+ " log(typeof currentSrc);"
550550
+ " log(currentSrc);"
551-
+ "} catch (e) { log('exception'); }\n"
551+
+ "} catch (e) { log(e.name); }\n"
552552
+ "</script>\n"
553553
+ "</body></html>";
554554

@@ -571,7 +571,7 @@ public void currentSrcChild() throws Exception {
571571
+ " var currentSrc = document.getElementById('a').currentSrc;\n"
572572
+ " log(typeof currentSrc);"
573573
+ " log(currentSrc);"
574-
+ "} catch (e) { log('exception'); }\n"
574+
+ "} catch (e) { log(e.name); }\n"
575575
+ "</script>\n"
576576
+ "</body></html>";
577577

@@ -594,7 +594,7 @@ public void currentSrcNotDefined() throws Exception {
594594
+ " var currentSrc = document.getElementById('a').currentSrc;\n"
595595
+ " log(typeof currentSrc);"
596596
+ " log(currentSrc);"
597-
+ "} catch (e) { log('exception'); }\n"
597+
+ "} catch (e) { log(e.name); }\n"
598598
+ "</script>\n"
599599
+ "</body></html>";
600600

src/test/java/org/htmlunit/javascript/host/html/HTMLBaseElementTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void type() throws Exception {
7272
+ " try {\n"
7373
+ " log(elem);\n"
7474
+ " log(HTMLBaseElement);\n"
75-
+ " } catch(e) { log('exception'); }\n"
75+
+ " } catch(e) { log(e.name); }\n"
7676
+ " }\n"
7777
+ "</script>\n"
7878
+ "</head>\n"

src/test/java/org/htmlunit/javascript/host/html/HTMLBaseFontElementTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void size() throws Exception {
7575
+ " base.size = 42;\n"
7676
+ " log(base.size);\n"
7777
+ " } catch(e) {\n"
78-
+ " log('exception');\n"
78+
+ " log(e.name);\n"
7979
+ " }\n"
8080
+ " }\n"
8181
+ " </script>\n"
@@ -105,7 +105,7 @@ public void face() throws Exception {
105105
+ " base.face = 'helvetica';\n"
106106
+ " log(base.face);\n"
107107
+ " } catch(e) {\n"
108-
+ " log('exception');\n"
108+
+ " log(e.name);\n"
109109
+ " }\n"
110110
+ " }\n"
111111
+ " </script>\n"
@@ -135,7 +135,7 @@ public void color() throws Exception {
135135
+ " base.color = 'blue';\n"
136136
+ " log(base.color);\n"
137137
+ " } catch(e) {\n"
138-
+ " log('exception');\n"
138+
+ " log(e.name);\n"
139139
+ " }\n"
140140
+ " }\n"
141141
+ " </script>\n"
@@ -150,7 +150,7 @@ public void color() throws Exception {
150150
* @throws Exception if the test fails
151151
*/
152152
@Test
153-
@Alerts({"[object HTMLElement]", "exception"})
153+
@Alerts({"[object HTMLElement]", "ReferenceError"})
154154
public void type() throws Exception {
155155
final String html = ""
156156
+ "<html><head>\n"
@@ -161,7 +161,7 @@ public void type() throws Exception {
161161
+ " try {\n"
162162
+ " log(elem);\n"
163163
+ " log(HTMLBaseFontElement);\n"
164-
+ " } catch(e) { log('exception'); }\n"
164+
+ " } catch(e) { log(e.name); }\n"
165165
+ " }\n"
166166
+ "</script>\n"
167167
+ "</head>\n"

src/test/java/org/htmlunit/javascript/host/html/HTMLBodyElementTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void defaultPaddingAndMargins() throws Exception {
7272
* @throws Exception if an error occurs
7373
*/
7474
@Test
75-
@Alerts("exception")
75+
@Alerts("TypeError")
7676
public void attachEvent() throws Exception {
7777
final String html =
7878
"<html>\n"
@@ -85,7 +85,7 @@ public void attachEvent() throws Exception {
8585
+ " function test() {\n"
8686
+ " try {\n"
8787
+ " document.body.attachEvent('onclick', handler);\n"
88-
+ " } catch(e) { log('exception'); }\n"
88+
+ " } catch(e) { log(e.name); }\n"
8989
+ " }\n"
9090
+ " </script>\n"
9191
+ " </head>\n"
@@ -315,7 +315,7 @@ public void enumeratedProperties() throws Exception {
315315
+ " for (var i in HTMLBodyElement)\n"
316316
+ " str += i + ', ';\n"
317317
+ " log(str);\n"
318-
+ " } catch (e) { log('exception')}\n"
318+
+ " } catch (e) { log(e.name)}\n"
319319
+ " }\n"
320320
+ "</script>\n"
321321
+ "</head>\n"

src/test/java/org/htmlunit/javascript/host/html/HTMLButtonElementTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void type() throws Exception {
8181
+ " log(b.type);\n"
8282
+ " try {\n"
8383
+ " b.type = 'button';\n"
84-
+ " } catch(e) {log('exception')}\n"
84+
+ " } catch(e) {log(e.name)}\n"
8585
+ " log(b.type);\n"
8686
+ " b.removeAttribute('type');\n"
8787
+ " log(b.type);\n"

src/test/java/org/htmlunit/javascript/host/html/HTMLCanvasElementTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void toDataUrl() throws Exception {
130130
+ " var canvas = document.getElementById('myCanvas');\n"
131131
+ " log(canvas.toDataURL());\n"
132132
+ "}\n"
133-
+ "catch (e) { log('exception'); }\n"
133+
+ "catch (e) { log(e.name); }\n"
134134
+ "</script>\n"
135135
+ "</body>\n"
136136
+ "</html>";
@@ -207,7 +207,7 @@ public void toDataUrlPng() throws Exception {
207207
+ " var canvas = document.getElementById('myCanvas');\n"
208208
+ " log(canvas.toDataURL('image/png'));\n"
209209
+ "}\n"
210-
+ "catch (e) { log('exception'); }\n"
210+
+ "catch (e) { log(e.name); }\n"
211211
+ "</script>\n"
212212
+ "</body>\n"
213213
+ "</html>";

0 commit comments

Comments
 (0)