Commit Graph

10547 Commits

Author SHA1 Message Date
Tim van der Meij
db9f71fe6b
Merge pull request #9433 from Snuffleupagus/addon-minimum-nightly
[Firefox addon] Change the minimum supported version to Firefox Nightly, and remove no longer needed fallback code
2018-02-04 16:24:39 +01:00
Tim van der Meij
7fbeeebbff
Merge pull request #9434 from Snuffleupagus/upstream-bug-1339461
Upstream the changes from: Bug 1339461 - Convert foo.indexOf(...) == -1 to foo.includes() and implement an eslint rule to enforce this
2018-02-04 16:12:03 +01:00
Jonas Jenwald
712090eff8 Upstream the changes from: Bug 1339461 - Convert foo.indexOf(...) == -1 to foo.includes() and implement an eslint rule to enforce this
Yet another case where PDF.js code was modified in `mozilla-central` without the changes happening in the GitHub repo first; *sigh*.
If we don't upstream at least the changes in `extensions/firefox/`, any future update of PDF.js in `mozilla-central` will be blocked.

Please see:
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1339461
 - https://hg.mozilla.org/mozilla-central/rev/d5a5ad1dbbf2
2018-02-04 14:59:27 +01:00
Jonas Jenwald
9ac9ef8ef1 Polyfill String.prototype.includes using core-js
See https://github.com/zloirock/core-js#ecmascript-6-string.
2018-02-04 14:31:59 +01:00
Jonas Jenwald
986c8b56ca Update the eslint-plugin-mozilla package to the latest version
With the updated compatibility for the addon, we can thus remove a few no longer needed exceptions from `extensions/firefox/.eslintrc`.
2018-02-04 14:07:18 +01:00
Jonas Jenwald
4db49b6613 Upstream the changes from: Bug 1431533 - Add ChromeUtils helpers for lazy module import
Please see:
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1431533
 - https://hg.mozilla.org/mozilla-central/rev/e6a7b5e11ba8
 - https://groups.google.com/forum/#!topic/mozilla.dev.platform/xQaTdsrbd-g
2018-02-04 14:07:18 +01:00
Jonas Jenwald
08b2e25ac1 [Firefox addon] Remove no longer needed fallback code for older versions of Firefox 2018-02-04 14:07:18 +01:00
Jonas Jenwald
d1ffd61093 [Firefox addon] Change the minimum supported version to (the current) Firefox Nightly release
At this point in time, trying to keep the development addon compatible with prior Firefox versions is already quite difficult and will become even harder very soon.

Please keep in mind that since Firefox 57, only WebExtensions are allowed/possible to install. The only exceptions are Firefox Nightly, with the `xpinstall.signatures.required` preference[1] set to `false`, and the (as of this writing) current ESR release.[2]

With the current compatibility situation, we thus need to effectively support both Nightly *and* ESR in the addon, while trying to keep up with current/upcoming changes in `mozilla-central`. With old addons no longer being officially supported, the amount of old code being removed/refactored is now increasing quite quickly.

*Please note:* The changes proposed here was to a large extent prompted by bugs such as:
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1431533 (already landed)
 - https://bugzilla.mozilla.org/show_bug.cgi?id=767640 (already landed)
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1432992 (still open)

Upstreaming all of those changes for the `MOZCENTRAL` version of PDF.js, while also keeping the Firefox addon running in older versions of the browser, would quickly become non-trivial.
Since we're using the ruleset from `eslint-plugin-mozilla` for the addon files, which is enforced in `mozilla-central`, we must ensure that the neccessary changes are upstreamed to the PDF.js repo such that the `mozilla-central` version of PDF.js can still be updated without failures.

Trying to feature detect, for the `FIREFOX` build target, some of the changes in the referenced bugs would probably become both quite messy and (not to mention) difficult. E.g. with the upcoming and automatically defined `Cc, Ci, Cu, Cr` variables, any sort of feature detection might be tricky since those need to be defined in the global scope of the files in question.

