Add several missing CFXJSE_Value::IsEmpty() calls.

BUG=pdfium:1269

Change-Id: Id8431ecd57f401ee47e05f3d43501bb0088dec74
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/52210
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 3d06629..879ba02 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -5551,7 +5551,7 @@
 // static
 int32_t CFXJSE_FormCalcContext::ValueToInteger(CFXJSE_Value* pThis,
                                                CFXJSE_Value* pValue) {
-  if (!pValue)
+  if (!pValue || pValue->IsEmpty())
     return 0;
 
   v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime();
diff --git a/fxjs/xfa/cfxjse_value.cpp b/fxjs/xfa/cfxjse_value.cpp
index c55226d..194e77d 100644
--- a/fxjs/xfa/cfxjse_value.cpp
+++ b/fxjs/xfa/cfxjse_value.cpp
@@ -131,6 +131,9 @@
 bool CFXJSE_Value::SetObjectProperty(ByteStringView szPropName,
                                      CFXJSE_Value* lpPropValue) {
   ASSERT(lpPropValue);
+  if (lpPropValue->IsEmpty())
+    return false;
+
   CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate());
   v8::Local<v8::Value> hObject =
       v8::Local<v8::Value>::New(GetIsolate(), m_hValue);
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 8f1331f..1ea2eb3 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -1428,8 +1428,10 @@
 
   if (bSetting) {
     WideString wsNewValue;
-    if (pValue && !(pValue->IsNull() || pValue->IsUndefined()))
+    if (pValue &&
+        !(pValue->IsEmpty() || pValue->IsNull() || pValue->IsUndefined())) {
       wsNewValue = pValue->ToWideString();
+    }
 
     WideString wsFormatValue(wsNewValue);
     CXFA_Node* pContainerNode = nullptr;
diff --git a/testing/resources/pixel/xfa_specific/bug_1269_1.in b/testing/resources/pixel/xfa_specific/bug_1269_1.in
new file mode 100644
index 0000000..ec7b6da
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/bug_1269_1.in
@@ -0,0 +1,18 @@
+{{header}}
+{{include ../../xfa_catalog_1_0.fragment}}
+{{include ../../xfa_object_single_2_0.fragment}}
+{{object 3 0}} <<
+  {{streamlen}}
+>>
+stream
+<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
+<template>
+<subform use=" .[$host.calculationsEnabled=$]">
+<field>
+endstream
+endobj
+{{include ../../xfa_pages_8_0.fragment}}
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/pixel/xfa_specific/bug_1269_1_expected.pdf.0.png b/testing/resources/pixel/xfa_specific/bug_1269_1_expected.pdf.0.png
new file mode 100644
index 0000000..08c11b0
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/bug_1269_1_expected.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/bug_1269_2.in b/testing/resources/pixel/xfa_specific/bug_1269_2.in
new file mode 100644
index 0000000..80425e9
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/bug_1269_2.in
@@ -0,0 +1,19 @@
+{{header}}
+{{include ../../xfa_catalog_1_0.fragment}}
+{{include ../../xfa_object_single_2_0.fragment}}
+{{object 3 0}} <<
+  {{streamlen}}
+>>
+stream
+<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
+<template>
+<defaultUi use=" .[c=$]">
+<field>
+<contentArea name="c">
+endstream
+endobj
+{{include ../../xfa_pages_8_0.fragment}}
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/pixel/xfa_specific/bug_1269_2_expected.pdf.0.png b/testing/resources/pixel/xfa_specific/bug_1269_2_expected.pdf.0.png
new file mode 100644
index 0000000..08c11b0
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/bug_1269_2_expected.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/bug_1269_3.in b/testing/resources/pixel/xfa_specific/bug_1269_3.in
new file mode 100644
index 0000000..5bbbeb6
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/bug_1269_3.in
@@ -0,0 +1,18 @@
+{{header}}
+{{include ../../xfa_catalog_1_0.fragment}}
+{{include ../../xfa_object_single_2_0.fragment}}
+{{object 3 0}} <<
+  {{streamlen}}
+>>
+stream
+<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
+<template>
+<template use=" .[Space($)]">
+<field>
+endstream
+endobj
+{{include ../../xfa_pages_8_0.fragment}}
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/pixel/xfa_specific/bug_1269_3_expected.pdf.0.png b/testing/resources/pixel/xfa_specific/bug_1269_3_expected.pdf.0.png
new file mode 100644
index 0000000..08c11b0
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/bug_1269_3_expected.pdf.0.png
Binary files differ