From 3321f15291b3fff3ebd6ef41bf48d883c8b78352 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Tue, 28 Aug 2018 20:19:03 +0000 Subject: Make built-in JS console compatible with Adobe's console. console.show() and console.println() are calls commonly found in XFA scripts. This CL adds methods to the built-in V8 console so these calls do not stop the rest of script from running. Bug: chromium:872893 Change-Id: I661f505176884558ae2d658312d561a28767ae25 Reviewed-on: https://pdfium-review.googlesource.com/41533 Reviewed-by: Ryan Harrison Commit-Queue: Henrique Nakashima --- fxjs/cfxjse_context.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fxjs/cfxjse_context.cpp b/fxjs/cfxjse_context.cpp index 6c5a95f966..5d40f6fa83 100644 --- a/fxjs/cfxjse_context.cpp +++ b/fxjs/cfxjse_context.cpp @@ -42,6 +42,13 @@ const char szCompatibleModeScript[] = " }\n" "}(this, {String: ['substr', 'toUpperCase']}));"; +const char szConsoleScript[] = + "console.show = function() {};\n" + "\n" + "console.println = function(...args) {\n" + " this.log(...args);\n" + "};"; + // Only address matters, values are for humans debuging here. char g_FXJSEHostObjectTag[] = "FXJSE Host Object"; char g_FXJSEProxyObjectTag[] = "FXJSE Proxy Object"; @@ -221,6 +228,7 @@ CFXJSE_Class* CFXJSE_Context::GetClassByName( void CFXJSE_Context::EnableCompatibleMode() { ExecuteScript(szCompatibleModeScript, nullptr, nullptr); + ExecuteScript(szConsoleScript, nullptr, nullptr); } bool CFXJSE_Context::ExecuteScript(const char* szScript, -- cgit v1.2.3