Skip to content

Commit ca7cdf2

Browse files
committed
more console tests
1 parent cb3213a commit ca7cdf2

File tree

1 file changed

+113
-3
lines changed

1 file changed

+113
-3
lines changed

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

Lines changed: 113 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,32 @@ public void timeStamp() throws Exception {
104104
* @throws Exception if the test fails
105105
*/
106106
@Test
107-
@Alerts({"function", "function", "function", "function", "function", "function"})
107+
@Alerts({"function", "function", "function", "function", "function", "function",
108+
"function", "function", "function", "function", "function", "function",
109+
"function"})
108110
public void methods() throws Exception {
109111
final String html = DOCTYPE_HTML
110112
+ "<html>\n"
111113
+ "<body>\n"
112114
+ "<script>\n"
113115
+ LOG_TITLE_FUNCTION
114116
+ " log(typeof console.log);\n"
117+
+ " log(typeof console.trace);\n"
115118
+ " log(typeof console.info);\n"
116119
+ " log(typeof console.warn);\n"
117120
+ " log(typeof console.error);\n"
118121
+ " log(typeof console.debug);\n"
122+
123+
+ " log(typeof console.assert);\n"
124+
125+
+ " log(typeof console.time);\n"
126+
+ " log(typeof console.timeLog);\n"
127+
+ " log(typeof console.timeEnd);\n"
119128
+ " log(typeof console.timeStamp);\n"
129+
130+
+ " log(typeof console.count);\n"
131+
+ " log(typeof console.countReset);\n"
132+
120133
+ "</script>\n"
121134
+ "</body></html>";
122135

@@ -149,15 +162,112 @@ public void windowProperty() throws Exception {
149162
*/
150163
@Test
151164
@Alerts("success")
152-
public void fromWindow() throws Exception {
165+
public void logFromWindow() throws Exception {
153166
final String html = DOCTYPE_HTML
154167
+ "<html>\n"
155168
+ "<body>\n"
156169
+ "<script>\n"
157170
+ LOG_TITLE_FUNCTION
158171
+ " try {\n"
159-
+ " var x = console.error;\n"
172+
+ " let x = console.log;\n"
173+
+ " x('hello');\n"
174+
175+
+ " x = console.trace;\n"
176+
+ " x('hello');\n"
177+
178+
+ " x = console.info;\n"
179+
+ " x('hello');\n"
180+
181+
+ " x = console.warn;\n"
182+
+ " x('hello');\n"
183+
184+
+ " x = console.error;\n"
185+
+ " x('hello');\n"
186+
187+
+ " x = console.debug;\n"
160188
+ " x('hello');\n"
189+
190+
+ " log('success');\n"
191+
+ " } catch(e) { logEx(e) }\n"
192+
+ "</script>\n"
193+
+ "</body></html>";
194+
195+
loadPageVerifyTitle2(html);
196+
}
197+
198+
/**
199+
* @throws Exception if the test fails
200+
*/
201+
@Test
202+
@Alerts("success")
203+
public void timeFromWindow() throws Exception {
204+
final String html = DOCTYPE_HTML
205+
+ "<html>\n"
206+
+ "<body>\n"
207+
+ "<script>\n"
208+
+ LOG_TITLE_FUNCTION
209+
+ " try {\n"
210+
+ " let x = console.time;\n"
211+
+ " x('hello');\n"
212+
213+
+ " x = console.timeLog;\n"
214+
+ " x('hello');\n"
215+
216+
+ " x = console.timeEnd;\n"
217+
+ " x('hello');\n"
218+
219+
+ " x = console.timeStamp;\n"
220+
+ " x('hello');\n"
221+
222+
+ " log('success');\n"
223+
+ " } catch(e) { logEx(e) }\n"
224+
+ "</script>\n"
225+
+ "</body></html>";
226+
227+
loadPageVerifyTitle2(html);
228+
}
229+
230+
/**
231+
* @throws Exception if the test fails
232+
*/
233+
@Test
234+
@Alerts("success")
235+
public void assertFromWindow() throws Exception {
236+
final String html = DOCTYPE_HTML
237+
+ "<html>\n"
238+
+ "<body>\n"
239+
+ "<script>\n"
240+
+ LOG_TITLE_FUNCTION
241+
+ " try {\n"
242+
+ " let x = console.assert;\n"
243+
+ " x(true, 'hello');\n"
244+
245+
+ " log('success');\n"
246+
+ " } catch(e) { logEx(e) }\n"
247+
+ "</script>\n"
248+
+ "</body></html>";
249+
250+
loadPageVerifyTitle2(html);
251+
}
252+
253+
/**
254+
* @throws Exception if the test fails
255+
*/
256+
@Test
257+
@Alerts("success")
258+
public void countFromWindow() throws Exception {
259+
final String html = DOCTYPE_HTML
260+
+ "<html>\n"
261+
+ "<body>\n"
262+
+ "<script>\n"
263+
+ LOG_TITLE_FUNCTION
264+
+ " try {\n"
265+
+ " let x = console.count;\n"
266+
+ " x('hello');\n"
267+
268+
+ " x = console.countReset;\n"
269+
+ " x('hello');\n"
270+
161271
+ " log('success');\n"
162272
+ " } catch(e) { logEx(e) }\n"
163273
+ "</script>\n"

0 commit comments

Comments
 (0)