Backport the fix on webpage.onConsoleMessage()

Refs #194