|
|
@ -31,15 +31,21 @@ var _dom_utils = require('../../display/dom_utils'); |
|
|
|
|
|
|
|
|
|
|
|
var _api = require('../../display/api'); |
|
|
|
var _api = require('../../display/api'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _is_node = require('../../shared/is_node'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _is_node2 = _interopRequireDefault(_is_node); |
|
|
|
|
|
|
|
|
|
|
|
var _global = require('../../display/global'); |
|
|
|
var _global = require('../../display/global'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
|
|
|
|
|
|
|
|
|
|
describe('api', function () { |
|
|
|
describe('api', function () { |
|
|
|
var basicApiFileName = 'basicapi.pdf'; |
|
|
|
var basicApiFileName = 'basicapi.pdf'; |
|
|
|
var basicApiFileLength = 105779; |
|
|
|
var basicApiFileLength = 105779; |
|
|
|
var basicApiGetDocumentParams = (0, _test_utils.buildGetDocumentParams)(basicApiFileName); |
|
|
|
var basicApiGetDocumentParams = (0, _test_utils.buildGetDocumentParams)(basicApiFileName); |
|
|
|
var CanvasFactory = void 0; |
|
|
|
var CanvasFactory = void 0; |
|
|
|
beforeAll(function (done) { |
|
|
|
beforeAll(function (done) { |
|
|
|
if ((0, _util.isNodeJS)()) {} else { |
|
|
|
if ((0, _is_node2.default)()) {} else { |
|
|
|
CanvasFactory = new _dom_utils.DOMCanvasFactory(); |
|
|
|
CanvasFactory = new _dom_utils.DOMCanvasFactory(); |
|
|
|
} |
|
|
|
} |
|
|
|
done(); |
|
|
|
done(); |
|
|
@ -57,7 +63,7 @@ describe('api', function () { |
|
|
|
describe('PDFJS', function () { |
|
|
|
describe('PDFJS', function () { |
|
|
|
describe('getDocument', function () { |
|
|
|
describe('getDocument', function () { |
|
|
|
it('creates pdf doc from URL', function (done) { |
|
|
|
it('creates pdf doc from URL', function (done) { |
|
|
|
if ((0, _util.isNodeJS)()) { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
} |
|
|
|
} |
|
|
|
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams); |
|
|
|
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams); |
|
|
@ -80,7 +86,7 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('creates pdf doc from URL and aborts before worker initialized', function (done) { |
|
|
|
it('creates pdf doc from URL and aborts before worker initialized', function (done) { |
|
|
|
if ((0, _util.isNodeJS)()) { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
} |
|
|
|
} |
|
|
|
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams); |
|
|
|
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams); |
|
|
@ -93,7 +99,7 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('creates pdf doc from URL and aborts loading after worker initialized', function (done) { |
|
|
|
it('creates pdf doc from URL and aborts loading after worker initialized', function (done) { |
|
|
|
if ((0, _util.isNodeJS)()) { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
} |
|
|
|
} |
|
|
|
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams); |
|
|
|
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams); |
|
|
@ -109,7 +115,7 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('creates pdf doc from typed array', function (done) { |
|
|
|
it('creates pdf doc from typed array', function (done) { |
|
|
|
var typedArrayPdf; |
|
|
|
var typedArrayPdf; |
|
|
|
if ((0, _util.isNodeJS)()) { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
typedArrayPdf = _test_utils.NodeFileReaderFactory.fetch({ path: _test_utils.TEST_PDFS_PATH.node + basicApiFileName }); |
|
|
|
typedArrayPdf = _test_utils.NodeFileReaderFactory.fetch({ path: _test_utils.TEST_PDFS_PATH.node + basicApiFileName }); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
var nonBinaryRequest = _global.PDFJS.disableWorker; |
|
|
|
var nonBinaryRequest = _global.PDFJS.disableWorker; |
|
|
@ -152,7 +158,7 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('creates pdf doc from non-existent URL', function (done) { |
|
|
|
it('creates pdf doc from non-existent URL', function (done) { |
|
|
|
if ((0, _util.isNodeJS)()) { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
} |
|
|
|
} |
|
|
|
var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)('non-existent.pdf')); |
|
|
|
var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)('non-existent.pdf')); |
|
|
@ -266,7 +272,7 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
describe('PDFWorker', function () { |
|
|
|
describe('PDFWorker', function () { |
|
|
|
if ((0, _util.isNodeJS)()) { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
pending('Worker is not supported in Node.js.'); |
|
|
|
pending('Worker is not supported in Node.js.'); |
|
|
|
} |
|
|
|
} |
|
|
|
it('worker created or destroyed', function (done) { |
|
|
|
it('worker created or destroyed', function (done) { |
|
|
@ -570,7 +576,7 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('gets attachments', function (done) { |
|
|
|
it('gets attachments', function (done) { |
|
|
|
if ((0, _util.isNodeJS)()) { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
pending('TODO: Use a non-linked test-case.'); |
|
|
|
pending('TODO: Use a non-linked test-case.'); |
|
|
|
} |
|
|
|
} |
|
|
|
var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)('bug766138.pdf')); |
|
|
|
var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)('bug766138.pdf')); |
|
|
@ -740,7 +746,7 @@ describe('api', function () { |
|
|
|
describe('Cross-origin', function () { |
|
|
|
describe('Cross-origin', function () { |
|
|
|
var loadingTask; |
|
|
|
var loadingTask; |
|
|
|
function _checkCanLoad(expectSuccess, filename, options) { |
|
|
|
function _checkCanLoad(expectSuccess, filename, options) { |
|
|
|
if ((0, _util.isNodeJS)()) { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
pending('Cannot simulate cross-origin requests in Node.js'); |
|
|
|
pending('Cannot simulate cross-origin requests in Node.js'); |
|
|
|
} |
|
|
|
} |
|
|
|
var params = (0, _test_utils.buildGetDocumentParams)(filename, options); |
|
|
|
var params = (0, _test_utils.buildGetDocumentParams)(filename, options); |
|
|
@ -952,7 +958,7 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('cancels rendering of page', function (done) { |
|
|
|
it('cancels rendering of page', function (done) { |
|
|
|
if ((0, _util.isNodeJS)()) { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
pending('TODO: Support Canvas testing in Node.js.'); |
|
|
|
pending('TODO: Support Canvas testing in Node.js.'); |
|
|
|
} |
|
|
|
} |
|
|
|
var viewport = page.getViewport(1); |
|
|
|
var viewport = page.getViewport(1); |
|
|
@ -972,7 +978,7 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('multiple render() on the same canvas', function (done) { |
|
|
|
it('multiple render() on the same canvas', function (done) { |
|
|
|
if ((0, _util.isNodeJS)()) { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
pending('TODO: Support Canvas testing in Node.js.'); |
|
|
|
pending('TODO: Support Canvas testing in Node.js.'); |
|
|
|
} |
|
|
|
} |
|
|
|
var viewport = page.getViewport(1); |
|
|
|
var viewport = page.getViewport(1); |
|
|
@ -993,7 +999,7 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
describe('Multiple PDFJS instances', function () { |
|
|
|
describe('Multiple PDFJS instances', function () { |
|
|
|
if ((0, _util.isNodeJS)()) { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
pending('TODO: Support Canvas testing in Node.js.'); |
|
|
|
pending('TODO: Support Canvas testing in Node.js.'); |
|
|
|
} |
|
|
|
} |
|
|
|
var pdf1 = (0, _test_utils.buildGetDocumentParams)('tracemonkey.pdf'); |
|
|
|
var pdf1 = (0, _test_utils.buildGetDocumentParams)('tracemonkey.pdf'); |
|
|
@ -1056,7 +1062,7 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
describe('PDFDataRangeTransport', function () { |
|
|
|
describe('PDFDataRangeTransport', function () { |
|
|
|
if ((0, _util.isNodeJS)()) { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
} |
|
|
|
} |
|
|
|
var pdfPath = new URL('../pdfs/tracemonkey.pdf', window.location).href; |
|
|
|
var pdfPath = new URL('../pdfs/tracemonkey.pdf', window.location).href; |
|
|
|