mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge upstream and change test pdf file.
This commit is contained in:
commit
faa202df1e
24 changed files with 4306 additions and 635 deletions
|
@ -7,6 +7,11 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
// Disable worker support for running test as
|
||||
// https://github.com/mozilla/pdf.js/pull/764#issuecomment-2638944
|
||||
// "firefox-bin: Fatal IO error 12 (Cannot allocate memory) on X server :1."
|
||||
PDFJS.disableWorker = true;
|
||||
|
||||
var appPath, browser, canvas, currentTaskIdx, manifest, stdout;
|
||||
var inFlightRequests = 0;
|
||||
|
||||
|
@ -51,23 +56,29 @@ function load() {
|
|||
}
|
||||
|
||||
function cleanup() {
|
||||
var styleSheet = document.styleSheets[0];
|
||||
if (styleSheet) {
|
||||
// Clear out all the stylesheets since a new one is created for each font.
|
||||
while (document.styleSheets.length > 0) {
|
||||
var styleSheet = document.styleSheets[0];
|
||||
while (styleSheet.cssRules.length > 0)
|
||||
styleSheet.deleteRule(0);
|
||||
var ownerNode = styleSheet.ownerNode;
|
||||
ownerNode.parentNode.removeChild(ownerNode);
|
||||
}
|
||||
var guard = document.getElementById('content-end');
|
||||
var body = document.body;
|
||||
while (body.lastChild !== guard)
|
||||
body.removeChild(body.lastChild);
|
||||
|
||||
// Wipe out the link to the pdfdoc so it can be GC'ed.
|
||||
for (var i = 0; i < manifest.length; i++) {
|
||||
if (manifest[i].pdfDoc) {
|
||||
manifest[i].pdfDoc.destroy();
|
||||
delete manifest[i].pdfDoc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function nextTask() {
|
||||
// If there is a pdfDoc on the last task executed, destroy it to free memory.
|
||||
if (task && task.pdfDoc) {
|
||||
task.pdfDoc.destroy();
|
||||
delete task.pdfDoc;
|
||||
}
|
||||
cleanup();
|
||||
|
||||
if (currentTaskIdx == manifest.length) {
|
||||
|
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -14,4 +14,5 @@
|
|||
!sizes.pdf
|
||||
!close-path-bug.pdf
|
||||
!alphatrans.pdf
|
||||
!devicen.pdf
|
||||
!cmykjpeg.pdf
|
||||
|
|
Binary file not shown.
BIN
test/pdfs/devicen.pdf
Normal file
BIN
test/pdfs/devicen.pdf
Normal file
Binary file not shown.
|
@ -323,18 +323,18 @@ def verifyPDFs(manifestList):
|
|||
if os.access(f, os.R_OK):
|
||||
fileMd5 = hashlib.md5(open(f, 'rb').read()).hexdigest()
|
||||
if 'md5' not in item:
|
||||
print 'ERROR: Missing md5 for file "' + f + '".',
|
||||
print 'WARNING: Missing md5 for file "' + f + '".',
|
||||
print 'Hash for current file is "' + fileMd5 + '"'
|
||||
error = True
|
||||
continue
|
||||
md5 = item['md5']
|
||||
if fileMd5 != md5:
|
||||
print 'ERROR: MD5 of file "' + f + '" does not match file.',
|
||||
print 'WARNING: MD5 of file "' + f + '" does not match file.',
|
||||
print 'Expected "' + md5 + '" computed "' + fileMd5 + '"'
|
||||
error = True
|
||||
continue
|
||||
else:
|
||||
print 'ERROR: Unable to open file for reading "' + f + '".'
|
||||
print 'WARNING: Unable to open file for reading "' + f + '".'
|
||||
error = True
|
||||
return not error
|
||||
|
||||
|
@ -365,7 +365,8 @@ def setUp(options):
|
|||
downloadLinkedPDFs(manifestList)
|
||||
|
||||
if not verifyPDFs(manifestList):
|
||||
raise Exception('ERROR: failed to verify pdfs.')
|
||||
print 'Unable to verify the checksum for the files that are used for testing.'
|
||||
print 'Please re-download the files, or adjust the MD5 checksum in the manifest for the files listed above.\n'
|
||||
|
||||
for b in testBrowsers:
|
||||
State.taskResults[b.name] = { }
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
},
|
||||
{ "id": "intelisa-load",
|
||||
"file": "pdfs/intelisa.pdf",
|
||||
"md5": "f5712097d29287a97f1278839814f682",
|
||||
"md5": "f3ed5487d1afa34d8b77c0c734a95c79",
|
||||
"link": true,
|
||||
"rounds": 1,
|
||||
|
@ -187,7 +188,7 @@
|
|||
},
|
||||
{ "id": "f1040",
|
||||
"file": "pdfs/f1040.pdf",
|
||||
"md5": "7323b50c6d28d959b8b4b92c469b2469",
|
||||
"md5": "b59272ce19b4a0c5808c8861441b0741",
|
||||
"link": true,
|
||||
"rounds": 1,
|
||||
"type": "load"
|
||||
|
@ -262,9 +263,16 @@
|
|||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "devicen",
|
||||
"file": "pdfs/devicen.pdf",
|
||||
"md5": "aac6a91725435d1376c6ff492dc5cb75",
|
||||
"link": false,
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "cmykjpeg",
|
||||
"file": "pdfs/cmykjpeg.pdf",
|
||||
"md5": "8307472972ba962d86d2f60d2ced9a97",
|
||||
"md5": "85d162b48ce98503a382d96f574f70a2",
|
||||
"link": false,
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
|
|
16
test/unit/obj_spec.js
Normal file
16
test/unit/obj_spec.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
'use strict';
|
||||
|
||||
describe("obj", function() {
|
||||
|
||||
describe("Name", function() {
|
||||
it("should retain the given name", function() {
|
||||
var givenName = "Font";
|
||||
var name = new Name(givenName);
|
||||
expect(name.name).toEqual(givenName);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
51
test/unit/unit_test.html
Normal file
51
test/unit/unit_test.html
Normal file
|
@ -0,0 +1,51 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>pdf.js unit test</title>
|
||||
|
||||
<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 type="text/javascript" src="../../external/jasmine/jasmine.js"></script>
|
||||
<script type="text/javascript" src="../../external/jasmine/jasmine-html.js"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script type="text/javascript" src="obj_spec.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script type="text/javascript" src="../../src/obj.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
'use strict';
|
||||
|
||||
(function pdfJsUnitTest() {
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
|
||||
var trivialReporter = new jasmine.TrivialReporter();
|
||||
|
||||
jasmineEnv.addReporter(trivialReporter);
|
||||
|
||||
jasmineEnv.specFilter = function pdfJsUnitTestSpecFilter(spec) {
|
||||
return trivialReporter.specFilter(spec);
|
||||
};
|
||||
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function pdfJsUnitTestOnload() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
execJasmine();
|
||||
};
|
||||
|
||||
function execJasmine() {
|
||||
jasmineEnv.execute();
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue