From 0784c7317e3aaa2c65d098cf2593b6b49986307d Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 23 Apr 2018 18:02:57 +0000 Subject: Disable JavaScript entirely if no JSPlatform passed by embedder. Allows run-time selection of whether to permit JS inside PDF. Previously, this was a link-time decision only. This requires a little more caution before we decide that we have the CJS_Runtime, and not the CJS_RuntimeStub in a few casts. Adds a kDisableJavaScript option to the form fill embeddertests. Adds a --disable-javascript flag to the pdfium_test executable. Also adds a --disable-xfa flag while we're at it. Change-Id: I8d8ac95f6474459cadba9a60572fbb342e984646 Reviewed-on: https://pdfium-review.googlesource.com/31090 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- testing/xfa_js_embedder_test.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'testing/xfa_js_embedder_test.cpp') diff --git a/testing/xfa_js_embedder_test.cpp b/testing/xfa_js_embedder_test.cpp index 0fe4b7a624..995c0ed1d5 100644 --- a/testing/xfa_js_embedder_test.cpp +++ b/testing/xfa_js_embedder_test.cpp @@ -47,21 +47,24 @@ CXFA_Document* XFAJSEmbedderTest::GetXFADocument() { return UnderlyingFromFPDFDocument(document())->GetXFADoc()->GetXFADoc(); } -bool XFAJSEmbedderTest::OpenDocumentWithOptions(const std::string& filename, - const char* password, - bool must_linearize) { - if (!EmbedderTest::OpenDocumentWithOptions(filename, password, - must_linearize)) +bool XFAJSEmbedderTest::OpenDocumentWithOptions( + const std::string& filename, + const char* password, + LinearizeOption linearize_option, + JavaScriptOption javascript_option) { + // JS required for XFA. + ASSERT(javascript_option == JavaScriptOption::kEnableJavaScript); + if (!EmbedderTest::OpenDocumentWithOptions( + filename, password, linearize_option, javascript_option)) { return false; - + } script_context_ = GetXFADocument()->GetScriptContext(); return true; } bool XFAJSEmbedderTest::Execute(const ByteStringView& input) { - if (ExecuteHelper(input)) { + if (ExecuteHelper(input)) return true; - } CFXJSE_Value msg(GetIsolate()); value_->GetObjectPropertyByIdx(1, &msg); -- cgit v1.2.3