Skip to content

Commit cb3213a

Browse files
committed
console update
1 parent dffab74 commit cb3213a

File tree

3 files changed

+111
-4
lines changed

3 files changed

+111
-4
lines changed

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

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ private void test(final String tagName) throws Exception {
7474
}
7575

7676
private void testString(final String preparation, final String string) throws Exception {
77+
testString(preparation, string, true);
78+
}
79+
80+
private void testInstanceString(final String preparation, final String string) throws Exception {
81+
testString(preparation, string, false);
82+
}
83+
84+
private void testString(final String preparation,
85+
final String string, final boolean fromCtor) throws Exception {
7786
final String html = DOCTYPE_HTML
7887
+ "<html><head><script>\n"
7988
+ LOG_TEXTAREA_FUNCTION
@@ -96,11 +105,13 @@ private void testString(final String preparation, final String string) throws Ex
96105
+ " */\n"
97106
+ " function process(object) {\n"
98107
+ " var all = [];\n"
99-
+ " var props = Object.getOwnPropertyNames(object.constructor.prototype);\n"
108+
+ " var props = Object.getOwnPropertyNames(object"
109+
+ (fromCtor ? ".constructor.prototype" : "") + ");\n"
100110
+ " for (i = 0; i < props.length; i++) {\n"
101111
+ " var property = props[i];\n"
102112

103-
+ " let desc = Object.getOwnPropertyDescriptor(object.constructor.prototype, property);\n"
113+
+ " let desc = Object.getOwnPropertyDescriptor(object"
114+
+ (fromCtor ? ".constructor.prototype" : "") + ", property);\n"
104115
+ " if (desc.get === undefined && typeof object[property] == 'function') {\n"
105116
+ " all.push(property + '()');\n"
106117
+ " } else {\n"
@@ -18588,4 +18599,39 @@ public void domMatrix() throws Exception {
1858818599
public void notification() throws Exception {
1858918600
testString("", "new Notification('not')");
1859018601
}
18602+
18603+
/**
18604+
* Test console.
18605+
*
18606+
* @throws Exception if the test fails
18607+
*/
18608+
@Test
18609+
@Alerts(CHROME = "assert(),clear(),context(),count(),countReset(),createTask(),debug(),dir(),dirxml(),error(),"
18610+
+ "group(),groupCollapsed(),groupEnd(),info(),log(),memory[GSCE],profile(),profileEnd(),table(),"
18611+
+ "time(),timeEnd(),timeLog(),timeStamp(),trace(),"
18612+
+ "warn()",
18613+
EDGE = "assert(),clear(),context(),count(),countReset(),createTask(),debug(),dir(),dirxml(),error(),"
18614+
+ "group(),groupCollapsed(),groupEnd(),info(),log(),memory[GSCE],profile(),profileEnd(),table(),"
18615+
+ "time(),timeEnd(),timeLog(),timeStamp(),trace(),"
18616+
+ "warn()",
18617+
FF = "assert(),clear(),count(),countReset(),debug(),dir(),dirxml(),error(),exception(),group(),"
18618+
+ "groupCollapsed(),groupEnd(),info(),log(),profile(),profileEnd(),table(),time(),timeEnd(),"
18619+
+ "timeLog(),timeStamp(),trace(),"
18620+
+ "warn()",
18621+
FF_ESR = "assert(),clear(),count(),countReset(),debug(),dir(),dirxml(),error(),exception(),group(),"
18622+
+ "groupCollapsed(),groupEnd(),info(),log(),profile(),profileEnd(),table(),time(),timeEnd(),"
18623+
+ "timeLog(),timeStamp(),trace(),"
18624+
+ "warn()")
18625+
@HtmlUnitNYI(
18626+
CHROME = "assert(),count(),countReset(),debug(),error(),info(),log(),"
18627+
+ "time(),timeEnd(),timeLog(),timeStamp(),toSource(),trace(),warn()",
18628+
EDGE = "assert(),count(),countReset(),debug(),error(),info(),log(),"
18629+
+ "time(),timeEnd(),timeLog(),timeStamp(),toSource(),trace(),warn()",
18630+
FF = "assert(),count(),countReset(),debug(),error(),info(),log(),"
18631+
+ "time(),timeEnd(),timeLog(),timeStamp(),toSource(),trace(),warn()",
18632+
FF_ESR = "assert(),count(),countReset(),debug(),error(),info(),log(),"
18633+
+ "time(),timeEnd(),timeLog(),timeStamp(),toSource(),trace(),warn()")
18634+
public void console() throws Exception {
18635+
testInstanceString("", "console");
18636+
}
1859118637
}

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,17 @@ private void test(final String tagName) throws Exception {
7373
testString("", "document.createElement('" + tagName + "')");
7474
}
7575

76+
7677
private void testString(final String preparation, final String string) throws Exception {
78+
testString(preparation, string, true);
79+
}
80+
81+
private void testInstanceString(final String preparation, final String string) throws Exception {
82+
testString(preparation, string, false);
83+
}
84+
85+
private void testString(final String preparation,
86+
final String string, final boolean fromCtor) throws Exception {
7787
final String html = DOCTYPE_HTML
7888
+ "<html><head><script>\n"
7989
+ LOG_TEXTAREA_FUNCTION
@@ -96,11 +106,13 @@ private void testString(final String preparation, final String string) throws Ex
96106
+ " */\n"
97107
+ " function process(object) {\n"
98108
+ " var all = [];\n"
99-
+ " var props = Object.getOwnPropertySymbols(object.constructor.prototype);\n"
109+
+ " var props = Object.getOwnPropertySymbols(object"
110+
+ (fromCtor ? ".constructor.prototype" : "") + ");\n"
100111
+ " for (i = 0; i < props.length; i++) {\n"
101112
+ " var str = props[i].toString();\n"
102113

103-
+ " let desc = Object.getOwnPropertyDescriptor(object.constructor.prototype, props[i]);\n"
114+
+ " let desc = Object.getOwnPropertyDescriptor(object"
115+
+ (fromCtor ? ".constructor.prototype" : "") + ", props[i]);\n"
104116
+ " str += ' [';\n"
105117
+ " if (desc.get != undefined) str += 'G';\n"
106118
+ " if (desc.set != undefined) str += 'S';\n"
@@ -3379,4 +3391,19 @@ public void domMatrix() throws Exception {
33793391
public void notification() throws Exception {
33803392
testString("", "new Notification('not')");
33813393
}
3394+
3395+
/**
3396+
* Test console.
3397+
*
3398+
* @throws Exception if the test fails
3399+
*/
3400+
@Test
3401+
@Alerts(CHROME = "Symbol(Symbol.toStringTag) [C] [console]",
3402+
EDGE = "Symbol(Symbol.toStringTag) [C] [console]",
3403+
FF = "Symbol(Symbol.toStringTag) [C] [console]",
3404+
FF_ESR = "Symbol(Symbol.toStringTag) [C] [console]")
3405+
@HtmlUnitNYI(CHROME = "-", EDGE = "-", FF = "-", FF_ESR = "-")
3406+
public void console() throws Exception {
3407+
testInstanceString("", "console");
3408+
}
33823409
}

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9671,4 +9671,38 @@ public void domMatrix() throws Exception {
96719671
public void notification() throws Exception {
96729672
testString("", "new Notification('not')");
96739673
}
9674+
9675+
/**
9676+
* Test console.
9677+
*
9678+
* @throws Exception if the test fails
9679+
*/
9680+
@Test
9681+
@Alerts(CHROME = "assert(),clear(),context(),count(),countReset(),createTask(),debug(),dir(),dirxml(),error(),"
9682+
+ "group(),groupCollapsed(),groupEnd(),info(),log(),memory,profile(),profileEnd(),table(),time(),"
9683+
+ "timeEnd(),timeLog(),timeStamp(),trace(),"
9684+
+ "warn()",
9685+
EDGE = "assert(),clear(),context(),count(),countReset(),createTask(),debug(),dir(),dirxml(),error(),"
9686+
+ "group(),groupCollapsed(),groupEnd(),info(),log(),memory,profile(),profileEnd(),table(),time(),"
9687+
+ "timeEnd(),timeLog(),timeStamp(),trace(),"
9688+
+ "warn()",
9689+
FF = "assert(),clear(),count(),countReset(),debug(),dir(),dirxml(),error(),exception(),group(),"
9690+
+ "groupCollapsed(),groupEnd(),info(),log(),profile(),profileEnd(),table(),time(),timeEnd(),"
9691+
+ "timeLog(),timeStamp(),trace(),"
9692+
+ "warn()",
9693+
FF_ESR = "assert(),clear(),count(),countReset(),debug(),dir(),dirxml(),error(),exception(),group(),"
9694+
+ "groupCollapsed(),groupEnd(),info(),log(),profile(),profileEnd(),table(),time(),timeEnd(),"
9695+
+ "timeLog(),timeStamp(),trace(),"
9696+
+ "warn()")
9697+
@HtmlUnitNYI(CHROME = "assert(),count(),countReset(),debug(),error(),info(),log(),"
9698+
+ "time(),timeEnd(),timeLog(),toSource(),trace(),warn()",
9699+
EDGE = "assert(),count(),countReset(),debug(),error(),info(),log(),"
9700+
+ "time(),timeEnd(),timeLog(),toSource(),trace(),warn()",
9701+
FF = "assert(),count(),countReset(),debug(),error(),info(),log(),"
9702+
+ "time(),timeEnd(),timeLog(),toSource(),trace(),warn()",
9703+
FF_ESR = "assert(),count(),countReset(),debug(),error(),info(),log(),"
9704+
+ "time(),timeEnd(),timeLog(),toSource(),trace(),warn()")
9705+
public void console() throws Exception {
9706+
testString("", "console");
9707+
}
96749708
}

0 commit comments

Comments
 (0)