Finally, given the amount of effort that we'd now need to spend to even attempt to keep the Firefox addon compatible, I just don't think it's worth the effort any more. Especially since the number of people that have, thus far, been doing this work is *very* low and those resources would be better spend elsewhere.
Unfortunately, this probably means that the development addon will no longer be compatible with release versions of Seamonkey. However the README has already mentioned, for quite some time, that support isn't guaranteed.

*In closing:* For all of the reasons mentioned above, I thus propose that we reduce the maintenance burden of the Firefox addon by only supporting the current Firefox Nightly.

---

[1] While the preference exists, and can be toggled, its value is ignored in non-Nightly versions of Firefox.

[2] There's unbranded builds of e.g. the release/beta versions of Firefox, where old and non-WebExtensions addons can be installed. However those builds can probably be assumed to be officially unsupported, and thus not recommended for users.
2018-02-04 14:07:17 +01:00
Jonas Jenwald
d42541d26b
Merge pull request #9412 from timvandermeij/crypto
Implement the `AESBaseCipher` class and let the `AES128Cipher` and `AES256Cipher` classes extend it
2018-02-04 09:33:37 +01:00
Tim van der Meij
73436c0d12
Implement the AESBaseCipher class and let the AES128Cipher and AES256Cipher classes extend it 2018-02-03 20:16:33 +01:00
Tim van der Meij
9a959e4df7
Update the AES128Cipher and AES256Cipher implementations to be more similar
This commit is the first step for extracting a base class for the
`AES128Cipher` and the `AES256Cipher` classes. The objective here is to
make code changes (not altering the logic) to make the implementations
as similar as possible as found by creating a diff of both classes.

In particular, we extract the key size and cycles of repetitions
constants since they are different for AES-128 and AES-256. Moreover, we
rename functions to be similar.

In the `AES256Cipher` class, there was an additional assignment to
`this` in the decryption function. However, this was unnecessary because
the assignment would also be done when the loop was exited.
2018-02-03 20:16:29 +01:00
Tim van der Meij
695a909a93
Merge pull request #9426 from Snuffleupagus/issue-9425
Attempt to find the next valid marker when encountering invalid image data in `JpegImage.parse` (issue 9425)
2018-02-03 18:46:38 +01:00
Jonas Jenwald
f4a95de694 Attempt to find the next valid marker when encountering invalid image data in JpegImage.parse (issue 9425)
In the JPEG images in the referenced PDF file, the DHT (Define Huffman Tables) segments contain more data than expected based on the length parameter.

Fixes 9425.
2018-02-03 16:01:19 +01:00
Jonas Jenwald
29d77dedad
Merge pull request #9385 from Snuffleupagus/rm-SINGLE_FILE
[api-major] Remove the `SINGLE_FILE` build target and the `PDFJS.disableWorker` option
2018-02-02 09:21:58 +01:00
Tim van der Meij
9c6a8801b1
Merge pull request #9424 from Snuffleupagus/package-update
Update all npm packages to the latest versions
2018-02-01 22:50:29 +01:00
Jonas Jenwald
8488eeadc4 Update all npm packages to the latest versions 2018-01-31 15:51:03 +01:00
Jonas Jenwald
39c5e1ed1a Remove the (unnecessary) WorkerMessageHandler variable from the setupFakeWorkerGlobal() function in the src/display/api.js file 2018-01-31 12:52:10 +01:00
Jonas Jenwald
56a8c934dd [api-major] Remove the PDFJS.disableWorker option
Despite this patch removing the `disableWorker` option itself, please note that we'll still fallback to loading the worker file(s) on the main-thread when running in environments without proper Web Worker support.

Furthermore it's still possible, even with this patch, to force the use of fake workers by manually loading the necessary file using a `<script>` tag on the main-thread.[1]
That way, the functionality of the now removed `SINGLE_FILE` build target and the resulting `build/pdf.combined.js` file can still be achieved simply by adding e.g. `<script src="build/pdf.worker.js"></script>` to the HTML (obviously with the path adjusted as needed).

Finally note that the `disableWorker` option is a performance footgun, and unfortunately many existing third-party examples actually use it without providing any sort of warning/justification.

---

