Cover CJX_Script::stateless() from JavaScript test
-- simplify its clumsy return value getter code.
Change-Id: I3e865383d1f4684360238690a641e095cef11f84
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/68430
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/xfa/cjx_script.cpp b/fxjs/xfa/cjx_script.cpp
index 482a57e..207a2ce 100644
--- a/fxjs/xfa/cjx_script.cpp
+++ b/fxjs/xfa/cjx_script.cpp
@@ -24,5 +24,5 @@
ThrowInvalidPropertyException();
return;
}
- pValue->SetString(FX_UTF8Encode(WideStringView(L"0", 1)).AsStringView());
+ pValue->SetString("0");
}
diff --git a/testing/resources/javascript/xfa_specific/xfa_variables.in b/testing/resources/javascript/xfa_specific/xfa_variables.in
index 429e663..6bfdb97 100644
--- a/testing/resources/javascript/xfa_specific/xfa_variables.in
+++ b/testing/resources/javascript/xfa_specific/xfa_variables.in
@@ -27,13 +27,17 @@
</pageArea>
</pageSet>
<event activity="docReady" ref="$host">
- <script name="my_script" contentType="application/x-javascript">
+ <script name="my_script" contentType="application/x-javascript"><![CDATA[
+ {{include ../expect.js}}
try {
- app.alert('We search variables context ' + (xx01.value + xx02.value));
- app.alert('We search variables context ' + (xx03.value + xx04.value));
var script1 = xfa.resolveNode('template..my_script');
var script2 = xfa.resolveNode('template..their_script');
var script3 = xfa.resolveNode('template..other_script');
+ app.alert('First, poke at a script node itsef');
+ expect('script1.stateless', '0');
+ expectError('script1.stateless = 42');
+ app.alert('We search variables context ' + (xx01.value + xx02.value));
+ app.alert('We search variables context ' + (xx03.value + xx04.value));
app.alert('We resolve off of script1 ' + (script1.xx01.value + script1.xx02.value));
app.alert('We resolve off of script2 ' + (script2.xx01.value + script2.xx02.value));
app.alert('We resolve off of script3 ' + (script3.xx01.value + script3.xx02.value));
@@ -43,7 +47,7 @@
} catch (e) {
app.alert('Error: ' + e);
}
- </script>
+ ]]></script>
</event>
</subform>
<subform layout="tb" name="their_doc">
diff --git a/testing/resources/javascript/xfa_specific/xfa_variables_expected.txt b/testing/resources/javascript/xfa_specific/xfa_variables_expected.txt
index bdb521c..75a457f 100644
--- a/testing/resources/javascript/xfa_specific/xfa_variables_expected.txt
+++ b/testing/resources/javascript/xfa_specific/xfa_variables_expected.txt
@@ -1,3 +1,6 @@
+Alert: First, poke at a script node itsef
+Alert: PASS: script1.stateless = 0
+Alert: PASS: script1.stateless = 42 threw Error: Invalid property set operation.
Alert: We search variables context 123456
Alert: We search variables context 579
Alert: We resolve off of script1 123456