[Extensions + Blink] Log messages from extension bindings in SWs

Extension bindings use a custom console object so that untrusted script
can't intercept any calls. This custom console reports messages via
RenderFrame::AddMessageToConsole(), which reports the messages to the
developer console and the browser process, which also logs them to
the terminal if appropriate (e.g., in debug mode or with
--enable-logging).  These logs are both important for developers (when
something goes wrong so they can see it in the console) and to browser
tests (so that we get detailed errors and can debug).

Unfortunately, these aren't currently logged for ServiceWorker contexts,
because there is no RenderFrame to log the message with.

Fix this by adding a new WebConsoleMessage::LogWebConsoleMessage()
static method that takes a v8::Context and logs the message in the
execution context associated with that context. This works for both
frame-based and worker-based contexts.

Additionally, expose a OnReportConsoleMessage() virtual method on
ServiceWorkerContextObserver to allow extensions code to observe
console messages. This allows us to test this behavior, and could also
be used to hook into recording error messages in extensions (e.g. for
the extensions::ErrorConsole).

Bug: 933941
Change-Id: Ic67ed46a608c3b4340e25fe695689d2cfeca30aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1495045
Commit-Queue: Devlin <[email protected]>
Reviewed-by: Jeremy Roman <[email protected]>
Reviewed-by: Matt Falkenhagen <[email protected]>
Reviewed-by: Kinuko Yasuda <[email protected]>
Cr-Commit-Position: refs/heads/master@{#637525}
16 files changed