mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-24 09:08:07 +02:00
Merge pull request #6771 from yurydelendik/requirejs
Removes hardcoded module loading order
This commit is contained in:
commit
e8db825512
25 changed files with 363 additions and 530 deletions
|
@ -6,55 +6,12 @@
|
|||
<link rel="shortcut icon" type="image/png" href="../../external/jasmine/jasmine_favicon.png">
|
||||
<link rel="stylesheet" type="text/css" href="../../external/jasmine/jasmine.css">
|
||||
|
||||
<script src="../../node_modules/requirejs/require.js"></script>
|
||||
<script src="../../external/jasmine/jasmine.js"></script>
|
||||
<script src="../../external/jasmine/jasmine-html.js"></script>
|
||||
<script src="../unit/testreporter.js"></script>
|
||||
<script src="fontutils.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script src="../../src/core/network.js"></script>
|
||||
<script src="../../src/core/arithmetic_decoder.js"></script>
|
||||
<script src="../../src/core/charsets.js"></script>
|
||||
<script src="../../src/core/glyphlist.js"></script>
|
||||
<script src="../../src/core/jpg.js"></script>
|
||||
<script src="../../src/core/metrics.js"></script>
|
||||
<script src="../../src/shared/global.js"></script>
|
||||
<script src="../../src/core/bidi.js"></script>
|
||||
<script src="../../src/display/dom_utils.js"></script>
|
||||
<script src="../../src/shared/util.js"></script>
|
||||
<script src="../../src/core/chunked_stream.js"></script>
|
||||
<script src="../../src/core/jbig2.js"></script>
|
||||
<script src="../../src/core/jpx.js"></script>
|
||||
<script src="../../src/core/murmurhash3.js"></script>
|
||||
<script src="../../src/core/primitives.js"></script>
|
||||
<script src="../../src/display/annotation_layer.js"></script>
|
||||
<script src="../../src/display/font_loader.js"></script>
|
||||
<script src="../../src/display/metadata.js"></script>
|
||||
<script src="../../src/display/text_layer.js"></script>
|
||||
<script src="../../src/display/webgl.js"></script>
|
||||
<script src="../../src/core/stream.js"></script>
|
||||
<script src="../../src/display/pattern_helper.js"></script>
|
||||
<script src="../../src/core/crypto.js"></script>
|
||||
<script src="../../src/core/font_renderer.js"></script>
|
||||
<script src="../../src/core/parser.js"></script>
|
||||
<script src="../../src/display/canvas.js"></script>
|
||||
<script src="../../src/core/cmap.js"></script>
|
||||
<script src="../../src/core/obj.js"></script>
|
||||
<script src="../../src/core/ps_parser.js"></script>
|
||||
<script src="../../src/display/api.js"></script>
|
||||
<script src="../../src/core/fonts.js"></script>
|
||||
<script src="../../src/core/function.js"></script>
|
||||
<script src="../../src/core/colorspace.js"></script>
|
||||
<script src="../../src/core/image.js"></script>
|
||||
<script src="../../src/core/pattern.js"></script>
|
||||
<script src="../../src/core/evaluator.js"></script>
|
||||
<script src="../../src/core/annotation.js"></script>
|
||||
<script src="../../src/core/document.js"></script>
|
||||
<script src="../../src/core/pdf_manager.js"></script>
|
||||
<script src="../../src/core/worker.js"></script>
|
||||
<script src="../../src/expose_to_global.js"></script>
|
||||
<script>PDFJS.workerSrc = '../../src/worker_loader.js';</script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script src="font_core_spec.js"></script>
|
||||
<script src="font_os2_spec.js"></script>
|
||||
|
@ -64,6 +21,20 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
function initializePDFJS(callback) {
|
||||
require.config({paths: {'pdfjs': '../../src'}});
|
||||
require(['pdfjs/core/fonts', 'pdfjs/core/stream', 'pdfjs/core/primitives',
|
||||
'pdfjs/core/cmap'], function (fonts, stream, primitives, cmap) {
|
||||
// Expose some of the PDFJS members to global scope for tests.
|
||||
window.Font = fonts.Font;
|
||||
window.Stream = stream.Stream;
|
||||
window.Name = primitives.Name;
|
||||
window.CMapFactory = cmap.CMapFactory;
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
(function pdfJsUnitTest() {
|
||||
function queryParams() {
|
||||
var qs = window.location.search.substring(1);
|
||||
|
@ -99,7 +70,7 @@
|
|||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
execJasmine();
|
||||
initializePDFJS(execJasmine);
|
||||
};
|
||||
|
||||
function execJasmine() {
|
||||
|
|
|
@ -18,17 +18,7 @@ limitations under the License.
|
|||
<head>
|
||||
<title>PDF.js test slave</title>
|
||||
<meta charset="utf-8">
|
||||
<script src="../src/shared/global.js"></script>
|
||||
<script src="../src/display/dom_utils.js"></script>
|
||||
<script src="../src/shared/util.js"></script>
|
||||
<script src="../src/display/annotation_layer.js"></script>
|
||||
<script src="../src/display/font_loader.js"></script>
|
||||
<script src="../src/display/metadata.js"></script>
|
||||
<script src="../src/display/text_layer.js"></script>
|
||||
<script src="../src/display/webgl.js"></script>
|
||||
<script src="../src/display/pattern_helper.js"></script>
|
||||
<script src="../src/display/canvas.js"></script>
|
||||
<script src="../src/display/api.js"></script>
|
||||
<script src="../node_modules/requirejs/require.js"></script>
|
||||
<script src="driver.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -41,12 +31,19 @@ limitations under the License.
|
|||
<div id="end"></div>
|
||||
</body>
|
||||
<script>
|
||||
var driver = new Driver({
|
||||
disableScrolling: document.getElementById('disableScrolling'),
|
||||
inflight: document.getElementById('inflight'),
|
||||
output: document.getElementById('output'),
|
||||
end: document.getElementById('end')
|
||||
require.config({paths: {'pdfjs': '../src'}});
|
||||
require(['pdfjs/display/api', 'pdfjs/display/text_layer',
|
||||
'pdfjs/display/annotation_layer', 'pdfjs/shared/util'],
|
||||
function (api, textLayer, annotationLayer, pdfjsSharedUtil) {
|
||||
window.pdfjsSharedUtil = pdfjsSharedUtil;
|
||||
|
||||
var driver = new Driver({
|
||||
disableScrolling: document.getElementById('disableScrolling'),
|
||||
inflight: document.getElementById('inflight'),
|
||||
output: document.getElementById('output'),
|
||||
end: document.getElementById('end')
|
||||
});
|
||||
driver.run();
|
||||
});
|
||||
driver.run();
|
||||
</script>
|
||||
</html>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* globals expect, it, describe, CFFCompiler, CFFParser, CFFIndex, CFFStrings,
|
||||
SEAC_ANALYSIS_ENABLED:true, Type1Parser, StringStream */
|
||||
SEAC_ANALYSIS_ENABLED, Type1Parser, StringStream,
|
||||
_enableSeacAnalysis */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -109,7 +110,7 @@ describe('font', function() {
|
|||
it('parses a CharString endchar with 4 args w/seac enabled', function() {
|
||||
var seacAnalysisState = SEAC_ANALYSIS_ENABLED;
|
||||
try {
|
||||
window.pdfjsCoreFonts._enableSeacAnalysis(true);
|
||||
_enableSeacAnalysis(true);
|
||||
var bytes = new Uint8Array([0, 1, // count
|
||||
1, // offsetSize
|
||||
0, // offset[0]
|
||||
|
@ -125,14 +126,14 @@ describe('font', function() {
|
|||
expect(result.seacs[0][2]).toEqual(65);
|
||||
expect(result.seacs[0][3]).toEqual(194);
|
||||
} finally {
|
||||
window.pdfjsCoreFonts._enableSeacAnalysis(seacAnalysisState);
|
||||
_enableSeacAnalysis(seacAnalysisState);
|
||||
}
|
||||
});
|
||||
|
||||
it('parses a CharString endchar with 4 args w/seac disabled', function() {
|
||||
var seacAnalysisState = SEAC_ANALYSIS_ENABLED;
|
||||
try {
|
||||
window.pdfjsCoreFonts._enableSeacAnalysis(false);
|
||||
_enableSeacAnalysis(false);
|
||||
var bytes = new Uint8Array([0, 1, // count
|
||||
1, // offsetSize
|
||||
0, // offset[0]
|
||||
|
@ -143,7 +144,7 @@ describe('font', function() {
|
|||
expect(result.charStrings.get(0).length).toEqual(9);
|
||||
expect(result.seacs.length).toEqual(0);
|
||||
} finally {
|
||||
window.pdfjsCoreFonts._enableSeacAnalysis(seacAnalysisState);
|
||||
_enableSeacAnalysis(seacAnalysisState);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -6,54 +6,21 @@
|
|||
<link rel="shortcut icon" type="image/png" href="../../external/jasmine/jasmine_favicon.png">
|
||||
<link rel="stylesheet" type="text/css" href="../../external/jasmine/jasmine.css">
|
||||
|
||||
<script src="../../node_modules/requirejs/require.js"></script>
|
||||
<script src="../../external/jasmine/jasmine.js"></script>
|
||||
<script src="../../external/jasmine/jasmine-html.js"></script>
|
||||
<script src="testreporter.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script src="../../src/core/network.js"></script>
|
||||
<script src="../../src/core/arithmetic_decoder.js"></script>
|
||||
<script src="../../src/core/charsets.js"></script>
|
||||
<script src="../../src/core/glyphlist.js"></script>
|
||||
<script src="../../src/core/jpg.js"></script>
|
||||
<script src="../../src/core/metrics.js"></script>
|
||||
<script src="../../src/shared/global.js"></script>
|
||||
<script src="../../src/core/bidi.js"></script>
|
||||
<script src="../../src/display/dom_utils.js"></script>
|
||||
<script src="../../src/shared/util.js"></script>
|
||||
<script src="../../src/core/chunked_stream.js"></script>
|
||||
<script src="../../src/core/jbig2.js"></script>
|
||||
<script src="../../src/core/jpx.js"></script>
|
||||
<script src="../../src/core/murmurhash3.js"></script>
|
||||
<script src="../../src/core/primitives.js"></script>
|
||||
<script src="../../src/display/annotation_layer.js"></script>
|
||||
<script src="../../src/display/font_loader.js"></script>
|
||||
<script src="../../src/display/metadata.js"></script>
|
||||
<script src="../../src/display/text_layer.js"></script>
|
||||
<script src="../../src/display/webgl.js"></script>
|
||||
<script src="../../src/core/stream.js"></script>
|
||||
<script src="../../src/display/pattern_helper.js"></script>
|
||||
<script src="../../src/core/crypto.js"></script>
|
||||
<script src="../../src/core/font_renderer.js"></script>
|
||||
<script src="../../src/core/parser.js"></script>
|
||||
<script src="../../src/display/canvas.js"></script>
|
||||
<script src="../../src/core/cmap.js"></script>
|
||||
<script src="../../src/core/obj.js"></script>
|
||||
<script src="../../src/core/ps_parser.js"></script>
|
||||
<script src="../../src/display/api.js"></script>
|
||||
<script src="../../src/core/fonts.js"></script>
|
||||
<script src="../../src/core/function.js"></script>
|
||||
<script src="../../src/core/colorspace.js"></script>
|
||||
<script src="../../src/core/image.js"></script>
|
||||
<script src="../../src/core/pattern.js"></script>
|
||||
<script src="../../src/core/evaluator.js"></script>
|
||||
<script src="../../src/core/annotation.js"></script>
|
||||
<script src="../../src/core/document.js"></script>
|
||||
<script src="../../src/core/pdf_manager.js"></script>
|
||||
<script src="../../src/core/worker.js"></script>
|
||||
<script src="../../src/expose_to_global.js"></script>
|
||||
<script src="../../web/ui_utils.js"></script>
|
||||
<script>PDFJS.workerSrc = '../../src/worker_loader.js';</script>
|
||||
|
||||
<script>
|
||||
// Hacking describe() to wait for PDFJS to be loaded, since Jasmine executes
|
||||
// it without waiting for libs to be loaded and fails to use PDFJS members.
|
||||
var oldDescribe = window.describe, describeQueue = [];
|
||||
window.describe = function () {
|
||||
describeQueue.push(Array.prototype.slice.call(arguments, 0));
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script src="primitives_spec.js"></script>
|
||||
|
@ -69,9 +36,66 @@
|
|||
<script src="util_spec.js"></script>
|
||||
<script src="cmap_spec.js"></script>
|
||||
<script src="annotation_layer_spec.js"></script>
|
||||
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
var pdfjsLibs;
|
||||
|
||||
function initializePDFJS(callback) {
|
||||
require.config({paths: {'pdfjs': '../../src'}});
|
||||
require(['pdfjs/shared/util', 'pdfjs/shared/global', 'pdfjs/core/primitives',
|
||||
'pdfjs/core/annotation', 'pdfjs/core/crypto', 'pdfjs/core/stream',
|
||||
'pdfjs/core/fonts', 'pdfjs/core/ps_parser', 'pdfjs/core/function',
|
||||
'pdfjs/core/parser', 'pdfjs/core/evaluator', 'pdfjs/core/cmap',
|
||||
'pdfjs/core/worker', 'pdfjs/display/api', 'pdfjs/display/metadata'],
|
||||
function (sharedUtil, sharedGlobal, corePrimitives, coreAnnotation,
|
||||
coreCrypto, coreStream, coreFonts, corePsParser, coreFunction,
|
||||
coreParser, coreEvaluator, coreCMap, coreWorker, displayAPI,
|
||||
displayMetadata) {
|
||||
|
||||
pdfjsLibs = {
|
||||
sharedUtil: sharedUtil,
|
||||
sharedGlobal: sharedGlobal,
|
||||
corePrimitives: corePrimitives,
|
||||
coreAnnotation: coreAnnotation,
|
||||
coreCrypto: coreCrypto,
|
||||
coreStream: coreStream,
|
||||
coreFonts: coreFonts,
|
||||
corePsParser: corePsParser,
|
||||
coreFunction: coreFunction,
|
||||
coreParser: coreParser,
|
||||
coreEvaluator: coreEvaluator,
|
||||
coreCMap: coreCMap,
|
||||
coreWorker: coreWorker,
|
||||
displayAPI: displayAPI,
|
||||
displayMetadata: displayMetadata
|
||||
};
|
||||
|
||||
// Expose all loaded internal exported members to global scope.
|
||||
Object.keys(pdfjsLibs).forEach(function (libName) {
|
||||
var lib = pdfjsLibs[libName];
|
||||
Object.keys(lib).forEach(function (name) {
|
||||
if (Object.getOwnPropertyDescriptor(window, name)) {
|
||||
return; // ignoring if already set
|
||||
}
|
||||
window[name] = lib[name];
|
||||
});
|
||||
});
|
||||
|
||||
// Configure the worker.
|
||||
PDFJS.workerSrc = '../../src/worker_loader.js';
|
||||
|
||||
// Release describe() calls.
|
||||
window.describe = oldDescribe;
|
||||
describeQueue.forEach(function (args) {
|
||||
oldDescribe.apply(window, args);
|
||||
});
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
(function pdfJsUnitTest() {
|
||||
function queryParams() {
|
||||
var qs = window.location.search.substring(1);
|
||||
|
@ -107,7 +131,7 @@
|
|||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
execJasmine();
|
||||
initializePDFJS(execJasmine);
|
||||
};
|
||||
|
||||
function execJasmine() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue