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

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: merge 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 | « third_party/WebKit/LayoutTests/virtual/enable_asmjs/http/tests/asmjs/worker.js ('k') | 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 20f8c1094b240b16c3b5eb3b13ccb5dd983a7c8c..c0ed0c3585dbf85783940aa47025fab7df6e8f5d 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
@@ -48,6 +48,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"
@@ -118,6 +119,32 @@ static String extractMessageForConsole(v8::Isolate* isolate,
return emptyString();
}
+namespace {
+MessageLevel MessageLevelFromNonFatalErrorLevel(int errorLevel) {
+ MessageLevel level = ErrorMessageLevel;
+ switch (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;
+ case v8::Isolate::kMessageError:
+ level = InfoMessageLevel;
+ break;
+ default:
+ NOTREACHED();
+ }
+ return level;
+}
+} // namespace
+
void V8Initializer::messageHandlerInMainThread(v8::Local<v8::Message> message,
v8::Local<v8::Value> data) {
ASSERT(isMainThread());
@@ -135,6 +162,14 @@ void V8Initializer::messageHandlerInMainThread(v8::Local<v8::Message> message,
std::unique_ptr<SourceLocation> location =
SourceLocation::fromMessage(isolate, message, context);
+ if (message->ErrorLevel() != v8::Isolate::kMessageError) {
+ context->addConsoleMessage(ConsoleMessage::create(
+ JSMessageSource,
+ MessageLevelFromNonFatalErrorLevel(message->ErrorLevel()),
+ toCoreStringWithNullCheck(message->Get()), std::move(location)));
+ return;
+ }
+
AccessControlStatus accessControlStatus = NotSharableCrossOrigin;
if (message->IsOpaque())
accessControlStatus = OpaqueResource;
@@ -374,7 +409,11 @@ void V8Initializer::initializeMainThread() {
isolate->SetOOMErrorHandler(reportOOMErrorInMainThread);
isolate->SetFatalErrorHandler(reportFatalErrorInMainThread);
- isolate->AddMessageListener(messageHandlerInMainThread);
+ isolate->AddMessageListenerWithErrorLevel(
+ messageHandlerInMainThread,
+ v8::Isolate::kMessageError | v8::Isolate::kMessageWarning |
+ v8::Isolate::kMessageInfo | v8::Isolate::kMessageDebug |
+ v8::Isolate::kMessageLog);
isolate->SetFailedAccessCheckCallbackFunction(
failedAccessCheckCallbackInMainThread);
isolate->SetAllowCodeGenerationFromStringsCallback(
@@ -444,6 +483,15 @@ static void messageHandlerInWorker(v8::Local<v8::Message> message,
ExecutionContext* context = scriptState->getExecutionContext();
std::unique_ptr<SourceLocation> location =
SourceLocation::fromMessage(isolate, message, context);
+
+ if (message->ErrorLevel() != v8::Isolate::kMessageError) {
+ context->addConsoleMessage(ConsoleMessage::create(
+ JSMessageSource,
+ MessageLevelFromNonFatalErrorLevel(message->ErrorLevel()),
+ toCoreStringWithNullCheck(message->Get()), std::move(location)));
+ return;
+ }
+
ErrorEvent* event =
ErrorEvent::create(toCoreStringWithNullCheck(message->Get()),
std::move(location), &scriptState->world());
@@ -476,7 +524,11 @@ NO_SANITIZE_ADDRESS
void V8Initializer::initializeWorker(v8::Isolate* isolate) {
initializeV8Common(isolate);
- isolate->AddMessageListener(messageHandlerInWorker);
+ isolate->AddMessageListenerWithErrorLevel(
+ messageHandlerInWorker,
+ v8::Isolate::kMessageError | v8::Isolate::kMessageWarning |
+ v8::Isolate::kMessageInfo | v8::Isolate::kMessageDebug |
+ v8::Isolate::kMessageLog);
isolate->SetFatalErrorHandler(reportFatalErrorInWorker);
uint32_t here;
« no previous file with comments | « third_party/WebKit/LayoutTests/virtual/enable_asmjs/http/tests/asmjs/worker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698