Merge pull request #16604 from Snuffleupagus/pdfviewer_api-test-Node
Run the PDF.js-viewer API unit-test in Node.js environments (PR 16592 follow-up)
This commit is contained in:
commit
d7ae2f86e8
9
external/webL10n/l10n.js
vendored
9
external/webL10n/l10n.js
vendored
@ -30,12 +30,14 @@
|
|||||||
- Replaces one `Node.insertBefore()` with `Element.prepend()`.
|
- Replaces one `Node.insertBefore()` with `Element.prepend()`.
|
||||||
- Removes `fireL10nReadyEvent` since the "localized" event it dispatches
|
- Removes `fireL10nReadyEvent` since the "localized" event it dispatches
|
||||||
is unused and may clash with an identically named event in the viewer.
|
is unused and may clash with an identically named event in the viewer.
|
||||||
|
- Use preprocessor statements for browser globals (removed during building),
|
||||||
|
to enable more unit-testing in Node.js environments.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*jshint browser: true, devel: true, es5: true, globalstrict: true */
|
/*jshint browser: true, devel: true, es5: true, globalstrict: true */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
document.webL10n = (function(window, document, undefined) {
|
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("LIB") ? {} : document).webL10n = (function(window, document) {
|
||||||
var gL10nData = {};
|
var gL10nData = {};
|
||||||
var gTextData = '';
|
var gTextData = '';
|
||||||
var gTextProp = 'textContent';
|
var gTextProp = 'textContent';
|
||||||
@ -1026,4 +1028,7 @@ document.webL10n = (function(window, document, undefined) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}) (window, document);
|
}) (
|
||||||
|
typeof PDFJSDev !== "undefined" && PDFJSDev.test("LIB") ? {} : window,
|
||||||
|
typeof PDFJSDev !== "undefined" && PDFJSDev.test("LIB") ? {} : document
|
||||||
|
);
|
||||||
|
@ -1566,7 +1566,12 @@ function buildLib(defines, dir) {
|
|||||||
{ base: "src/" }
|
{ base: "src/" }
|
||||||
),
|
),
|
||||||
gulp.src(
|
gulp.src(
|
||||||
["examples/node/domstubs.js", "web/*.js", "!web/{pdfjs,viewer}.js"],
|
[
|
||||||
|
"examples/node/domstubs.js",
|
||||||
|
"external/webL10n/l10n.js",
|
||||||
|
"web/*.js",
|
||||||
|
"!web/{pdfjs,viewer}.js",
|
||||||
|
],
|
||||||
{ base: "." }
|
{ base: "." }
|
||||||
),
|
),
|
||||||
gulp.src("test/unit/*.js", { base: "." }),
|
gulp.src("test/unit/*.js", { base: "." }),
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
"pdf_find_utils_spec.js",
|
"pdf_find_utils_spec.js",
|
||||||
"pdf_history_spec.js",
|
"pdf_history_spec.js",
|
||||||
"pdf_spec.js",
|
"pdf_spec.js",
|
||||||
|
"pdf_viewer.component_spec.js",
|
||||||
"pdf_viewer_spec.js",
|
"pdf_viewer_spec.js",
|
||||||
"primitives_spec.js",
|
"primitives_spec.js",
|
||||||
"stream_spec.js",
|
"stream_spec.js",
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
import "../external/webL10n/l10n.js";
|
import "../external/webL10n/l10n.js";
|
||||||
import { getL10nFallback } from "./l10n_utils.js";
|
import { getL10nFallback } from "./l10n_utils.js";
|
||||||
|
|
||||||
const { webL10n } = document;
|
|
||||||
|
|
||||||
const PARTIAL_LANG_CODES = {
|
const PARTIAL_LANG_CODES = {
|
||||||
en: "en-US",
|
en: "en-US",
|
||||||
es: "es-ES",
|
es: "es-ES",
|
||||||
@ -47,6 +45,7 @@ function fixupLangCode(langCode) {
|
|||||||
*/
|
*/
|
||||||
class GenericL10n {
|
class GenericL10n {
|
||||||
constructor(lang) {
|
constructor(lang) {
|
||||||
|
const { webL10n } = document;
|
||||||
this._lang = lang;
|
this._lang = lang;
|
||||||
this._ready = new Promise((resolve, reject) => {
|
this._ready = new Promise((resolve, reject) => {
|
||||||
webL10n.setLanguage(fixupLangCode(lang), () => {
|
webL10n.setLanguage(fixupLangCode(lang), () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user