Commit Graph

150 Commits

Author SHA1 Message Date
Jonas Jenwald
c3c1fc511d Move the workerSrc option from the global PDFJS object and into GlobalWorkerOptions instead 2018-02-16 13:22:35 +01:00
Brendan Dahl
4f5fb78237
Merge pull request #9401 from brendandahl/svg-fail
Make the test framework more resilient to errors.
2018-02-14 17:05:40 -08:00
Brendan Dahl
53d19b619d Make the test framework more resilient to errors. 2018-02-14 17:02:19 -08:00
Jonas Jenwald
e95c11a7f0 Remove the undocumented PDFJS.enableStats option
In order to simplify things, the undocumented `enableStats` option was removed and `pdfBug` is now instead used to enabled general debugging *and* page request/rendering stats.
Considering that in the default viewer the `stats` was only used when debugging was also enabled, this simplification (code wise) definitely seem worthwhile to me.
2018-02-13 16:56:57 +01:00
Jonas Jenwald
c45c394364 Move the imageResourcesPath option to a BaseViewer/PDFPageView/AnnotationLayerBuilder option
This removes the `PDFJS.imageResourcesPath` dependency from the viewer components and the test-suite, but please note that as a *temporary* solution the default viewer still uses it.
2018-02-13 14:28:38 +01:00
Jonas Jenwald
1cf116ab88 Enable the mozilla/use-includes-instead-of-indexOf ESLint rule globally
This rule is available from https://www.npmjs.com/package/eslint-plugin-mozilla, and is enforced in mozilla-central. Note that we have the necessary `Array`/`String` polyfills and that most cases have already been fixed, see PRs 9032 and 9434.
2018-02-10 23:24:50 +01:00
Jonas Jenwald
2eb29409bc Enable the mozilla/avoid-removeChild ESLint rule globally
This rule is available from https://www.npmjs.com/package/eslint-plugin-mozilla, and is enforced in mozilla-central. Note that we have a polyfill for `ChildNode.remove()` and that most cases have already been fixed, see PRs 8056 and 8138.
2018-02-10 23:24:50 +01:00
Jonas Jenwald
7c5ba9aad5 [api-major] Only create a StatTimer for pages when enableStats == true (issue 5215)
Unless the debugging tools (i.e. `PDFBug`) are enabled, or the `browsertest` is running, the `PDFPageProxy.stats` aren't actually used for anything.
Rather than initializing unnecessary `StatTimer` instances, we can simply re-use *one* dummy class (with static methods) for every page. Note that by using a dummy `StatTimer` in this way, rather than letting `PDFPageProxy.stats` be undefined, we don't need to guard *every* single stats collection callsite.

Since it wouldn't make much sense to attempt to use `PDFPageProxy.stats` when stat collection is disabled, it was instead changed to a "private" property (i.e. `PDFPageProxy._stats`) and a getter was added for accessing `PDFPageProxy.stats`. This getter will now return `null` when stat collection is disabled, making that case easy to handle.

For benchmarking purposes, the test-suite used to re-create the `StatTimer` after loading/rendering each page. However, modifying properties on various API code from the outside in this way seems very error-prone, and is an anti-pattern that we really should avoid at all cost. Hence the `PDFPageProxy.cleanup` method was modified to accept an optional parameter, which will take care of resetting `this.stats` when necessary, and `test/driver.js` was updated accordingly.

Finally, a tiny bit more validation was added on the viewer side, to ensure that all the code we're attempting to access is defined when handling `PDFPageProxy` stats.
2017-12-06 23:12:25 +01:00
Tim van der Meij
7d7edd9cc6
[api-major] Remove the PDFJS_NEXT option
Nothing uses this option anymore, so setting it is a no-op now. We can
safely remove it.

Use `SKIP_BABEL` (instead of `PDFJS_NEXT`) now if you want to skip Babel
translation for a build.
2017-10-16 23:16:51 +02:00
Jonas Jenwald
1ebbdc253a Use the SimpleLinkService when running "annotations" reference tests
Rather than (basically) duplicating the `SimpleLinkService` in `test/driver.js`, with potential test failuires if you forget to update the test mock, it seems much nicer to just re-use the viewer component.

Note that `SimpleLinkService` is already bundled into the `build/components/pdf_viewer.js` file. Hence we only need to expose it similar to the other viewer components in that file, and make sure that the `gulp components` command runs as part of the test-setup.
2017-09-12 15:24:46 +02:00
Tim van der Meij
23cbe294d5
Combine the common styles and overrides for the annotation layer
reference tests

