Skip to content

Commit 5e09025

Browse files
committed
more on error handling
1 parent a1219fa commit 5e09025

17 files changed

+69
-69
lines changed

src/test/java/org/htmlunit/javascript/host/ActiveXObject2Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void browserDetection() throws Exception {
6262
* @throws Exception if the test fails
6363
*/
6464
@Test
65-
@Alerts("exception")
65+
@Alerts("ReferenceError")
6666
public void xmlDocument() throws Exception {
6767
final String html = "<html>\n"
6868
+ " <head>\n"
@@ -72,7 +72,7 @@ public void xmlDocument() throws Exception {
7272
+ " try {\n"
7373
+ " var doc = new ActiveXObject('Microsoft.XMLDOM');\n"
7474
+ " log(typeof doc);\n"
75-
+ " } catch(e) { log('exception'); }\n"
75+
+ " } catch(e) { log(e.name); }\n"
7676
+ " }\n"
7777
+ "</script></head>\n"
7878
+ "<body onload='test()'>\n"
@@ -98,7 +98,7 @@ public void activex() throws Exception {
9898
+ " } else {\n"
9999
+ " log('ActiveXObject undefined');\n"
100100
+ " }\n"
101-
+ " } catch(e) {log('exception');}\n"
101+
+ " } catch(e) {log(e.name);}\n"
102102
+ " }\n"
103103
+ "</script></head><body onload='test()'>\n"
104104
+ "</body></html>";

src/test/java/org/htmlunit/javascript/host/BoxObjectTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class BoxObjectTest extends WebDriverTestCase {
3434
* @throws Exception if an error occurs
3535
*/
3636
@Test
37-
@Alerts("exception")
37+
@Alerts("TypeError")
3838
public void elementAttributes() throws Exception {
3939
final String html =
4040
"<html>\n"
@@ -55,7 +55,7 @@ public void elementAttributes() throws Exception {
5555
+ " log(box.lastChild == spanB);\n"
5656
+ " log(box.previousSibling == spanFoo);\n"
5757
+ " log(box.nextSibling == spanBar);\n"
58-
+ " } catch (e) {log('exception')}\n"
58+
+ " } catch (e) {log(e.name)}\n"
5959
+ " }\n"
6060
+ " </script>\n"
6161
+ " </body>\n"
@@ -69,7 +69,7 @@ public void elementAttributes() throws Exception {
6969
* @throws Exception if an error occurs
7070
*/
7171
@Test
72-
@Alerts("exception")
72+
@Alerts("TypeError")
7373
public void positionAndSizeAttributes() throws Exception {
7474
final String html =
7575
"<html>\n"
@@ -85,7 +85,7 @@ public void positionAndSizeAttributes() throws Exception {
8585
+ " log(box.x + '-' + box.y);\n"
8686
+ " log(box.screenX + '-' + box.screenY);\n"
8787
+ " log(box.width + '-' + box.height);\n"
88-
+ " } catch (e) {log('exception')}\n"
88+
+ " } catch (e) {log(e.name)}\n"
8989
+ " }\n"
9090
+ " </script>\n"
9191
+ " </body>\n"

src/test/java/org/htmlunit/javascript/host/ClientRectListTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ public void itemOutside() throws Exception {
7272

7373
+ " try {\n"
7474
+ " log(rects.item(1));\n"
75-
+ " } catch(e) { log('exception'); }\n"
75+
+ " } catch(e) { log(e.name); }\n"
7676

7777
+ " try {\n"
7878
+ " log(rects.item(-1));\n"
79-
+ " } catch(e) { log('exception'); }\n"
79+
+ " } catch(e) { log(e.name); }\n"
8080
+ " }\n"
8181
+ "</script></head>\n"
8282
+ "<body onload='test()'>\n"
@@ -104,11 +104,11 @@ public void indexOutside() throws Exception {
104104

105105
+ " try {\n"
106106
+ " log(rects[1]);\n"
107-
+ " } catch(e) { log('exception'); }\n"
107+
+ " } catch(e) { log(e.name); }\n"
108108

109109
+ " try {\n"
110110
+ " log(rects[-1]);\n"
111-
+ " } catch(e) { log('exception'); }\n"
111+
+ " } catch(e) { log(e.name); }\n"
112112
+ " }\n"
113113
+ "</script></head>\n"
114114
+ "<body onload='test()'>\n"
@@ -136,11 +136,11 @@ public void empty() throws Exception {
136136

137137
+ " try {\n"
138138
+ " log(rects[1]);\n"
139-
+ " } catch(e) { log('exception'); }\n"
139+
+ " } catch(e) { log(e.name); }\n"
140140

141141
+ " try {\n"
142142
+ " log(rects[-1]);\n"
143-
+ " } catch(e) { log('exception'); }\n"
143+
+ " } catch(e) { log(e.name); }\n"
144144
+ " }\n"
145145
+ "</script></head>\n"
146146
+ "<body onload='test()'>\n"

src/test/java/org/htmlunit/javascript/host/ClientRectTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void properties() throws Exception {
4747
+ " log(pos.right);\n"
4848
+ " log(pos.width);\n"
4949
+ " log(pos.height);\n"
50-
+ " } catch (e) { log('exception');}\n"
50+
+ " } catch (e) { log(e.name);}\n"
5151
+ " }\n"
5252
+ "</script></head><body onload='test()'>\n"
5353
+ "<div id='outer' style='position: absolute; left: 400px; top: 100px; width: 50px; height: 80px;'>\n"

src/test/java/org/htmlunit/javascript/host/Console2Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public void fromWorker() throws Exception {
211211
+ "<script async>\n"
212212
+ "try {\n"
213213
+ " var myWorker = new Worker('worker.js');\n"
214-
+ "} catch(e) { log('exception'); }\n"
214+
+ "} catch(e) { log(e.name); }\n"
215215
+ "</script></body></html>\n";
216216

217217
loadPage(html);

src/test/java/org/htmlunit/javascript/host/ConsoleTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void prototype() throws Exception {
5353
+ " log(window.console == undefined);\n"
5454
+ " log(typeof window.console);\n"
5555
+ " log('console' in window);\n"
56-
+ " } catch(e) { log('exception');}\n"
56+
+ " } catch(e) { log(e.name);}\n"
5757
+ "</script>\n"
5858
+ "</body></html>";
5959

@@ -75,7 +75,7 @@ public void prototypeUppercase() throws Exception {
7575
+ " log(window.Console == undefined);\n"
7676
+ " log(typeof window.Console);\n"
7777
+ " log('Console' in window);\n"
78-
+ " } catch(e) { log('exception');}\n"
78+
+ " } catch(e) { log(e.name);}\n"
7979
+ "</script>\n"
8080
+ "</body></html>";
8181

@@ -140,7 +140,7 @@ public void windowProperty() throws Exception {
140140
+ " try {\n"
141141
+ " var x = Object.getOwnPropertyNames(window).indexOf('console');\n"
142142
+ " log(x >= 0);\n"
143-
+ " } catch(e) {log('exception')}\n"
143+
+ " } catch(e) {log(e.name)}\n"
144144
+ "</script>\n"
145145
+ "</body></html>";
146146

@@ -162,7 +162,7 @@ public void fromWindow() throws Exception {
162162
+ " var x = console.error;\n"
163163
+ " x('hello');\n"
164164
+ " log('success');\n"
165-
+ " } catch(e) {log('exception')}\n"
165+
+ " } catch(e) {log(e.name)}\n"
166166
+ "</script>\n"
167167
+ "</body></html>";
168168

src/test/java/org/htmlunit/javascript/host/ElementTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void attributes() throws Exception {
8181
* @throws Exception if the test fails
8282
*/
8383
@Test
84-
@Alerts("exception")
84+
@Alerts("TypeError")
8585
public void selectNodes() throws Exception {
8686
final String html = "<html><head><script>\n"
8787
+ LOG_TITLE_FUNCTION
@@ -91,7 +91,7 @@ public void selectNodes() throws Exception {
9191
+ " var nodes = doc.documentElement.selectNodes('//title');\n"
9292
+ " log(nodes.length);\n"
9393
+ " log(nodes[0].tagName);\n"
94-
+ " } catch (e) { log('exception'); }\n"
94+
+ " } catch (e) { log(e.name); }\n"
9595
+ " }\n"
9696
+ XMLDocumentTest.LOAD_XML_DOCUMENT_FROM_FILE_FUNCTION
9797
+ "</script></head><body onload='test()'>\n"
@@ -188,7 +188,7 @@ public void getAttributeNode() throws Exception {
188188
* @throws Exception if the test fails
189189
*/
190190
@Test
191-
@Alerts({"book", "exception"})
191+
@Alerts({"book", "TypeError"})
192192
public void selectNode_root() throws Exception {
193193
final String html = "<html><head><script>\n"
194194
+ LOG_TITLE_FUNCTION
@@ -199,7 +199,7 @@ public void selectNode_root() throws Exception {
199199
+ " try {\n"
200200
+ " log(child.selectNodes('/title').length);\n"
201201
+ " log(child.selectNodes('title').length);\n"
202-
+ " } catch (e) { log('exception'); }\n"
202+
+ " } catch (e) { log(e.name); }\n"
203203
+ " }\n"
204204
+ XMLDocumentTest.LOAD_XML_DOCUMENT_FROM_FILE_FUNCTION
205205
+ "</script></head><body onload='test()'>\n"
@@ -233,7 +233,7 @@ public void getElementsByTagNameNS() throws Exception {
233233
+ " try {\n"
234234
+ " log(doc.documentElement.getElementsByTagNameNS('http://myNS', 'template').length);\n"
235235
+ " log(doc.documentElement.getElementsByTagNameNS(null, 'html').length);\n"
236-
+ " } catch (e) { log('exception'); }\n"
236+
+ " } catch (e) { log(e.name); }\n"
237237
+ " }\n"
238238
+ XMLDocumentTest.LOAD_XML_DOCUMENT_FROM_STRING_FUNCTION
239239
+ "</script></head><body onload='test()'>\n"
@@ -265,7 +265,7 @@ public void getElementsByTagNameNSAsterisk() throws Exception {
265265
+ " log(doc.documentElement.getElementsByTagNameNS('http://myNS', '*').length);\n"
266266
+ " log(doc.documentElement.getElementsByTagNameNS(null, '*').length);\n"
267267
+ " log(doc.documentElement.getElementsByTagNameNS('*', '*').length);\n"
268-
+ " } catch (e) { log('exception'); }\n"
268+
+ " } catch (e) { log(e.name); }\n"
269269
+ " }\n"
270270
+ XMLDocumentTest.LOAD_XML_DOCUMENT_FROM_STRING_FUNCTION
271271
+ "</script></head><body onload='test()'>\n"
@@ -794,7 +794,7 @@ public void getBoundingClientRect() throws Exception {
794794
+ LOG_TITLE_FUNCTION
795795
+ "try {\n"
796796
+ " log(typeof Element.prototype.getBoundingClientRect);\n"
797-
+ "} catch (e) { log('exception');}\n"
797+
+ "} catch (e) { log(e.name);}\n"
798798
+ "</script></body></html>";
799799
loadPageVerifyTitle2(html);
800800
}
@@ -957,17 +957,17 @@ public void children() throws Exception {
957957
+ " try {\n"
958958
+ " var children = doc.documentElement.children;\n"
959959
+ " log(children + ' ' + children.length);\n"
960-
+ " } catch (e) { log('exception'); }\n"
960+
+ " } catch (e) { log(e.name); }\n"
961961

962962
+ " try {\n"
963963
+ " children = document.documentElement.children;\n"
964964
+ " log(children + ' ' + children.length);\n"
965-
+ " } catch (e) { log('exception'); }\n"
965+
+ " } catch (e) { log(e.name); }\n"
966966

967967
+ " try {\n"
968968
+ " children = document.getElementById('myId').children;\n"
969969
+ " log(children + ' ' + children.length);\n"
970-
+ " } catch (e) { log('exception'); }\n"
970+
+ " } catch (e) { log(e.name); }\n"
971971
+ "}\n"
972972
+ XMLDocumentTest.LOAD_XML_DOCUMENT_FROM_STRING_FUNCTION
973973
+ "</script></head><body onload='test()'>\n"
@@ -1178,12 +1178,12 @@ public void prototypConstructor() throws Exception {
11781178
+ " process(Element);\n"
11791179
+ " process(Element.prototype);\n"
11801180
+ " process(Element.prototype.constructor);\n"
1181-
+ " } catch (e) {log('exception')}\n"
1181+
+ " } catch (e) {log(e.name)}\n"
11821182
+ " }\n"
11831183
+ " function process(obj) {\n"
11841184
+ " try {\n"
11851185
+ " log(obj);\n"
1186-
+ " } catch (e) {log('exception')}\n"
1186+
+ " } catch (e) {log(e.name)}\n"
11871187
+ " }\n"
11881188
+ "</script>\n"
11891189
+ "</head>\n"

src/test/java/org/htmlunit/javascript/host/ExternalTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void isSearchProviderInstalled() throws Exception {
110110
+ " try {\n"
111111
+ " var res = window.external.IsSearchProviderInstalled('http://htmlunit.sourceforge.net');\n"
112112
+ " log('IsSearchProviderInstalled: ' + res);\n"
113-
+ " } catch(e) { log('exception'); }\n"
113+
+ " } catch(e) { log(e.name); }\n"
114114
+ " } else {\n"
115115
+ " log('no IsSearchProviderInstalled');\n"
116116
+ " }\n"

src/test/java/org/htmlunit/javascript/host/History2Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public void pushStateLocationHref() throws Exception {
325325
+ " var stateObj = { hi: 'there' };\n"
326326
+ " window.history.pushState(stateObj, 'page 2', 'bar.html');\n"
327327
+ " log(location.href.indexOf('bar.html') > -1);\n"
328-
+ " } catch(e) { log('exception'); }\n"
328+
+ " } catch(e) { log(e.name); }\n"
329329
+ " }\n"
330330

331331
+ " function test2() {\n"
@@ -334,7 +334,7 @@ public void pushStateLocationHref() throws Exception {
334334
+ " var stateObj = { hi2: 'there2' };\n"
335335
+ " window.history.pushState(stateObj, 'page 3', 'bar2.html');\n"
336336
+ " log(location.href.indexOf('bar2.html') > -1);\n"
337-
+ " } catch(e) { log('exception'); }\n"
337+
+ " } catch(e) { log(e.name); }\n"
338338
+ " }\n"
339339

340340
+ "</script>\n"

src/test/java/org/htmlunit/javascript/host/Location2Test.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public void about_blank_query_attributes() throws Exception {
178178
+ " log(location.port);\n"
179179
+ " log(location.protocol);\n"
180180
+ " log(location.search);\n"
181-
+ " } catch(e) { log('exception'); }\n"
181+
+ " } catch(e) { log(e.name); }\n"
182182
+ " }\n"
183183
+ " </script>\n"
184184
+ "</head>\n"
@@ -210,7 +210,7 @@ public void about_blank_emptyquery_attributes() throws Exception {
210210
+ " log(location.port);\n"
211211
+ " log(location.protocol);\n"
212212
+ " log(location.search);\n"
213-
+ " } catch(e) { log('exception'); }\n"
213+
+ " } catch(e) { log(e.name); }\n"
214214
+ " }\n"
215215
+ " </script>\n"
216216
+ "</head>\n"
@@ -242,7 +242,7 @@ public void about_blank_hash_attributes() throws Exception {
242242
+ " log(location.port);\n"
243243
+ " log(location.protocol);\n"
244244
+ " log(location.search);\n"
245-
+ " } catch(e) { log('exception'); }\n"
245+
+ " } catch(e) { log(e.name); }\n"
246246
+ " }\n"
247247
+ " </script>\n"
248248
+ "</head>\n"
@@ -275,7 +275,7 @@ public void about_blank_emptyquery_hash_attributes() throws Exception {
275275
+ " log(location.port);\n"
276276
+ " log(location.protocol);\n"
277277
+ " log(location.search);\n"
278-
+ " } catch(e) { log('exception'); }\n"
278+
+ " } catch(e) { log(e.name); }\n"
279279
+ " }\n"
280280
+ " </script>\n"
281281
+ "</head>\n"
@@ -309,7 +309,7 @@ public void about_blank_query_hash_attributes() throws Exception {
309309
+ " log(location.port);\n"
310310
+ " log(location.protocol);\n"
311311
+ " log(location.search);\n"
312-
+ " } catch(e) { log('exception'); }\n"
312+
+ " } catch(e) { log(e.name); }\n"
313313
+ " }\n"
314314
+ " </script>\n"
315315
+ "</head>\n"
@@ -341,7 +341,7 @@ public void about_blank_set_hash() throws Exception {
341341
+ " location.hash = 'foo';\n"
342342
+ " log(location.hash);\n"
343343
+ " log(location.href);\n"
344-
+ " } catch(e) { log('exception'); }\n"
344+
+ " } catch(e) { log(e.name); }\n"
345345
+ " }\n"
346346
+ " </script>\n"
347347
+ "</head>\n"

0 commit comments

Comments
 (0)