1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 15:48:06 +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

@ -23,7 +23,11 @@ if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {
if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
pdfjsLib = window['pdfjs-dist/build/pdf'];
} else if (typeof require === 'function') {
pdfjsLib = require('../build/pdf.js');
if (PDFJSDev.test('LIB')) {
pdfjsLib = require('../pdf.js');
} else {
pdfjsLib = require('../build/pdf.js');
}
} else {
throw new Error('Neither `require` nor `window` found');
}

View file

@ -30,7 +30,8 @@ var RendererType = {
SVG: 'svg',
};
var mozL10n = document.mozL10n || document.webL10n;
var mozL10n = typeof document !== 'undefined' ?
(document.mozL10n || document.webL10n) : undefined;
/**
* Disables fullscreen support, and by extension Presentation Mode,
@ -81,8 +82,9 @@ if (typeof PDFJSDev === 'undefined' ||
* Interface locale settings.
* @var {string}
*/
PDFJS.locale = (PDFJS.locale === undefined ? navigator.language :
PDFJS.locale);
PDFJS.locale =
(PDFJS.locale === undefined && typeof navigator !== 'undefined' ?
navigator.language : PDFJS.locale);
}
/**