This patch allows us to use the common styles as used by the viewer as a
baseline for the annotation layer reference tests. They are extended
with a small set of overrides to ensure that all elements are visible
during the test.

The overrides file now only contains the absolutely necessary rules to
make all elements visible and is therefore no longer an almost verbatim
copy of the common styles.
2017-09-10 18:18:56 +02:00
Jonas Jenwald
11e95712d4 Add support for the nativeImageDecoderSupport parameter, to force JPEG image decoding using src/core/jpg.js, when running the reference tests 2017-07-11 16:38:49 +02:00
Jonas Jenwald
efbd68efef Fix inconsistent spacing and trailing commas in objects in test/ files, so we can enable the comma-dangle and object-curly-spacing ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing

Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.

Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.

```diff
diff --git a/test/chromium/test-telemetry.js b/test/chromium/test-telemetry.js
index cc412a31..2e5bdfa1 100755
--- a/test/chromium/test-telemetry.js
+++ b/test/chromium/test-telemetry.js
@@ -324,7 +324,7 @@ var tests = [
     var window = createExtensionGlobal();
     telemetryScript.runInNewContext(window);
     window.chrome.runtime.getManifest = function() {
-     return { version: '1.0.1', };
+      return { version: '1.0.1', };
     };
     window.Date.test_now_value += 12 * 36E5;
     telemetryScript.runInNewContext(window);
diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js
index 1f00747a..f22988e7 100644
--- a/test/unit/api_spec.js
+++ b/test/unit/api_spec.js
@@ -503,8 +503,9 @@ describe('api', function() {
     it('gets destinations, from /Dests dictionary', function(done) {
       var promise = doc.getDestinations();
       promise.then(function(data) {
-        expect(data).toEqual({ chapter1: [{ gen: 0, num: 17, }, { name: 'XYZ', },
-                                          0, 841.89, null], });
+        expect(data).toEqual({
+          chapter1: [{ gen: 0, num: 17, }, { name: 'XYZ', }, 0, 841.89, null],
+        });
         done();
       }).catch(function (reason) {
         done.fail(reason);
diff --git a/test/unit/function_spec.js b/test/unit/function_spec.js
index 66441212..62127eb9 100644
--- a/test/unit/function_spec.js
+++ b/test/unit/function_spec.js
@@ -492,9 +492,11 @@ describe('function', function() {
     it('check compiled mul', function() {
       check([0.25, 0.5, 'mul'], [], [0, 1], [{ input: [], output: [0.125], }]);
       check([0, 'mul'], [0, 1], [0, 1], [{ input: [0.25], output: [0], }]);
-      check([0.5, 'mul'], [0, 1], [0, 1], [{ input: [0.25], output: [0.125], }]);
+      check([0.5, 'mul'], [0, 1], [0, 1],
+            [{ input: [0.25], output: [0.125], }]);
       check([1, 'mul'], [0, 1], [0, 1], [{ input: [0.25], output: [0.25], }]);
-      check([0, 'exch', 'mul'], [0, 1], [0, 1], [{ input: [0.25], output: [0], }]);
+      check([0, 'exch', 'mul'], [0, 1], [0, 1],
+            [{ input: [0.25], output: [0], }]);
       check([0.5, 'exch', 'mul'], [0, 1], [0, 1],
             [{ input: [0.25], output: [0.125], }]);
       check([1, 'exch', 'mul'], [0, 1], [0, 1],
```
2017-06-02 13:04:04 +02:00
Yury Delendik
b66b705ed7 Using pre-built code for testing. 2017-05-30 22:06:21 +02:00
Jonas Jenwald
b5775af716 Wait for previous pdfDocument(s) to be destroyed before running the next reference test
Refactors `Driver._cleanup` to return a `Promise` which is resolved once all opened documents have been destroyed.
This is then used in `Driver._nextTask` to ensure that we wait for everything to be cleaned up, such that the tests run sequentially.
2017-05-11 12:56:45 +02:00
Jonas Jenwald
7560f12a17 Enable the object-shorthand ESLint rule
Please see http://eslint.org/docs/rules/object-shorthand.

Unfortunately, based on commit 9276d1dcd9, it seems that we still need to maintain compatibility with old Node.js versions, hence certain files/directories that are executed in Node.js are currently exempt from this rule.

