Skip to content

Commit

Permalink
more on error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Feb 2, 2025
1 parent 314f842 commit 062ddff
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 73 deletions.
26 changes: 13 additions & 13 deletions src/test/java/org/htmlunit/javascript/host/SymbolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private void name(final String name) throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts({"Symbol()", "Symbol(foo)", "Symbol(Symbol.iterator)", "exception"})
@Alerts({"Symbol()", "Symbol(foo)", "Symbol(Symbol.iterator)", "TypeError"})
public void string() throws Exception {
final String html =
HtmlPageTest.STANDARDS_MODE_PREFIX_
Expand All @@ -167,7 +167,7 @@ public void string() throws Exception {
+ " log(Symbol().toString());\n"
+ " log(Symbol('foo').toString());\n"
+ " log(Symbol.iterator.toString());\n"
+ " try { log(Symbol.replace) } catch(e) { log('exception'); };\n"
+ " try { log(Symbol.replace) } catch(e) { log(e.name); };\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand Down Expand Up @@ -195,7 +195,7 @@ public void defaultValue() throws Exception {
+ " log(Symbol().toString());\n"
+ " log(Symbol('foo').toString());\n"
+ " log(Symbol.iterator.toString());\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand Down Expand Up @@ -224,7 +224,7 @@ public void typeOf() throws Exception {
+ " log(typeof Symbol());\n"
+ " log(typeof Symbol('foo'));\n"
+ " log(typeof Symbol.iterator);\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand Down Expand Up @@ -254,7 +254,7 @@ public void symbolFor() throws Exception {

+ " var sym = Symbol.for('mario');\n"
+ " log(sym.toString());\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand Down Expand Up @@ -284,7 +284,7 @@ public void symbolForGlobal() throws Exception {
+ " try {\n"
+ " log(Symbol.for('global') === globSym);\n"
+ " log(Symbol('global') === globSym);\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand All @@ -298,7 +298,7 @@ public void symbolForGlobal() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts({"exception", "exception"})
@Alerts({"TypeError", "TypeError"})
public void symbolNew() throws Exception {
final String html =
HtmlPageTest.STANDARDS_MODE_PREFIX_
Expand All @@ -310,10 +310,10 @@ public void symbolNew() throws Exception {
+ " if (!window.Symbol) { log('not supported'); return; }\n"
+ " try {\n"
+ " new Symbol();\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " try {\n"
+ " new Symbol('foo');\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand All @@ -327,7 +327,7 @@ public void symbolNew() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts({"exception", "exception"})
@Alerts({"TypeError", "TypeError"})
public void globalSymbolRegistry() throws Exception {
final String html =
HtmlPageTest.STANDARDS_MODE_PREFIX_
Expand All @@ -339,10 +339,10 @@ public void globalSymbolRegistry() throws Exception {
+ " if (!window.Symbol) { log('not supported'); return; }\n"
+ " try {\n"
+ " new Symbol();\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " try {\n"
+ " new Symbol('foo');\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand Down Expand Up @@ -390,7 +390,7 @@ public void inFunction2() throws Exception {
+ " try {\n"
+ " var x = Symbol('hello');\n"
+ " log('called');\n"
+ " } catch(e) {log('exception');}\n"
+ " } catch(e) {log(e.name);}\n"
+ " });\n"
+ " }\n"
+ "}\n"
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/org/htmlunit/javascript/host/TextDecoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public void encoding_iso_8859_15() throws Exception {
* @throws Exception on test failure
*/
@Test
@Alerts("exception")
@Alerts("RangeError")
public void encoding_iso_8859_15_ex() throws Exception {
encoding("latin9");
}
Expand Down Expand Up @@ -501,7 +501,7 @@ public void encoding_gb18030() throws Exception {
* @throws Exception on test failure
*/
@Test
@Alerts("exception")
@Alerts("RangeError")
public void encoding_hz_gb_2312() throws Exception {
encoding("hz-gb-2312");
}
Expand Down Expand Up @@ -577,7 +577,7 @@ public void encoding_euc_kr() throws Exception {
* @throws Exception on test failure
*/
@Test
@Alerts("exception")
@Alerts("RangeError")
public void encoding_iso_2022_kr() throws Exception {
encoding("csiso2022kr");
encoding("iso-2022-kr");
Expand Down Expand Up @@ -615,7 +615,7 @@ public void encoding_x_user_defined() throws Exception {
* @throws Exception on test failure
*/
@Test
@Alerts("exception")
@Alerts("RangeError")
public void encoding_replacement() throws Exception {
encoding("iso-2022-cn");
encoding("iso-2022-cn-ext");
Expand All @@ -630,7 +630,7 @@ private void encoding(final String encoding) throws Exception {
+ " try {\n"
+ " enc = new TextDecoder('" + encoding + "');\n"
+ " log(enc.encoding);\n"
+ " } catch(e) { log('exception'); }\n"
+ " } catch(e) { log(e.name); }\n"
+ " }\n"
+ " </script>\n"
+ "</head>\n"
Expand Down Expand Up @@ -703,7 +703,7 @@ public void decode() throws Exception {
* @throws Exception on test failure
*/
@Test
@Alerts({"", "exception"})
@Alerts({"", "TypeError"})
public void decode2() throws Exception {
final String html = "<html>\n"
+ "<head>\n"
Expand All @@ -713,11 +713,11 @@ public void decode2() throws Exception {
+ " var dec = new TextDecoder('utf-8');\n"
+ " try {\n"
+ " log(dec.decode(undefined));\n"
+ " } catch(e) { log('exception'); }\n"
+ " } catch(e) { log(e.name); }\n"

+ " try {\n"
+ " log(dec.decode(null));\n"
+ " } catch(e) { log('exception'); }\n"
+ " } catch(e) { log(e.name); }\n"
+ " }\n"
+ " </script>\n"
+ "</head>\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ public void forEach() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts({"exception", "exception"})
@Alerts({"TypeError", "TypeError"})
public void forEachWrongParam() throws Exception {
final String html
= "<html><head><script>\n"
Expand All @@ -936,10 +936,10 @@ public void forEachWrongParam() throws Exception {
+ " var param = new URLSearchParams('key1=val1&key2=val2&key3=val3');\n"
+ " try {\n"
+ " param.forEach();\n"
+ " } catch(e) { log('exception'); }\n"
+ " } catch(e) { log(e.name); }\n"
+ " try {\n"
+ " param.forEach('wrong');\n"
+ " } catch(e) { log('exception'); }\n"
+ " } catch(e) { log(e.name); }\n"
+ " }\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/org/htmlunit/javascript/host/WeakMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void constructorArray() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts("exception")
@Alerts("TypeError")
public void constructorSetParam() throws Exception {
final String html
= "<html><head>\n"
Expand All @@ -67,7 +67,7 @@ public void constructorSetParam() throws Exception {
+ " var myMap = new WeakMap(new Set('test'));\n"
+ " log(myMap.has('test'));\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " log(e.name);\n"
+ " }\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
Expand All @@ -94,7 +94,7 @@ public void constructorMapParam() throws Exception {
+ " var myMap = new WeakMap(testMap);\n"
+ " log(myMap.has(foo));\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " log(e.name);\n"
+ " }\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
Expand Down Expand Up @@ -134,7 +134,7 @@ public void constructorIteratorParam() throws Exception {
+ " var myMap = new WeakMap(myIterable);\n"
+ " log(myMap.has(foo));\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " log(e.name);\n"
+ " }\n"
+ " }"
+ "}\n"
Expand Down Expand Up @@ -169,7 +169,7 @@ public void get() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts("exception")
@Alerts("TypeError")
public void setNonObject() throws Exception {
final String html = "<html><head>\n"
+ "<script>\n"
Expand All @@ -180,7 +180,7 @@ public void setNonObject() throws Exception {
+ " var myMap = new WeakMap(kvArray);\n"
+ " try {\n"
+ " myMap.set(1, 2);\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ " }\n"
+ "</script></head><body onload='test()'>\n"
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/htmlunit/javascript/host/WebSocketTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,22 @@ public void binaryType() throws Exception {
+ " try {\n"
+ " ws.binaryType = 'abc';\n"
+ " log(ws.binaryType);\n"
+ " } catch(e) { log('exception') }\n"
+ " } catch(e) { log(e.name) }\n"

+ " try {\n"
+ " ws.binaryType = 'arraybuffer';\n"
+ " log(ws.binaryType);\n"
+ " } catch(e) { log('exception') }\n"
+ " } catch(e) { log(e.name) }\n"

+ " try {\n"
+ " ws.binaryType = 'blob';\n"
+ " log(ws.binaryType);\n"
+ " } catch(e) { log('exception') }\n"
+ " } catch(e) { log(e.name) }\n"

+ " try {\n"
+ " ws.binaryType = '';\n"
+ " log(ws.binaryType);\n"
+ " } catch(e) { log('exception') }\n"
+ " } catch(e) { log(e.name) }\n"
+ " }\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Loading

0 comments on commit 062ddff

Please sign in to comment.