aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2019-12-10 00:41:12 +0000
committerChromium commit bot <commit-bot@chromium.org>2019-12-10 00:41:12 +0000
commit787d4c1a2b96f23dd8199ba9f47d2ad22d9573bf (patch)
treedda7b48642baec27acefe3bf2230bd194701e761 /testing
parentab23ea7adbc6ad1e27ae14e44bb15663e10dbf6e (diff)
downloadplatform_external_pdfium-787d4c1a2b96f23dd8199ba9f47d2ad22d9573bf.tar.gz
platform_external_pdfium-787d4c1a2b96f23dd8199ba9f47d2ad22d9573bf.tar.bz2
platform_external_pdfium-787d4c1a2b96f23dd8199ba9f47d2ad22d9573bf.zip
Add JavaScript tests for file select fields.
- Re-order dictionary entries to match our convention while at it. Change-Id: Ibb950660793db99e788f4be3dbda97ac23a1c5a3 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/63511 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'testing')
-rw-r--r--testing/resources/javascript/field.fragment36
-rw-r--r--testing/resources/javascript/field_methods.in4
-rw-r--r--testing/resources/javascript/field_methods_expected.txt5
-rw-r--r--testing/resources/javascript/field_properties.in10
-rw-r--r--testing/resources/javascript/field_properties_expected.txt2
5 files changed, 43 insertions, 14 deletions
diff --git a/testing/resources/javascript/field.fragment b/testing/resources/javascript/field.fragment
index d3663617b..f30136411 100644
--- a/testing/resources/javascript/field.fragment
+++ b/testing/resources/javascript/field.fragment
@@ -45,69 +45,70 @@ endobj
9 0 R
10 0 R
11 0 R
+ 12 0 R
]
>>
endobj
{{object 6 0}} <<
+ /Type /Annot
+ /Subtype /Widget
/FT /Tx
/Parent 5 0 R
/T (MyText)
- /Type /Annot
- /Subtype /Widget
/Rect [200 201 220 221]
/V (bleen)
/DV (grue)
>>
endobj
{{object 7 0}} <<
+ /Type /Annot
+ /Subtype /Widget
/FT /Btn
/Ff 65536
/Parent 5 0 R
/T (MyPushButton)
- /Type /Annot
- /Subtype /Widget
/Rect [220 221 240 241]
>>
endobj
{{object 8 0}} <<
+ /Type /Annot
+ /Subtype /Widget
/FT /Btn
/Ff 32768
/Parent 5 0 R
/T (MyRadio)
- /Type /Annot
- /Subtype /Widget
/Rect [240 241 260 261]
>>
endobj
{{object 9 0}} <<
+ /Type /Annot
+ /Subtype /Widget
/FT /Btn
/Ff 0
/Parent 5 0 R
/T (MyCheckBox)
- /Type /Annot
- /Subtype /Widget
/Rect [260 261 280 281]
>>
endobj
{{object 10 0}} <<
+ /Type /Annot
+ /Subtype /Widget
/FT /Ch
/Ff 2097152
/Parent 5 0 R
/T (MyMultiSelect)
- /Type /Annot
- /Subtype /Widget
/Rect [ 280 281 300 301 ]
/Opt [ (foo) (bar) (qux) ]
/V (qux)
>>
endobj
{{object 11 0}} <<
+ /Type /Annot
+ /Subtype /Widget
/FT /Ch
/Ff 0
/Parent 5 0 R
/T (MySingleSelect)
- /Type /Annot
- /Subtype /Widget
/Rect [ 300 301 320 321 ]
/Opt [
[ (foo) (Foo) ]
@@ -116,6 +117,17 @@ endobj
]
>>
endobj
+{{object 12 0}} <<
+ /Type /Annot
+ /Subtype /Widget
+ /FT /Tx
+ /Ff 1048576
+ /Parent 5 0 R
+ /T (MyFile)
+ /Rect [200 201 220 221]
+ /V ("/path/to/file.pdf")
+>>
+endobj
% OpenAction action
{{object 15 0}} <<
/Type /Action
diff --git a/testing/resources/javascript/field_methods.in b/testing/resources/javascript/field_methods.in
index aebbf716d..3197af9eb 100644
--- a/testing/resources/javascript/field_methods.in
+++ b/testing/resources/javascript/field_methods.in
@@ -40,6 +40,8 @@ expect("this.getField('MyField.MyPushButton').buttonGetCaption()", "");
expect("this.getField('MyField.MyPushButton').buttonGetIcon()", "[object Object]");
expect("this.getField('MyField.MyPushButton').buttonImportIcon()", undefined);
+expect("this.getField('MyField.MyFile').browseForFileToSubmit()", undefined);
+
expectError("this.getField('MyField').checkThisBox()");
expectError("this.getField('MyField').checkThisBox({})");
@@ -56,7 +58,7 @@ expect("this.getField('MyField').isDefaultChecked(0)", false);
expect("this.getField('MyField').setFocus()", undefined);
-// TODO(tsepez): these need a different kind of object to pass
+app.alert("These mismatched cases always throw");
expectError("this.getField('MyField.MyText').browseForFileToSubmit()");
expectError("this.getField('MyField').checkThisBox(0, true)");
expectError("this.getField('MyField').getItemAt(0)");
diff --git a/testing/resources/javascript/field_methods_expected.txt b/testing/resources/javascript/field_methods_expected.txt
index f72c99cf4..70cb22eb6 100644
--- a/testing/resources/javascript/field_methods_expected.txt
+++ b/testing/resources/javascript/field_methods_expected.txt
@@ -1,8 +1,9 @@
Alert: field is MyField
Alert: button is MyField.MyPushButton
Alert: nonesuch is undefined
-Alert: found 6 sub-fields:
+Alert: found 7 sub-fields:
Alert: MyField.MyCheckBox
+Alert: MyField.MyFile
Alert: MyField.MyMultiSelect
Alert: MyField.MyPushButton
Alert: MyField.MyRadio
@@ -11,6 +12,7 @@ Alert: MyField.MyText
Alert: PASS: this.getField('MyField.MyPushButton').buttonGetCaption() =
Alert: PASS: this.getField('MyField.MyPushButton').buttonGetIcon() = [object Object]
Alert: PASS: this.getField('MyField.MyPushButton').buttonImportIcon() = undefined
+Alert: PASS: this.getField('MyField.MyFile').browseForFileToSubmit() = undefined
Alert: PASS: this.getField('MyField').checkThisBox() threw Field.checkThisBox: Incorrect number of parameters passed to function.
Alert: PASS: this.getField('MyField').checkThisBox({}) threw Field.checkThisBox: Object is of the wrong type.
Alert: PASS: this.getField('MyField').defaultIsChecked() threw Field.defaultIsChecked: Incorrect number of parameters passed to function.
@@ -22,6 +24,7 @@ Alert: PASS: this.getField('MyField').isDefaultChecked() threw Field.isDefaultCh
Alert: PASS: this.getField('MyField').isDefaultChecked(20) threw Field.isDefaultChecked: Incorrect parameter value.
Alert: PASS: this.getField('MyField').isDefaultChecked(0) = false
Alert: PASS: this.getField('MyField').setFocus() = undefined
+Alert: These mismatched cases always throw
Alert: PASS: this.getField('MyField.MyText').browseForFileToSubmit() threw Field.browseForFileToSubmit: Object is of the wrong type.
Alert: PASS: this.getField('MyField').checkThisBox(0, true) threw Field.checkThisBox: Object is of the wrong type.
Alert: PASS: this.getField('MyField').getItemAt(0) threw Field.getItemAt: Object is of the wrong type.
diff --git a/testing/resources/javascript/field_properties.in b/testing/resources/javascript/field_properties.in
index 4b3ee4e5d..212638474 100644
--- a/testing/resources/javascript/field_properties.in
+++ b/testing/resources/javascript/field_properties.in
@@ -14,6 +14,7 @@ function testProperties() {
var radio = this.getField("MyField.MyRadio");
var list = this.getField("MyField.MyMultiSelect");
var check = this.getField("MyField.MyCheckBox");
+ var file = this.getField("MyField.MyFile");
app.alert('Testing properties under delay');
testRWProperty(field, "delay", false, true);
// TODO(tsepez): try this case, too.
@@ -25,6 +26,7 @@ function testProperties() {
testRadioButtonPropertiesCase(radio);
testCheckBoxPropertiesCase(check);
testListBoxPropertiesCase(list);
+ testFileSelectPropertiesCase(file);
} catch (e) {
app.alert("Unexpected error: " + e);
}
@@ -135,6 +137,14 @@ function testListBoxPropertiesCase(field) {
}
}
+function testFileSelectPropertiesCase(field) {
+ try {
+ testRIProperty(field, "fileSelect", true);
+ } catch (e) {
+ app.alert("Unexpected error: " + e);
+ }
+}
+
testProperties();
endstream
endobj
diff --git a/testing/resources/javascript/field_properties_expected.txt b/testing/resources/javascript/field_properties_expected.txt
index 676953e28..3b2e6f673 100644
--- a/testing/resources/javascript/field_properties_expected.txt
+++ b/testing/resources/javascript/field_properties_expected.txt
@@ -118,3 +118,5 @@ Alert: PASS: valueAsString = Off
Alert: PASS: valueAsString threw Field.valueAsString: Operation not supported.
Alert: PASS: currentValueIndices = 2
Alert: PASS: currentValueIndices = 1
+Alert: PASS: fileSelect = true
+Alert: PASS: fileSelect = true