Furthermore, since the files specific to the Chromium extension are not run through Babel, the `/extensions/chromium/` directory is also exempt from this rule.
2017-04-30 11:13:34 +02:00
Jonas Jenwald
9d62ff80ca Actually skip pages included in the skipPages array when running tests, rather than creating empty 1x1 canvases (issue 8241)
Considering how extremely simple this patch turned out to be, I'm almost worried that I completely misunderstood why the current code looks like it does...
2017-04-06 13:17:52 +02:00
Jonas Jenwald
6d672c4ba6 [api-minor] Add a pdfjsNext parameter, and PDFJS_NEXT build flag, to allow backwards incompatible API changes 2017-03-13 18:43:43 +01:00
Jonas Jenwald
e416032b38 Prevent browser console errors during testing
The `Driver._cleanup` method is removing all stylesheets between test runs, which causes "TypeError: styleElement.parentNode is null" console errors in `FontLoader.clear`.

As can also be seen during various tests, some of the changes I made in PR 7972 unfortunately causes console errors.
It seems that I didn't test this properly, since it *should* have been obvious to me that while tests are triggered using Node.js, the files in question are run within the *browser*.
My apologies for not testing this thoroughly, and for causing unnecessary churn in the code!
2017-02-05 13:23:42 +01:00
Tim van der Meij
6f0cf8c4cb Merge pull request #7972 from Snuffleupagus/eslint_no-unused-vars
Enable the `no-unused-vars` ESLint rule
2017-02-01 23:50:23 +01:00
Jonas Jenwald
c102232275 Append the contents of FileAttachment annotations to the attachments view of the sidebar, for easier access to the embedded files
Other PDF viewers, e.g. Adobe Reader, seem to append `FileAttachment`s to their attachments views.
One obvious difference in PDF.js is that we cannot append all the annotations on document load, since that would require parsing *every* page. Despite that, it still seems like a good idea to add `FileAttachment`s, since it's thus possible to access all the various types of attachments from a single place.

*Note:* With the previous patch we display a notification when a `FileAttachment` is added to the sidebar, which thus makes appending the contents of these annotations to the sidebar slightly more visible/useful.
2017-01-31 22:26:16 +01:00
Jonas Jenwald
52e0f51917 Enable the no-unused-vars ESLint rule
Please see http://eslint.org/docs/rules/no-unused-vars; note that this patch purposely uses the same rule options as in `mozilla-central`, such that it fixes part of issue 7957.

It wasn't, in my opinion, entirely straightforward to enable this rule compared to the already existing rules. In many cases a `var descriptiveName = ...` format was used (more or less) to document the code, and I choose to place the old variable name in a trailing comment to not lose that information.

I welcome feedback on these changes, since it wasn't always entirely easy to know what changes made the most sense in every situation.
2017-01-29 23:23:17 +01:00
Jonas Jenwald
3820946301 Fix (most) errors reported by the no-multi-spaces ESLint rule
http://eslint.org/docs/rules/no-multi-spaces
2016-12-12 20:35:51 +01:00
Jonas Jenwald
3a105e37f4 Ensure that test/driver.js actually takes the same Annotation code-path as the viewer when running forms tests (PR 7633 follow-up)
Unfortunately PR 7633 missed, and I didn't catch it during review, to update `test/driver.js` such that the `forms` tests takes the correct code-path.
This resultet in the `forms` reference test images looking better than they should, and more problematicly differing from the rendering in the viewer.

With this patch, the tests now correctly skip over any `Appearance` streams.
The `forms` tests now highlights quite clearly (e.g. look at `annotation-tx2.pdf`/`annotation-tx3.pdf`) that we cannot just skip the `Appearance` streams when rendering forms. Hence we're going to have to find a way to fix that *before* enabling forms by default, since both display *and* print would look completely wrong otherwise.
Finally, this patch also uncovers one more existing bug that still needs to be fixed, since the current `rasterizeAnnotationLayer` in `test/driver.js` isn't able to handle the contents of e.g. `<input>` and `<textarea>`.
2016-09-21 12:21:20 +02:00
Tim van der Meij
e281ce7c73 Enable regression testing for interactive forms 2016-09-07 16:50:44 +02:00
Jeremy Press
1ceeb4d17b added text enhancement regression tests 2016-08-31 09:54:52 -07:00
Jeremy Press
6faa84abdb Continuing fairexpand #6663
1. Expanding divs to improve text selection. (Yury)
2. Adding enhanceTextSelection as an option.
3. Moving feature functionality from text_layer_builder.js to text_layer.js.
4. Added expandTextDivs method to only load expanded divs on first click, and only show on subsequent clicks
2016-08-31 09:54:52 -07:00
Jonas Jenwald
f297e4d17c [api-minor] Add a parameter to PDFPageProxy_getTextContent that controls whether PartialEvaluator_getTextContent will attempt to combine same line text items
From the discussion in issue 7445, it seems that there may be cases where an API consumer would want to get the text content as is, without combined text items.
2016-07-19 13:38:57 +02:00
Prakash Palanisamy
a25c29d98d Remove combineUrl and replace it with new URL. 2016-04-15 21:33:10 +05:30
Brendan Dahl
fb47490648 Log uncaught global errors. 2016-03-22 15:49:32 -07:00
Tim van der Meij
b7217a2274 Implement annotation layer regression testing 2015-12-20 13:45:56 +01:00
Yury Delendik
6b60c8f4db Adds UMD headers to core, display and shared files. 2015-12-15 13:24:39 -06:00
Jonas Jenwald
6dfe53b976 [api-minor] Add a parameter to PDFPageProxy_getTextContent that enables replacing of all whitespace with standard spaces in the textLayer (issue 6612)
This patch goes a bit further than issue 6612 requires, and replaces all kinds of whitespace with standard spaces.

