diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 8bcca052ba6..e566f1447a7 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -8,6 +8,15 @@ + + Replace \n in console output with real line break. + + + core-js: Make sure the placeholder replacements of console.log() is also done for ConsStrings. + + + core-js: console.log() ignores %c styling but updates the param count to not disturb further replacements. + Support for unicode point escapes added when converting regex from js to java. diff --git a/src/main/java/com/gargoylesoftware/htmlunit/WebConsole.java b/src/main/java/com/gargoylesoftware/htmlunit/WebConsole.java index 501efb7a8b0..59bd0dec15f 100644 --- a/src/main/java/com/gargoylesoftware/htmlunit/WebConsole.java +++ b/src/main/java/com/gargoylesoftware/htmlunit/WebConsole.java @@ -160,7 +160,7 @@ public void print(final Context cx, final Scriptable scope, final Level level, switch (level) { case TRACE: if (logger_.isInfoEnabled()) { - String msg = NativeConsole.format(cx, scope, args); + String msg = format(cx, scope, args); if (stack != null) { final StringBuilder scriptStack = new StringBuilder(); scriptStack.append(msg); @@ -179,22 +179,22 @@ public void print(final Context cx, final Scriptable scope, final Level level, break; case DEBUG: if (logger_.isDebugEnabled()) { - logger_.debug(NativeConsole.format(cx, scope, args)); + logger_.debug(format(cx, scope, args)); } break; case INFO: if (logger_.isInfoEnabled()) { - logger_.info(NativeConsole.format(cx, scope, args)); + logger_.info(format(cx, scope, args)); } break; case WARN: if (logger_.isWarnEnabled()) { - logger_.warn(NativeConsole.format(cx, scope, args)); + logger_.warn(format(cx, scope, args)); } break; case ERROR: if (logger_.isErrorEnabled()) { - logger_.error(NativeConsole.format(cx, scope, args)); + logger_.error(format(cx, scope, args)); } break; @@ -203,6 +203,12 @@ public void print(final Context cx, final Scriptable scope, final Level level, } } + private String format(final Context cx, final Scriptable scope, final Object[] args) { + String msg = NativeConsole.format(cx, scope, args); + msg = msg.replaceAll("\\r?\\n", "\n"); + return msg; + } + /** * This class is the default logger used by WebConsole. */