1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 07:38:07 +02:00

Enable running the ui_utils unit-tests on Travis

With the exception of just one test-case, all the current `ui_utils` unit-tests can run successfully on Node.js (since most of them doesn't rely on the DOM).

To get this working, I had to first of all add a new `LIB` build flag such that `gulp lib` produces a `web/pdfjs.js` file that is able to load `pdf.js` successfully.
Second of all, since neither `document` nor `navigator` is available in Node.js, `web/ui_utils.js` was adjusted slightly to avoid errors.
This commit is contained in:
Jonas Jenwald 2017-04-24 22:07:00 +02:00
parent 5fe26bb9da
commit ae04cf1c37
5 changed files with 17 additions and 4 deletions

View file

@ -16,6 +16,7 @@
"primitives_spec.js",
"stream_spec.js",
"type1_parser_spec.js",
"ui_utils_spec.js",
"unicode_spec.js",
"util_spec.js"
]

View file

@ -31,6 +31,7 @@ var binarySearchFirstItem = webUiUtils.binarySearchFirstItem;
var getPDFFileNameFromURL = webUiUtils.getPDFFileNameFromURL;
var EventBus = webUiUtils.EventBus;
var createObjectURL = sharedUtil.createObjectURL;
var isNodeJS = sharedUtil.isNodeJS;
describe('ui_utils', function() {
describe('binary search', function() {
@ -160,6 +161,9 @@ describe('ui_utils', function() {
it('gets PDF filename from query string appended to "blob:" URL',
function() {
if (isNodeJS()) {
pending('Blob in not supported in Node.js.');
}
var typedArray = new Uint8Array([1, 2, 3, 4, 5]);
var blobUrl = createObjectURL(typedArray, 'application/pdf');
// Sanity check to ensure that a "blob:" URL was returned.