1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | 'use strict';
|
23 |
|
24 | function initializePDFJS(callback) {
|
25 | Promise.all(['pdfjs/display/api', 'pdfjs/display/worker_options', 'pdfjs/display/network', 'pdfjs/display/fetch_stream', 'pdfjs/shared/is_node', 'pdfjs-test/unit/annotation_spec', 'pdfjs-test/unit/api_spec', 'pdfjs-test/unit/bidi_spec', 'pdfjs-test/unit/cff_parser_spec', 'pdfjs-test/unit/cmap_spec', 'pdfjs-test/unit/colorspace_spec', 'pdfjs-test/unit/crypto_spec', 'pdfjs-test/unit/custom_spec', 'pdfjs-test/unit/display_svg_spec', 'pdfjs-test/unit/document_spec', 'pdfjs-test/unit/dom_utils_spec', 'pdfjs-test/unit/encodings_spec', 'pdfjs-test/unit/evaluator_spec', 'pdfjs-test/unit/fonts_spec', 'pdfjs-test/unit/function_spec', 'pdfjs-test/unit/metadata_spec', 'pdfjs-test/unit/murmurhash3_spec', 'pdfjs-test/unit/network_spec', 'pdfjs-test/unit/network_utils_spec', 'pdfjs-test/unit/parser_spec', 'pdfjs-test/unit/pdf_history_spec', 'pdfjs-test/unit/primitives_spec', 'pdfjs-test/unit/stream_spec', 'pdfjs-test/unit/type1_parser_spec', 'pdfjs-test/unit/ui_utils_spec', 'pdfjs-test/unit/unicode_spec', 'pdfjs-test/unit/util_spec', 'pdfjs-test/unit/util_stream_spec'].map(function (moduleName) {
|
26 | return SystemJS.import(moduleName);
|
27 | })).then(function (modules) {
|
28 | var displayApi = modules[0];
|
29 | var GlobalWorkerOptions = modules[1].GlobalWorkerOptions;
|
30 | var PDFNetworkStream = modules[2].PDFNetworkStream;
|
31 | var PDFFetchStream = modules[3].PDFFetchStream;
|
32 | var isNodeJS = modules[4];
|
33 | if (isNodeJS()) {
|
34 | throw new Error('The `gulp unittest` command cannot be used in ' + 'Node.js environments.');
|
35 | }
|
36 | if (typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream !== 'undefined') {
|
37 | displayApi.setPDFNetworkStreamFactory(function (params) {
|
38 | return new PDFFetchStream(params);
|
39 | });
|
40 | } else {
|
41 | displayApi.setPDFNetworkStreamFactory(function (params) {
|
42 | return new PDFNetworkStream(params);
|
43 | });
|
44 | }
|
45 | GlobalWorkerOptions.workerSrc = '../../build/generic/build/pdf.worker.js';
|
46 | callback();
|
47 | });
|
48 | }
|
49 | (function () {
|
50 | window.jasmine = jasmineRequire.core(jasmineRequire);
|
51 | jasmineRequire.html(jasmine);
|
52 | var env = jasmine.getEnv();
|
53 | var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
54 | extend(window, jasmineInterface);
|
55 | var queryString = new jasmine.QueryString({
|
56 | getWindowLocation: function getWindowLocation() {
|
57 | return window.location;
|
58 | }
|
59 | });
|
60 | var stoppingOnSpecFailure = queryString.getParam('failFast');
|
61 | env.stopOnSpecFailure(typeof stoppingOnSpecFailure === 'undefined' ? false : stoppingOnSpecFailure);
|
62 | var throwingExpectationFailures = queryString.getParam('throwFailures');
|
63 | env.throwOnExpectationFailure(throwingExpectationFailures);
|
64 | var random = queryString.getParam('random');
|
65 | env.randomizeTests(random);
|
66 | var seed = queryString.getParam('seed');
|
67 | if (seed) {
|
68 | env.seed(seed);
|
69 | }
|
70 | var htmlReporter = new jasmine.HtmlReporter({
|
71 | env: env,
|
72 | onStopExecutionClick: function onStopExecutionClick() {
|
73 | queryString.navigateWithNewParam('failFast', env.stoppingOnSpecFailure());
|
74 | },
|
75 | onThrowExpectationsClick: function onThrowExpectationsClick() {
|
76 | queryString.navigateWithNewParam('throwFailures', !env.throwingExpectationFailures());
|
77 | },
|
78 | onRandomClick: function onRandomClick() {
|
79 | queryString.navigateWithNewParam('random', !env.randomTests());
|
80 | },
|
81 | addToExistingQueryString: function addToExistingQueryString(key, value) {
|
82 | return queryString.fullStringWithNewParam(key, value);
|
83 | },
|
84 | getContainer: function getContainer() {
|
85 | return document.body;
|
86 | },
|
87 | createElement: function createElement() {
|
88 | return document.createElement.apply(document, arguments);
|
89 | },
|
90 | createTextNode: function createTextNode() {
|
91 | return document.createTextNode.apply(document, arguments);
|
92 | },
|
93 |
|
94 | timer: new jasmine.Timer()
|
95 | });
|
96 | env.addReporter(htmlReporter);
|
97 | if (queryString.getParam('browser')) {
|
98 | var testReporter = new TestReporter(queryString.getParam('browser'), queryString.getParam('path'));
|
99 | env.addReporter(testReporter);
|
100 | }
|
101 | var specFilter = new jasmine.HtmlSpecFilter({
|
102 | filterString: function filterString() {
|
103 | return queryString.getParam('spec');
|
104 | }
|
105 | });
|
106 | env.specFilter = function (spec) {
|
107 | return specFilter.matches(spec.getFullName());
|
108 | };
|
109 | jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
110 | var currentWindowOnload = window.onload;
|
111 | window.onload = function () {
|
112 | if (currentWindowOnload) {
|
113 | currentWindowOnload();
|
114 | }
|
115 | initializePDFJS(function () {
|
116 | htmlReporter.initialize();
|
117 | env.execute();
|
118 | });
|
119 | };
|
120 | function extend(destination, source) {
|
121 | for (var property in source) {
|
122 | destination[property] = source[property];
|
123 | }
|
124 | return destination;
|
125 | }
|
126 | })(); |
\ | No newline at end of file |