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 682e763 commit 56be803
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void setNonWritablePropertyContentType() throws Exception {
+ " log(document.contentType);\n"
+ " document.contentType = '123456';\n"
+ " log(document.contentType);\n"
+ " } catch (e) { log('exception'); }\n"
+ " } catch (e) { log(e.name); }\n"
+ " }\n"
+ "</script></head>\n"
+ "<body onload='test()'>\n"
Expand All @@ -79,7 +79,7 @@ public void setNonWritablePropertyCompatMode() throws Exception {
+ " log(document.compatMode);\n"
+ " document.compatMode = '123456';\n"
+ " log(document.compatMode);\n"
+ " } catch (e) { log('exception'); }\n"
+ " } catch (e) { log(e.name); }\n"
+ " }\n"
+ "</script></head>\n"
+ "<body onload='test()'>\n"
Expand Down Expand Up @@ -316,7 +316,7 @@ private void set_ReadOnly(final String expression) throws Exception {
+ " try {\n"
+ " " + expression + " = '" + expression + " was set" + "';\n"
+ " log(" + expression + ");\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ "}\n"
+ "</script></head>\n"
+ "<body onload='test()'>\n"
Expand Down Expand Up @@ -350,7 +350,7 @@ public void lookupGetter() throws Exception {
+ " log(lengthGetter);\n"
+ " log(lengthGetter.call(window));\n"
+ " log(lengthGetter.call());\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ "}\n"
+ "</script></head>\n"
+ "<body onload='test()'>\n"
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/org/htmlunit/javascript/JavaScriptEngine2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public void constructor() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts("exception")
@Alerts("ReferenceError")
public void packages() throws Exception {
object("Packages");
}
Expand All @@ -254,7 +254,7 @@ public void packages() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts("exception")
@Alerts("ReferenceError")
public void java() throws Exception {
object("java");
}
Expand All @@ -275,7 +275,7 @@ private void object(final String object) throws Exception {
+ "try {\n"
+ " log(" + object + ");\n"
+ "} catch (e) {\n"
+ " log('exception');\n"
+ " log(e.name);\n"
+ "}\n"
+ "</script>\n"
+ "</body></html>";
Expand Down Expand Up @@ -1028,15 +1028,15 @@ public void falsyAndDocumentAll() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts("exception")
@Alerts("ReferenceError")
public void javaNotAccessable() throws Exception {
final String html = "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ "function test() {\n"
+ " try {\n"
+ " log(java.lang.Math.PI);\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 @@ -406,7 +406,7 @@ public void commaOperatorFunctionTry() throws Exception {
+ " try {\n"
+ " (0, obj.default)('var y=\"my y var\"');\n"
+ " log(y);\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/htmlunit/javascript/NativeJSONTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class NativeJSONTest extends WebDriverTestCase {
* @throws Exception if the test fails
*/
@Test
@Alerts({"x,y", "exception"})
@Alerts({"x,y", "SyntaxError"})
public void getArraySyntax() throws Exception {
final String html
= "<html>\n"
Expand All @@ -48,7 +48,7 @@ public void getArraySyntax() throws Exception {
+ " text = '{\"name\": [, \"y\"]}';\n"
+ " try {\n"
+ " var obj = JSON.parse(text);"
+ " } catch(e) { log('exception'); }\n"
+ " } catch(e) { log(e.name); }\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/htmlunit/javascript/NativeNumberTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,13 @@ public void toLocaleStringNoParam() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts("exception")
@Alerts("RangeError")
public void toLocaleStringHintertupfingen() throws Exception {
final String html = "<html><head><script>\n"
+ LOG_TITLE_FUNCTION
+ " try {\n"
+ " log((12345).toLocaleString('Hintertupfingen'));\n"
+ " } catch(e) { log('exception'); }\n"
+ " } catch(e) { log(e.name); }\n"
+ "</script></head><body>\n"
+ "</body></html>";
loadPageVerifyTitle2(html);
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/org/htmlunit/javascript/NativeObjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public void getPrototypeOfString() throws Exception {
+ " function test() {\n"
+ " try {\n"
+ " log(String.prototype === Object.getPrototypeOf(''));\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand All @@ -261,7 +261,7 @@ public void getPrototypeOfNumber() throws Exception {
+ " function test() {\n"
+ " try {\n"
+ " log(Number.prototype === Object.getPrototypeOf(1));\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand All @@ -284,7 +284,7 @@ public void getPrototypeOfBoolean() throws Exception {
+ " function test() {\n"
+ " try {\n"
+ " log(Boolean.prototype === Object.getPrototypeOf(true));\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand All @@ -307,7 +307,7 @@ public void getTypeOfPrototypeOfNumber() throws Exception {
+ " function test() {\n"
+ " try {\n"
+ " log(typeof Object.getPrototypeOf(1));\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand Down Expand Up @@ -340,7 +340,7 @@ public void getOwnPropertySymbols() throws Exception {
+ " log(objectSymbols.length);\n"
+ " log(objectSymbols[0] === a);\n"
+ " log(objectSymbols[1] === b);\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand All @@ -354,7 +354,7 @@ public void getOwnPropertySymbols() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts("exception")
@Alerts("TypeError")
public void getOwnPropertySymbolsEmpty() throws Exception {
final String html = ""
+ "<html><head>\n"
Expand All @@ -364,7 +364,7 @@ public void getOwnPropertySymbolsEmpty() throws Exception {
+ " try {\n"
+ " var objectSymbols = Object.getOwnPropertySymbols();\n"
+ " log(objectSymbols.length);\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand Down Expand Up @@ -397,7 +397,7 @@ public void getOwnPropertyDescriptor() throws Exception {
+ " log(desc);\n"

+ " log(typeof desc.get);\n"
+ " } catch(e) {log('exception')}\n"
+ " } catch(e) {log(e.name)}\n"
+ " }\n"
+ "</script>\n"
+ "</head>\n"
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/org/htmlunit/javascript/ScriptableObjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ public void getOwnPropertySymbols() throws Exception {
* @throws Exception on failure
*/
@Test
@Alerts({"exception", "true", "true"})
@Alerts({"TypeError", "true", "true"})
public void ctorNotChangeableForPrimitives() throws Exception {
final String html = "<html><body>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " let val = null;\n"
+ " try {\n"
+ " val.constructor = 1;\n"
+ " } catch (e) { log('exception'); }\n"
+ " } catch (e) { log(e.name); }\n"

+ " val = 'abc';\n"
+ " val.constructor = Number;"
Expand All @@ -133,7 +133,7 @@ public void ctorNotChangeableForPrimitives() throws Exception {
* @throws Exception on failure
*/
@Test
@Alerts({"exception", "true", "true"})
@Alerts({"TypeError", "true", "true"})
@NotYetImplemented
public void ctorNotChangeableForPrimitivesStrict() throws Exception {
final String html = "<html><body>\n"
Expand All @@ -145,7 +145,7 @@ public void ctorNotChangeableForPrimitivesStrict() throws Exception {
+ " let val = null;\n"
+ " try {\n"
+ " val.constructor = 1;\n"
+ " } catch (e) { log('exception'); }\n"
+ " } catch (e) { log(e.name); }\n"

+ " val = 'abc';\n"
+ " val.constructor = Number;"
Expand Down Expand Up @@ -185,7 +185,7 @@ public void ctorChangeableHasNoEffectForTypeOf() throws Exception {
+ " log('ctor');\n"
+ " a.constructor = 'bar';\n"
+ " log(a.constructor === 'bar');\n"
+ " } catch (e) { log('exception') }\n"
+ " } catch (e) { log(e.name) }\n"

+ "</script>\n"
+ "</body>\n"
Expand Down Expand Up @@ -216,7 +216,7 @@ public void ctorChangeableHasNoEffectForTypeOfStrict() throws Exception {
+ " log('ctor');\n"
+ " a.constructor = 'bar';\n"
+ " log(a.constructor === 'bar');\n"
+ " } catch (e) { log('exception') }\n"
+ " } catch (e) { log(e.name) }\n"

+ "</script>\n"
+ "</body>\n"
Expand Down Expand Up @@ -266,7 +266,7 @@ public void ctorChangeableHasNoEffectForSealedStrict() throws Exception {
+ " try {\n"
+ " a.constructor = Number;\n"
+ " log(a.constructor === Object);\n"
+ " } catch (e) { log('exception') }\n"
+ " } catch (e) { log(e.name) }\n"

+ "</script>\n"
+ "</body>\n"
Expand Down

0 comments on commit 56be803

Please sign in to comment.