Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp

Issue 2530503002: [wasm][asm.js] Routing asm.js warnings to the dev console. (Closed)
Patch Set: fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
index dcb07ce1011bfb5097babc465b707c2ab34f9c52..dd5752155edae047aefe25c55a573701306d01b4 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
@@ -49,6 +49,7 @@
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
+#include "core/inspector/ConsoleMessage.h"
#include "core/inspector/MainThreadDebugger.h"
#include "core/workers/WorkerGlobalScope.h"
#include "platform/EventDispatchForbiddenScope.h"
@@ -139,6 +140,36 @@ void V8Initializer::messageHandlerInMainThread(v8::Local<v8::Message> message,
std::unique_ptr<SourceLocation> location =
SourceLocation::fromMessage(isolate, message, context);
+ if (message->ErrorLevel() != v8::Isolate::kMessageError) {
+ // Ignore if called before frame is ready.
+ if (!context->isDocument()) {
+ return;
+ }
+ LocalFrame* frame = toDocument(context)->frame();
+
+ MessageLevel level;
+ switch (message->ErrorLevel()) {
+ case v8::Isolate::kMessageLog:
+ level = LogMessageLevel;
+ break;
+ case v8::Isolate::kMessageWarning:
+ level = WarningMessageLevel;
+ break;
+ case v8::Isolate::kMessageDebug:
+ level = DebugMessageLevel;
+ break;
+ case v8::Isolate::kMessageInfo:
+ level = InfoMessageLevel;
+ break;
+ default:
+ UNREACHABLE();
+ }
+ frame->document()->addConsoleMessage(ConsoleMessage::create(
dgozman 2016/12/01 18:38:33 ExecutionContext has addConsoleMessage method, let
bradnelson 2016/12/14 08:26:39 Done.
+ JSMessageSource, level, toCoreStringWithNullCheck(message->Get()),
+ std::move(location)));
+ return;
+ }
+
AccessControlStatus accessControlStatus = NotSharableCrossOrigin;
if (message->IsOpaque())
accessControlStatus = OpaqueResource;
@@ -400,7 +431,11 @@ void V8Initializer::initializeMainThread() {
isolate->SetOOMErrorHandler(reportOOMErrorInMainThread);
isolate->SetFatalErrorHandler(reportFatalErrorInMainThread);
- isolate->AddMessageListener(messageHandlerInMainThread);
+ isolate->AddMessageListener(
+ messageHandlerInMainThread, v8::Local<v8::Value>(),
+ v8::Isolate::kMessageError | v8::Isolate::kMessageWarning |
+ v8::Isolate::kMessageInfo | v8::Isolate::kMessageDebug |
+ v8::Isolate::kMessageLog);
isolate->SetFailedAccessCheckCallbackFunction(
failedAccessCheckCallbackInMainThread);
isolate->SetAllowCodeGenerationFromStringsCallback(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698