When testing this locally, it actually seemed to slightly improve two existing test-cases (`tracemonkey-text` and `taro-text`).

Fixes 6612.
2015-11-25 17:28:40 +01:00
Yury Delendik
bd7f121c83 Better "text" testing. 2015-11-19 11:03:52 -06:00
Yury Delendik
194994a289 Merge pull request #6551 from yurydelendik/subaa
[api-minor] Enables subpixel anti-aliasing for most of the content.
2015-11-17 19:45:32 -06:00
Yury Delendik
1d8800370a Allow subpixel anti-aliasing for most of the content. 2015-11-16 10:50:02 -06:00
Manas
a2ba1b8189 Uses editorconfig to maintain consistent coding styles
Removes the following as they unnecessary
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
2015-11-14 07:32:18 +05:30
Rob Wu
b627a1a0d9 Add --testfilter (-t) flag to run a specific test 2015-07-18 17:31:56 +02:00
Tim van der Meij
e02ab9fb79 Implement an option to disable automatic scrolling
This adds a checkbox with which one can disable scrolling, for example to look back at output during testing. Note that the styles are inline because the test runner removes all <style> elements for each test.
2015-05-21 20:19:36 +02:00
Tim van der Meij
07ec736eb9 Improve driver code structure
- Improve variable names and move variables to the top of the method
- Use constants where possible
- Only print the delay text if there is an atual delay set
- Simplify continuation logic in _nextTask
- Do not pass anything to clearCanvas: we can get the context from this.canvas there.
- Remove innerHTML and replace it with textContent. Add a comment why insertAdjancentHTML is so important for performance and runtime.
- Merge _quit and _sendQuitRequest.
2015-05-21 20:19:32 +02:00
Tim van der Meij
ae8748edfb Refactor test driver to be more class-like
- Extract NullTextLayerBuilder and SimpleTextLayerBuilder from the driver code and create classes for them.
- Move options to the constructor and pass in HTML elements instead of getting them in the driver.
- Remove unused masterMode variable.
- Minor method name updates.

The rest is only moving/indenting existing code and adding 'this'.
2015-05-21 20:19:02 +02:00
Tim van der Meij
d59660cfa6 Clean up the test driver
- Remove a hack for Chrome on Windows because we do not run Chrome on the Windows bot anymore, so it added unneeded complexity.
- Merge nextTask and continueNextTask functions. nextTask did nothing more than calling cleanup. This change also allows us to remove the callback for that function.
- Remove unnecessary one-line functions.
2015-05-15 23:21:20 +02:00
Tim van der Meij
58769fd3b9 Refactor test slave
- Improved names of elements
- Easier scrolling code
2015-05-15 23:20:14 +02:00
Brendan Dahl
4824baf31c Merge pull request #5905 from timvandermeij/specialpowers
Remove SpecialPowers addon
2015-04-27 10:36:54 -07:00
Jonas Jenwald
36ac67583f Remove commented out code about |disableWorker| in the test suite
Since the tests have run with workers enabled for a long time, these comments are no longer relevant.
2015-04-04 13:32:44 +02:00
Tim van der Meij
75d8f70d06 Remove SpecialPowers addon 2015-04-03 20:17:20 +02:00
Mitar
2f72ac1255 textLayer is not used anymore in render context.
It should be removed to prevent confusion when reading the code.
2014-09-19 15:13:01 -07:00
Tim van der Meij
e525902241 Use strict equalities in test/driver.js 2014-07-31 23:08:54 +02:00
Tim van der Meij
34728ee49b Removing unused code 2014-07-18 22:34:50 +02:00
Brendan Dahl
339f8f0ac9 Call correct quit function and wait request sending. 2014-04-17 07:34:38 -05:00