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