[1] This approach is used in the default viewer, since certain kind of debugging may be easier if the code is running directly on the main-thread.
2018-01-31 12:52:10 +01:00
Jonas Jenwald
a5aaf62754 [api-minor] Add a (static) PDFWorker.getWorkerSrc method that returns the current workerSrc
This method returns the currently used `workerSrc`, which thus allows obtaining the fallback `workerSrc` value (e.g. when the option wasn't set by the user).
2018-01-31 12:52:07 +01:00
Jonas Jenwald
c56f3f04dd [api-major] Remove the SINGLE_FILE build target
Please note that this build target, and the resulting `build/pdf.combined.js` file, is equivalent to setting the `PDFJS.disableWorker` option to `true` which is a performance footgun.
2018-01-29 14:44:44 +01:00
Tim van der Meij
55e3f97aa9
Merge pull request #9415 from Snuffleupagus/clitests-PDFNodeStream
Utilize `PDFNodeStream` to run more API unit-tests on Node.js/Travis
2018-01-28 18:24:59 +01:00
Jonas Jenwald
42c71cd99f Utilize PDFNodeStream to run more API unit-tests on Node.js/Travis 2018-01-28 17:14:08 +01:00
Rob Wu
fd242ad2c2
Merge pull request #9410 from Rob--W/cleanup-chrome-compat
Cleanup code to drop support for Chrome < 49 in the Chrome extension
2018-01-26 16:32:18 +01:00
Rob Wu
ff5ecc3f4c Remove work-around for old filesystem:-bug
https://crbug.com/362061 was fixed in Chrome 36, and the lowest
supported Chrome version in the extension is Chrome 49, so the
work-around for a filesystem:-bug in chromecom can be removed.
2018-01-26 15:54:35 +01:00
Rob Wu
7268f4ec1b [CRX] Add comment about ftp compatibility 2018-01-26 15:54:35 +01:00
Rob Wu
838573abd4 [CRX] Clean up file/ftp handler
Merge ftp and file handler now their implementations are identical.
Remove redundant comment (the referenced Chrome bug has been fixed
a long time ago - https://crbug.com/302548 ).
2018-01-26 15:54:35 +01:00
Rob Wu
85378fc982 [CRX] Remove feature-detect.js
All detected features were introduced in Chrome 35.
We don't support Chrome 34 and earlier, so drop the legacy code.
2018-01-26 15:54:35 +01:00
Jonas Jenwald
28c87ce9c6
Merge pull request #9409 from Rob--W/compat-chrome-49
Fix Chrome 49 compatibility via polyfills
2018-01-26 14:36:31 +01:00
Rob Wu
e904b8a67c Drop third parameter to replaceState/pushState
This was introduced in #3582 to work around https://crbug.com/274024 .
The bug in Chrome has been fixed a long time ago (at least 33), so let's
simplify the code.
2018-01-26 13:23:51 +01:00
Rob Wu
5d1c541702 Enable some polyfills for compat with Chrome 49
Successfully tested with Chrome 49.
2018-01-26 12:31:41 +01:00
Rob Wu
44025a3ec1 Explicitly state intended support in compatibility.js
Add comments with supported browser versions where missing.

Method:
- Use MDN compat tables if available.
- Otherwise test in Chrome (31+) otherwise.
  (the Chrome Web Store does not update older versions of
   Chrome, so probably nobody is interested in even older
   versions, even though there is an existing comment for
   Chrome<29 at `document.currentScript`).
2018-01-26 12:31:41 +01:00
Jonas Jenwald
628e70fbb5
Merge pull request #9405 from Snuffleupagus/pr-9245-followup
Re-factor resetting of `StatTimer` instances to fix completely broken benchmarking (PR 9245 follow-up)
2018-01-26 10:15:41 +01:00
Jonas Jenwald
d33c763dd5 Re-factor resetting of StatTimer instances to fix completely broken benchmarking (PR 9245 follow-up)
It turns out that PR 9245 unfortunately broke benchmarking completely, sorry about that!

The bug is that we were attempting to reset the current instance of `StatTimer`, instead of creating a new one as was previously done. By resetting the current instance, the `StatTimer` data fetched in `test/driver.js` is now wiped out since it points to the *same* underlying object.
This re-use of a `StatTimer` instance was asked for during review, and unfortunately I didn't test this thoroughly enough before submitting the final version of the PR.[1]

---

[1] Note that while I did test the benchmarking scripts with that PR *before* initially submitting it, I did however forget to do that after addressing the review comments which might explain why this problem went unnoticed.
2018-01-25 19:46:03 +01:00
Jonas Jenwald
b6c57d9088
Merge pull request #8991 from janpe2/jbig2-huffman
Implement Huffman coding in JBIG2
2018-01-23 19:26:42 +01:00
Jani Pehkonen
5593c970e0 Implement Huffman coding in JBIG2 2018-01-23 17:04:07 +02:00
Jonas Jenwald
f0216484bc
Merge pull request #9383 from Rob--W/better-content-disposition-parser
Better content disposition parser
2018-01-21 15:08:14 +01:00
Tim van der Meij
9746646511
Merge pull request #9386 from shikhar-scs/remove-parsejbig2-function
removed parseJbig2 function
2018-01-21 14:51:59 +01:00
Rob Wu
a4e907169e Improve correctness of Content-Disposition parser
Re-uses logic from 9f5fcae11c/extension/content-disposition.js
which is already covered by tests: 6f3bbb8bbf
2018-01-21 13:31:12 +01:00
Jonas Jenwald
fe5102a27f
Merge pull request #9363 from Rob--W/fetch-http/s-only
Limit PDFFetchStream to http(s) in the Chrome extension
2018-01-21 11:45:09 +01:00
Shikhar Agnihotri
43e003cf5c
removed parseJbig2 function 2018-01-20 19:49:06 +05:30
Jonas Jenwald
fad2a3f427
Merge pull request #9384 from timvandermeij/remove-moznomarginboxes
Remove `moznomarginboxes`
2018-01-20 10:11:22 +01:00
Tim van der Meij
81aa95b560
Remove moznomarginboxes 2018-01-19 22:05:50 +01:00
Rob Wu
0ffe9b9289 Remove useless test from network_utils_spec.js
Remove "returns null when content disposition is form-data".
The name of the test is already misleading: It suggests that
the return value is null if the Content-Disposition starts with
"form-data". This is not the case, anything with the "filename"
parameter is accepted.

So, to correct this, one would have to rephrase the test description to
"returns null when content disposition has no filename".
But this is already tested by the test called
"gets the filename from the response header".

So, remove the test.
2018-01-19 17:28:47 +01:00
Tim van der Meij
75dc2bbd35
Merge pull request #9379 from Snuffleupagus/contentDispositionFilename
[api-minor] Extract the Content-Disposition filename
2018-01-18 23:28:50 +01:00
Jonas Jenwald
69a8336cf1 Address the final round of review comments for Content-Disposition filename extraction
This patch updates the `IPDFStreamReader` interface and ensures that the interface/implementation of `network.js`, `fetch_stream.js`, `node_stream.js`, and `transport_stream.js` all match properly.
The unit-tests are also adjusted, to more closely replicate the actual behaviour of the various actual `IPDFStreamReader` implementations.
Finally, this patch adjusts the use of the Content-Disposition filename when setting the title in the viewer, and adds `PDFDocumentProperties` support as well.
2018-01-18 17:39:22 +01:00
Juan Salvador Perez Garcia
eb1f6f4c24 Content disposition filename
File name is extracted from headers.
2018-01-18 17:38:44 +01:00
Jonas Jenwald
96c573ad38
Merge pull request #9345 from himanish-star/hide-download-button
Download button is now hidden for PDFs which are loaded from 'file://'
2018-01-18 17:36:21 +01:00
Soumya Himanish Mohapatra
06b3bb8214 Download button is now hidden for PDFs which are opened from 'file://' 2018-01-18 16:13:25 +05:30
Jonas Jenwald
f774abc8d3
Merge pull request #9368 from acchou/9362
end() is the official way to release a Writable stream
2018-01-17 12:45:23 +01:00
Jonas Jenwald
22a9274193 Update l10n files 2018-01-17 11:37:44 +01:00