Skip to content

Commit c893a66

Browse files
committed
more details for errors
1 parent 266e078 commit c893a66

File tree

209 files changed

+1104
-1090
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+1104
-1090
lines changed

src/test/java/org/htmlunit/WebDriverTestCase.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,21 @@
145145
*/
146146
public abstract class WebDriverTestCase extends WebTestCase {
147147

148+
private static final String LOG_EX_FUNCTION =
149+
" function logEx(e) {\n"
150+
+ " let rx = /\\[object (.*)\\]/;\n"
151+
+ " let toStr = Object.prototype.toString.call(e);\n"
152+
+ " let match = rx.exec(toStr);\n"
153+
+ " if (match != null) { toStr = match[1]; }\n"
154+
+ " log(e.name + '/' + toStr);\n"
155+
+ "}\n";
156+
148157
/**
149158
* Function used in many tests.
150159
*/
151160
public static final String LOG_TITLE_FUNCTION =
152-
" function log(msg) { window.document.title += msg + '\\u00a7'; }\n";
161+
" function log(msg) { window.document.title += msg + '\\u00a7'; }\n"
162+
+ LOG_EX_FUNCTION;
153163

154164
/**
155165
* Function used in many tests.
@@ -162,13 +172,16 @@ public abstract class WebDriverTestCase extends WebTestCase {
162172
+ "msg = msg.replace(/\\r/g, '\\\\r'); "
163173
+ "msg = msg.replace(/\\t/g, '\\\\t'); "
164174
+ "msg = msg.replace(/\\u001e/g, '\\\\u001e'); "
165-
+ "window.document.title += msg + '\u00A7';}\n";
175+
+ "window.document.title += msg + '\u00A7';}\n"
176+
177+
+ LOG_EX_FUNCTION;
166178

167179
/**
168180
* Function used in many tests.
169181
*/
170182
public static final String LOG_WINDOW_NAME_FUNCTION =
171-
" function log(msg) { window.top.name += msg + '\\u00a7'; }\n window.top.name = '';";
183+
" function log(msg) { window.top.name += msg + '\\u00a7'; }\n window.top.name = '';"
184+
+ LOG_EX_FUNCTION;
172185

173186
/**
174187
* Function used in many tests.
@@ -182,7 +195,8 @@ public abstract class WebDriverTestCase extends WebTestCase {
182195
* Function used in many tests.
183196
*/
184197
public static final String LOG_TEXTAREA_FUNCTION = " function log(msg) { "
185-
+ "document.getElementById('myLog').value += msg + '\u00A7';}\n";
198+
+ "document.getElementById('myLog').value += msg + '\u00A7';}\n"
199+
+ LOG_EX_FUNCTION;
186200

187201
/**
188202
* HtmlSniped to insert text area used for logging.

src/test/java/org/htmlunit/general/DedicatedWorkerGlobalScopeClassNameTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private void test(final String className) throws Exception {
4545
+ " log('' + e.data);\n"
4646
+ " };\n"
4747
+ " setTimeout(function() { myWorker.postMessage('test');}, 10);\n"
48-
+ "} catch(e) { log(e.name); }\n"
48+
+ "} catch(e) { logEx(e); }\n"
4949
+ "</script></body></html>\n";
5050

5151
final String workerJs = "onmessage = function(e) {\n"

src/test/java/org/htmlunit/general/DedicatedWorkerGlobalScopeTypeOfTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private void test(final String className) throws Exception {
4545
+ " log('' + e.data);\n"
4646
+ " };\n"
4747
+ " setTimeout(function() { myWorker.postMessage('test');}, 10);\n"
48-
+ "} catch(e) { log(e.name); }\n"
48+
+ "} catch(e) { logEx(e); }\n"
4949
+ "</script></body></html>\n";
5050

5151
final String workerJs = "onmessage = function(e) {\n"

src/test/java/org/htmlunit/general/ElementClosesItselfTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private void test(final String tagName) throws Exception {
107107
+ " var e = document.getElementById('outer');\n"
108108
+ " try {\n"
109109
+ " log(e == null ? e : e.children.length);\n"
110-
+ " } catch(e) { log(e.name); }"
110+
+ " } catch(e) { logEx(e); }"
111111
+ "}\n"
112112
+ "</script>\n"
113113
+ "</head><body onload='test()'>\n"

src/test/java/org/htmlunit/general/ElementOwnPropertiesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private void testString(final String preparation, final String string) throws Ex
8888
+ " try{\n"
8989
+ " " + preparation + "\n"
9090
+ " process(" + string + ");\n"
91-
+ " } catch (e) {log(e.name); return;}\n"
91+
+ " } catch (e) {logEx(e); return;}\n"
9292
+ " }\n"
9393
+ "\n"
9494
+ " /*\n"

src/test/java/org/htmlunit/general/ElementOwnPropertySymbolsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private void testString(final String preparation, final String string) throws Ex
8888
+ " try{\n"
8989
+ " " + preparation + "\n"
9090
+ " process(" + string + ");\n"
91-
+ " } catch (e) {log(e.name);return;}\n"
91+
+ " } catch (e) {logEx(e);return;}\n"
9292
+ " }\n"
9393
+ "\n"
9494
+ " /*\n"

src/test/java/org/htmlunit/general/ElementPropertiesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private void testString(final String preparation, final String string) throws Ex
8888
+ " try{\n"
8989
+ " " + preparation + "\n"
9090
+ " process(" + string + ");\n"
91-
+ " } catch (e) {log(e.name);return;}\n"
91+
+ " } catch (e) {logEx(e);return;}\n"
9292
+ " }\n"
9393
+ "\n"
9494
+ " /*\n"

src/test/java/org/htmlunit/general/HostClassNameTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private void test(final String className) throws Exception {
5959
// normalize FF output
6060
+ " clsName = clsName.replace('{\\n [native code]\\n}', '{ [native code] }');\n"
6161
+ " log(clsName);\n"
62-
+ " } catch(e) {log(e.name)}\n"
62+
+ " } catch(e) {logEx(e)}\n"
6363
+ " }\n"
6464
+ "</script></head>\n"
6565
+ "<body onload='test()'>\n"

src/test/java/org/htmlunit/general/HostConstructorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private void test(final String className) throws Exception {
9494

9595
+ " try {\n"
9696
+ " log(new " + className + "());\n"
97-
+ " } catch(e) {log(e.name)}\n"
97+
+ " } catch(e) {logEx(e)}\n"
9898
+ "</script>\n"
9999
+ "</body></html>";
100100

src/test/java/org/htmlunit/general/HostTypeOfTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private void test(final String className) throws Exception {
4141
+ " function test() {\n"
4242
+ " try {\n"
4343
+ " log(typeof " + className + ");\n"
44-
+ " } catch(e) {log(e.name)}\n"
44+
+ " } catch(e) {logEx(e)}\n"
4545
+ " }\n"
4646
+ "</script></head><body onload='test()'>\n"
4747
+ "</body></html>";

0 commit comments

Comments
 (0)