summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-08-28 20:19:03 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-28 20:19:03 +0000
commit3321f15291b3fff3ebd6ef41bf48d883c8b78352 (patch)
treeaa50c08dd8ec467242aeddd5a9c4f9ef84a73a2a /fxjs
parent7e4fff7163382cb40b761a383fad9a2e313713c7 (diff)
downloadpdfium-3321f15291b3fff3ebd6ef41bf48d883c8b78352.tar.xz
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 <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cfxjse_context.cpp8
1 files changed, 8 insertions, 0 deletions
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,