summaryrefslogtreecommitdiff
path: root/testing/resources/javascript
AgeCommit message (Collapse)Author
2018-10-24Be more particular about FX objects constructed from JSTom Sepez
This is back-filling some more error cases from the work from a few weeks ago. Replaces a lambda with a static CallHandler() method since the verbosity was increasing. It gets invoked if you try to make a new FXJS object from the javascript side, rather than the C++ side. Making such an object is a little tricky, since we don't give these functions names in V8, but they can be obtained via constructor property from an instance of the object. Change-Id: Ibca686e75338ac54d08a114f36f930cd424a1eb5 Reviewed-on: https://pdfium-review.googlesource.com/c/44534 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-23Test color.convert() and equal() from JS (and fix comparison logic).Tom Sepez
Currently, color.equal(a, b) may not give the same result as color.equal(b, a) since arg1 is converted to be the type of arg2, and some of these conversions lose information. Instead promote to the type with the most components in the hope of preserving the most information. Better error message when there are the right number of parameters but the types are wrong. Change-Id: I1d93fa29db4fb65e0f7c07c3ba7d9ca87ebf7bc9 Reviewed-on: https://pdfium-review.googlesource.com/c/44413 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-23Split field.in into field_properties.in and field_methods.inTom Sepez
Matches the conventions of the other JavaScript tests. Change-Id: I9dc41e3964220db03f57b9ab30289e0c19b042da Reviewed-on: https://pdfium-review.googlesource.com/c/44531 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-22Modernize app.* JS method tests.chromium/3590Tom Sepez
Also add several missing cases. Change-Id: I38aa1fdacf839975249957267ffb121ad609aec5 Reviewed-on: https://pdfium-review.googlesource.com/c/44430 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-22Consolidate app_*.in tests into app_methods.inTom Sepez
One file per method is excessive. Change-Id: I02e3e9dffd2fc2d98f77f15a4669bd15c0119dd3 Reviewed-on: https://pdfium-review.googlesource.com/c/44412 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-22Add missing property to event_properties.inTom Sepez
Change-Id: I63c2f2c416d3270061fcffd0c9d0a82c10de88d2 Reviewed-on: https://pdfium-review.googlesource.com/c/44411 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-22Call last uncovered document methods.Tom Sepez
Test-only CL. Change-Id: Ica1613c42075adb5fedfef6d66d99095cef08655 Reviewed-on: https://pdfium-review.googlesource.com/c/44410 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-22Fix timezone inconsistency in document methods test.Tom Sepez
We do this by adding an override that forces GM time on everyone when run from the test harness. Generalize presubmit warnings so that the new function passes. De-duplicate lambda capture in place of static function. Change-Id: I15b34bea558baf1763476b36f0bca76614984107 Reviewed-on: https://pdfium-review.googlesource.com/c/44390 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-19Roll v8/ c623fabe5..604c50c84 (9 commits)Lei Zhang
https://chromium.googlesource.com/v8/v8.git/+log/c623fabe5643..604c50c84e67 Version 7.1.132 Update array_buffer JS test to adjust for https://chromium.googlesource.com/v8/v8/+/5cfe1a6b on Windows for 32-bit and ASAN builds. Change-Id: I7cfea684ab56d4a809989a7f029d7fc013eac372 Reviewed-on: https://pdfium-review.googlesource.com/c/44370 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-18Fully populate JS platform callbacks in pdfium_testTom Sepez
Adjust expected results accordingly. Order functions to match platform member order. Change-Id: I3d5f8e3ef8f532af0891b7fbbc1a8305d1922a75 Reviewed-on: https://pdfium-review.googlesource.com/c/44311 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-18Try assigning more kinds of values to doc propsTom Sepez
Change-Id: I99b28f5f047f9043bd95f76f17970d1979276d63 Reviewed-on: https://pdfium-review.googlesource.com/c/44310 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-18Expand CJS_Document::mail{Doc,Form}() parametersTom Sepez
Use ExpandKeywordParams() rather than ad-hoc processing. Add test case for {} argument. Change-Id: I1f60a87b3995d62f4bead79245a1f58fd31b102e Reviewed-on: https://pdfium-review.googlesource.com/c/44290 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-18Remove PrintParams object.Tom Sepez
The only way to theoretically get one is via doc.getPrintParams(), and it always returns in error. Even if one were returend to JS, there aren't any methods/callbacks to change its properties. Even if there were methods to change its properties, the information it stores doesn't align with what is in the JS spec for this object. Even if it were aligned with the JS spec, the way we check for its presence as the ninth parameter in CJS_Document::print() doesn't match the way its use is documented in the spec as the sole first parameter. Instead implement the older, simpler behaviour as spec'd prior to 6.0, and toss this enhancement altogether. Move function to check the result of ExpandKeywordParams() to js_define.h so other files can use it. Update comment in that file to remove reference to deprecated enum. Expand test for API and introduce callback to log parameters. Change-Id: I047e2be0d2afbad91d6b58c6c74bbea083fed330 Reviewed-on: https://pdfium-review.googlesource.com/c/44271 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-18Add JavaScript tests for event API.Tom Sepez
Change-Id: Ic62fd1c6e55e6db5864e124fe3ba50e05b0020e1 Reviewed-on: https://pdfium-review.googlesource.com/c/44210 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-18Add JavaScript public methods tests.Tom Sepez
Still very preliminary. Alphabetize table in .cpp file to match test. Bug: pdfium:1028 Change-Id: Ia3b646507e1a2ec384bf59893cd1d74c2a4b2456 Reviewed-on: https://pdfium-review.googlesource.com/c/43980 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-15Clone dict before iteration in CJS_Document::get_infoTom Sepez
Bug: 895152 Change-Id: I678350841892f88a5d580b58a33a639a1b6ec305 Reviewed-on: https://pdfium-review.googlesource.com/c/44050 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-12Beef up coverage in CJS_Field.Tom Sepez
Still a long way to go, but hit the easy ones first. Alphabetize property names in cjs_field.cpp file. Change-Id: I1ede770a1e159d464287775cf9e19cbaf9f2a62f Reviewed-on: https://pdfium-review.googlesource.com/c/43978 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-12Beef up CJS_Document method coverage.Tom Sepez
Also alphabetize mailDoc method position in .cpp file. Change-Id: Ifb53e9a6f5f165bb41b865d51dae15e3bc84c4c7 Reviewed-on: https://pdfium-review.googlesource.com/c/43972 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-12Add test for CJS_Annot JS callbacks.Tom Sepez
Change-Id: I8ef9bb333e786e833faca75566730a5b441d63c2 Reviewed-on: https://pdfium-review.googlesource.com/c/43830 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-12Add test for CJS_Color properties.Tom Sepez
Return a more precise error in one case. Change-Id: I21e4ef6b30be5f44d35922640643bffb9cb4b5e4 Reviewed-on: https://pdfium-review.googlesource.com/c/43950 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-12Add tests for CJS_Console methods.Tom Sepez
Change-Id: Ie534b26d8241e889ad9cdca942e142cddca44bf4 Reviewed-on: https://pdfium-review.googlesource.com/c/43933 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-02Remove ability to delete annot in CJS_Document::removeField()Tom Sepez
This path has only been present under XFA, and has resulted in several bugs, including the referenced one. There is a breakage in some XFA functionality, but I'm not confident we can do this without re-engineering all of fpdfsdk widget ownership. Bug: 891210 Change-Id: I5aa158fa5359b1c8338046eefb25fb25df9ace48 Reviewed-on: https://pdfium-review.googlesource.com/c/43311 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-27Roll v8/ 9cf8abb7c..ff6b34b46 (689 commits)Lei Zhang
https://chromium.googlesource.com/v8/v8.git/+log/9cf8abb7ce7e..ff6b34b468c1 This updates V8 to 6.8.44. There has been changes to how JS handles timezones. [1] Update the test expectations to match the new behavior, even though it deviates from Acrobat, which still has the old behavior. BUG=pdfium:1075 [1] https://github.com/tc39/ecma262/pull/778 Change-Id: I63f0df9cd423ceee5b8d1008ba12a47ca84bbd6d Reviewed-on: https://pdfium-review.googlesource.com/41450 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-20Re-work some more c_str() usage.Tom Sepez
Many of these are converting ByteString => c_str => ByteStringView, since the ByteStringView ctor is implicit. This is unfortunate, since that involves a strlen() which the ByteString already knows if we use AsStringView() instead. This changed one test result where we can now return the string "\0" instead of "" -- since strlen no longer eats the NUL. This seems consistent, say, with String.fromCharCode(). Change-Id: I17f68d1a1f4b352960208f9148e68ab4c4d78bd2 Reviewed-on: https://pdfium-review.googlesource.com/35590 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-08Ensure CJS_Return() with error always includes a message.Tom Sepez
Change the signature of the constructors to make it impossible to do this otherwise. Change-Id: I14e88d98a1128f2d599459ce9337cd6d079469fe Reviewed-on: https://pdfium-review.googlesource.com/34531 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-07Convert resolve_nodes.pdf into 3 test casesRyan Harrison
There are 3 elements in the PDF that can be interacted with that cause testable output. This CL creates test cases for each of these elements. 2 of them work correctly, and a new bug, pdfium:1106, has been filed for the third. BUG=pdfium:1020 Change-Id: I524911d03927a0eeeee1d1479e1a855f90269e8e Reviewed-on: https://pdfium-review.googlesource.com/34370 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-05-15Use {{streamlen}} macro in testing/resources/javascript/*.inTom Sepez
Change-Id: I1d2a91619a1c944b6fdca00b2f9c5bb338326986 Reviewed-on: https://pdfium-review.googlesource.com/32572 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-05-15Use {{trailer}} macro in testing/resources/javascript/*.inTom Sepez
Also format the trailer in a cleaner multi-line format. Change-Id: If145834b56f8678f97247b346cc0cfd4d367c501 Reviewed-on: https://pdfium-review.googlesource.com/32571 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-05-15Test app.beep() in standalone PDFium.Tom Sepez
Precursor to testing app.beep() in chrome's browser tests. Change-Id: I09ef497bd6a8094e389783b144fa04c9230cbe3d Reviewed-on: https://pdfium-review.googlesource.com/32550 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-01-29Roll V8 to ee5d9a0c.Lei Zhang
Update test expectations after V8 enabled --harmony-function-tostring by default. https://chromium.googlesource.com/v8/v8/+log/0c287882..ee5d9a0c TBR=dsinclair@chromium.org Change-Id: I4eabc6b2ed854153dcbfb75f527e209f57e86a2a Reviewed-on: https://pdfium-review.googlesource.com/24110 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-08-31Implement FORM_OnFocus() API.Lei Zhang
Given a point, if there is an annotation at the point, give if focus if it is not focus already. If there is no annotation at the point, then remove the focus from the focused annotation. BUG=chromium:754594 Change-Id: Iec3070472bbbfbad9d86e517f25da560f82efd4e Reviewed-on: https://pdfium-review.googlesource.com/12530 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-07-24Observe Annot destruction in CPDFSDK_PageView::DeleteAnnotTom Sepez
Run test XFA-Only, since that's where the issue occurs, and the textual output is different for non-xfa. Fix a few lifetime issue in pdfium_test.cc unearthed by this test (doc must outlive pages now held in formfill info). Bug: 735912 Change-Id: Icc9e6a967c32ece67d897117896c973bb16a1515 Reviewed-on: https://pdfium-review.googlesource.com/8510 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-07-17More tightly validate format strings in util.cpp.chromium/3160Tom Sepez
Re-work the previous fix to be even more particular about the input. Bug: chromium:740166 Change-Id: I6bea3b6a6dd320a83f830b07afd52951be7d1b63 Reviewed-on: https://pdfium-review.googlesource.com/7691 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-07-13Fix invalid write for util.printfDan Sinclair
This CL fixes and invalid WRITE triggered by calling util.printf. We need to verify that the integer format will be less then 260 characters. Bug: chromium:740166 Change-Id: I1c9047101780582da5f39088568727e2c8b4c2d2 Reviewed-on: https://pdfium-review.googlesource.com/7630 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-06-16Avoid a crash inside wcsftime() on Windows.chromium/3135chromium/3134chromium/3133Lei Zhang
BUG=chromium:733245 Change-Id: Ic9347e2cc245831c0b71fac1d531c33c5646ab3f Reviewed-on: https://pdfium-review.googlesource.com/6671 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-03-15Add array_buffer JS test.Tom Sepez
JS Array Buffers are the first candidate to be allocated from PartitionAlloc when it becomes available, so add test first. Presently, we will return as large an array buffer as the system can handle; this is generally a bad idea so limit them to 256MB and test that we handle failure. Change-Id: I205745a7938d69eb32ac883b90824f2f9e584ec7 Reviewed-on: https://pdfium-review.googlesource.com/3065 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-02-27Fix uninitialized memory read in CJS_Object::GetEmbedObject()Tom Sepez
The expected way to create native PDFium objects for JS is via the NewFxDynamicObject() call in C++, but that doesn't mean that the corresponding constructors won't be called from JS. In that case, the internal fields will be uninitialized, and subsequent method calls may try to use them. Add a constructor callback for all PDFium objects that nulls out these fields (shame that v8 doesn't do this by default, but probably saves some cycles). Then ensure that we check for this possibility in all the places it might turn up. Conversely, if we've just gotten a successful return from NewFxDynamicObject(), we know the CJS_Object/EmbedObj are good, so avoid checking there. BUG=695826 Change-Id: Iadad644c4af937def967ddc83daac1dad7544d69 Reviewed-on: https://pdfium-review.googlesource.com/2839 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-01-12Custom toString() methods may delete annots.tsepez
In this case, we observe the destruction of the object, but have unfortunately saved a pointer to it in a local variable. BUG=679643 Review-Url: https://codereview.chromium.org/2628233002
2017-01-11Annotation deleted while retrieving it in JStsepez
Widgets as returned from GetWidgets() can pop out of existence unexpectedly, so always return observed pointers. This extends the same pattern used elsewhere in the file to all occurrences. BUG=679642 Review-Url: https://codereview.chromium.org/2624933002
2016-10-18Add a test case for bug 494057.thestig
The expectation is set incorrectly to allow the test to pass. BUG=chromium:494057 Review-Url: https://codereview.chromium.org/2430583002
2016-08-26Add support to Document::getAnnots methodtonikitoo
Although notably, the parameters handling support is not complete, CL intends to be the first step towards a more complete implementation of this API. TEST=testing/resources/javascript/bug_492_1.in BUG=pdfium:492 Review-Url: https://codereview.chromium.org/2281273002
2016-08-19Stub out Document::syncAnnotScan method.chromium/2834tonikitoo
The PDF specification [1] says: " syncAnnotScan guarantees that all annotations will be scanned by the time this method returns. (..) Normally a background task runs that examine every page and looks for annotations during idle times. " The statement details specifically how Acrobat implements this method. Although, neither the method itself nor the background scanner task are implemented in PDFium (as of today, Ago/2016), not having ::syncAnnotScan at least stubbed out can be considered harmfull since its absence makes JS acrobat scripts silently fail when it has a call to it. Given that, and following a stub-out pattern present in other methods including ::addAnnot and ::addField, CL provides a stubbed out implementation of Document::syncAnnotScan. [1] http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf BUG=pdfium:492 Review-Url: https://codereview.chromium.org/2265553002
2016-08-18Add initial Document::getAnnot supportchromium/2833tonikitoo
CL implements the first step in order to support Annotations manipulation in PDFium: Document::getAnnot. The method takes two arguments, an integer (page number) and a string (annotation name). When called, it iterates over the annotations on the given page number, searching for the one whose name matches the string in the second parameter. If found, then an Annot instance (see Annot.cpp/g added by this CL), is bound to a Javascript object and returned. With the use cases described in bug [1] as an initial test case, CL adds support to the following Annotation object properties: - hidden - name - type Idea is to keep evolving the implementation with more methods and properties in follow up CLs. [1] https://bugs.chromium.org/p/pdfium/issues/detail?id=492 BUG=pdfium:492 Review-Url: https://codereview.chromium.org/2260663002
2016-08-10Make Document's 'info' property readonlytonikitoo
As per the PDF specification in [1], page 103, the 'info' property of the Document object is readonly. [1] http://partners.adobe.com/public/developer/en/acrobat/sdk/5186AcroJS.pdf Review-Url: https://codereview.chromium.org/2235883003
2016-08-08Add support to Document::gotoNamedDest method.tonikitoo
Patch implements the Document's API gotoNamedDest, which is part of the PDF specification [1], page 129, with the following (short) description: "Use this method to go to a named destination within the PDF document". [1] http://partners.adobe.com/public/developer/en/acrobat/sdk/5186AcroJS.pdf "Named destination" is a common concept in the PDF world. It can be used together with PDF's Links, Annotations, Bookmarks and OpenActions, as well as an action per se, in case "this.gotoNamedDest" is called directly. Note that the implementation makes use of the existing hook CPDFDoc_Environment::FFI_DoGoToAction, which ends up calling out the embedder to actually handle it. In case of Chromium, for instance, it calls PDFiumEngine::Form_DoGoToAction which only handles for now the "page" property of the "destination". Other properties, including zoom level, and scroll position are ignored for the moment. BUG=pdfium:492 Review-Url: https://codereview.chromium.org/2221823003
2016-08-08Add support to Document::URL property getter.tonikitoo
As per the PDF specification at [1] " This property specifies the document's URL. ". IE/Acrobat supports it, and getting it implemented would be one step forward in order to support Acrobat JS script as the one in [2]. [1] http://partners.adobe.com/public/developer/en/acrobat/sdk/5186AcroJS.pdf [2] https://bugs.chromium.org/p/pdfium/issues/detail?id=492 BUG=492 Review-Url: https://codereview.chromium.org/2219183002
2016-03-29Add test for util.byteToChar() and fix error msg.tsepez
Review URL: https://codereview.chromium.org/1838543002
2016-03-28Added test for util.printx() and make it match spec.tsepez
R=dsinclair@chromium.org Review URL: https://codereview.chromium.org/1837543002
2016-03-25util.printd() replaces specified date with current date.tsepez
Added test case. Several bugs going on here: JS_LocalTime() ignoring argument and returning current time and not factoring in the time zone adjustment. Use of FXSYS_floor() silently casts result to float, losing precision required to extract minutes and seconds. Pre-existing wcsftime escapes not stripped. BUG=pdfium:413 Review URL: https://codereview.chromium.org/1833053002
2016-03-03Add JS tests for global const equality.Tom Sepez
Add these tests before fixing bug 419. R=dsinclair@chromium.org Review URL: https://codereview.chromium.org/1761923002 .