mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Update Prettier to version 2.0
Please note that these changes were done automatically, using `gulp lint --fix`. Given that the major version number was increased, there's a fair number of (primarily whitespace) changes; please see https://prettier.io/blog/2020/03/21/2.0.0.html In order to reduce the size of these changes somewhat, this patch maintains the old "arrowParens" style for now (once mozilla-central updates Prettier we can simply choose the same formatting, assuming it will differ here).
This commit is contained in:
parent
a4dd081d7b
commit
426945b480
145 changed files with 2005 additions and 2009 deletions
|
@ -25,13 +25,13 @@ if (!fs.existsSync(file)) {
|
|||
function calculateMD5(pdfFile, callback) {
|
||||
var hash = crypto.createHash("md5");
|
||||
var stream = fs.createReadStream(pdfFile);
|
||||
stream.on("data", function(data) {
|
||||
stream.on("data", function (data) {
|
||||
hash.update(data);
|
||||
});
|
||||
stream.on("error", function(err) {
|
||||
stream.on("error", function (err) {
|
||||
callback(err);
|
||||
});
|
||||
stream.on("end", function() {
|
||||
stream.on("end", function () {
|
||||
var result = hash.digest("hex");
|
||||
callback(null, result);
|
||||
});
|
||||
|
|
|
@ -45,13 +45,13 @@ function createExtensionGlobal() {
|
|||
window.chrome.extension.inIncognitoContext = false;
|
||||
window.chrome.runtime = {};
|
||||
window.chrome.runtime.id = "oemmndcbldboiebfnladdacbdfmadadm";
|
||||
window.chrome.runtime.getManifest = function() {
|
||||
window.chrome.runtime.getManifest = function () {
|
||||
return { version: "1.0.0" };
|
||||
};
|
||||
|
||||
function createStorageAPI() {
|
||||
var storageArea = {};
|
||||
storageArea.get = function(key, callback) {
|
||||
storageArea.get = function (key, callback) {
|
||||
assert.equal(key, "disableTelemetry");
|
||||
// chrome.storage.*. is async, but we make it synchronous to ease testing.
|
||||
callback(storageArea.mock_data);
|
||||
|
@ -73,7 +73,7 @@ function createExtensionGlobal() {
|
|||
|
||||
var getRandomValues_state = 0;
|
||||
window.crypto = {};
|
||||
window.crypto.getRandomValues = function(buf) {
|
||||
window.crypto.getRandomValues = function (buf) {
|
||||
var state = getRandomValues_state++;
|
||||
for (var i = 0; i < buf.length; ++i) {
|
||||
// Totally random byte ;)
|
||||
|
@ -89,38 +89,38 @@ function createExtensionGlobal() {
|
|||
throw new TypeError("Illegal invocation");
|
||||
},
|
||||
};
|
||||
window.fetch = function(url, options) {
|
||||
window.fetch = function (url, options) {
|
||||
assert.equal(url, LOG_URL);
|
||||
assert.equal(options.method, "POST");
|
||||
assert.equal(options.mode, "cors");
|
||||
assert.ok(!options.body);
|
||||
test_requests.push(options.headers);
|
||||
};
|
||||
window.Headers = function(headers) {
|
||||
window.Headers = function (headers) {
|
||||
headers = JSON.parse(JSON.stringify(headers)); // Clone.
|
||||
Object.keys(headers).forEach(function(k) {
|
||||
Object.keys(headers).forEach(function (k) {
|
||||
headers[k] = String(headers[k]);
|
||||
});
|
||||
return headers;
|
||||
};
|
||||
window.XMLHttpRequest = function() {
|
||||
window.XMLHttpRequest = function () {
|
||||
var invoked = {
|
||||
open: false,
|
||||
send: false,
|
||||
};
|
||||
var headers = {};
|
||||
return {
|
||||
open: function(method, url) {
|
||||
open: function (method, url) {
|
||||
assert.equal(invoked.open, false);
|
||||
invoked.open = true;
|
||||
assert.equal(method, "POST");
|
||||
assert.equal(url, LOG_URL);
|
||||
},
|
||||
setRequestHeader: function(k, v) {
|
||||
setRequestHeader: function (k, v) {
|
||||
assert.equal(invoked.open, true);
|
||||
headers[k] = String(v);
|
||||
},
|
||||
send: function(body) {
|
||||
send: function (body) {
|
||||
assert.equal(invoked.open, true);
|
||||
assert.equal(invoked.send, false);
|
||||
invoked.send = true;
|
||||
|
@ -132,19 +132,19 @@ function createExtensionGlobal() {
|
|||
|
||||
// Time-related logic.
|
||||
var timers = [];
|
||||
window.setInterval = function(callback, ms) {
|
||||
window.setInterval = function (callback, ms) {
|
||||
assert.equal(typeof callback, "function");
|
||||
timers.push(callback);
|
||||
};
|
||||
window.Date = {
|
||||
test_now_value: Date.now(),
|
||||
now: function() {
|
||||
now: function () {
|
||||
return window.Date.test_now_value;
|
||||
},
|
||||
};
|
||||
window.test_fireTimers = function() {
|
||||
window.test_fireTimers = function () {
|
||||
assert.ok(timers.length);
|
||||
timers.forEach(function(timer) {
|
||||
timers.forEach(function (timer) {
|
||||
timer();
|
||||
});
|
||||
};
|
||||
|
@ -156,7 +156,7 @@ function createExtensionGlobal() {
|
|||
function updateBrowser(window) {
|
||||
window.navigator.userAgent = window.navigator.userAgent.replace(
|
||||
/Chrome\/(\d+)/,
|
||||
function(_, v) {
|
||||
function (_, v) {
|
||||
return "Chrome/" + (parseInt(v) + 1);
|
||||
}
|
||||
);
|
||||
|
@ -351,7 +351,7 @@ var tests = [
|
|||
function test_extension_update() {
|
||||
var window = createExtensionGlobal();
|
||||
telemetryScript.runInNewContext(window);
|
||||
window.chrome.runtime.getManifest = function() {
|
||||
window.chrome.runtime.getManifest = function () {
|
||||
return { version: "1.0.1" };
|
||||
};
|
||||
window.Date.test_now_value += 12 * 36e5;
|
||||
|
@ -373,7 +373,7 @@ var tests = [
|
|||
var window = createExtensionGlobal();
|
||||
var didWarn = false;
|
||||
window.console = {};
|
||||
window.console.warn = function() {
|
||||
window.console.warn = function () {
|
||||
didWarn = true;
|
||||
};
|
||||
window.chrome.runtime.id = "abcdefghijklmnopabcdefghijklmnop";
|
||||
|
@ -413,7 +413,7 @@ var tests = [
|
|||
function test_fetch_mode_not_supported() {
|
||||
var window = createExtensionGlobal();
|
||||
delete window.Request.prototype.mode;
|
||||
window.fetch = function() {
|
||||
window.fetch = function () {
|
||||
throw new Error("Unexpected call to fetch!");
|
||||
};
|
||||
telemetryScript.runInNewContext(window);
|
||||
|
|
|
@ -40,7 +40,7 @@ function downloadFile(file, url, callback, redirects) {
|
|||
var completed = false;
|
||||
var protocol = /^https:\/\//.test(url) ? https : http;
|
||||
protocol
|
||||
.get(url, function(response) {
|
||||
.get(url, function (response) {
|
||||
var redirectTo;
|
||||
if (
|
||||
response.statusCode === 301 ||
|
||||
|
@ -71,14 +71,14 @@ function downloadFile(file, url, callback, redirects) {
|
|||
return;
|
||||
}
|
||||
var stream = fs.createWriteStream(file);
|
||||
stream.on("error", function(err) {
|
||||
stream.on("error", function (err) {
|
||||
if (!completed) {
|
||||
completed = true;
|
||||
callback(err);
|
||||
}
|
||||
});
|
||||
response.pipe(stream);
|
||||
stream.on("finish", function() {
|
||||
stream.on("finish", function () {
|
||||
stream.end();
|
||||
if (!completed) {
|
||||
completed = true;
|
||||
|
@ -86,7 +86,7 @@ function downloadFile(file, url, callback, redirects) {
|
|||
}
|
||||
});
|
||||
})
|
||||
.on("error", function(err) {
|
||||
.on("error", function (err) {
|
||||
if (!completed) {
|
||||
if (
|
||||
typeof err === "object" &&
|
||||
|
@ -113,7 +113,7 @@ function downloadManifestFiles(manifest, callback) {
|
|||
var file = links[i].file;
|
||||
var url = links[i].url;
|
||||
console.log("Downloading " + url + " to " + file + "...");
|
||||
downloadFile(file, url, function(err) {
|
||||
downloadFile(file, url, function (err) {
|
||||
if (err) {
|
||||
console.error("Error during downloading of " + url + ": " + err);
|
||||
fs.writeFileSync(file, ""); // making it empty file
|
||||
|
@ -125,10 +125,10 @@ function downloadManifestFiles(manifest, callback) {
|
|||
}
|
||||
|
||||
var links = manifest
|
||||
.filter(function(item) {
|
||||
.filter(function (item) {
|
||||
return item.link && !fs.existsSync(item.file);
|
||||
})
|
||||
.map(function(item) {
|
||||
.map(function (item) {
|
||||
var file = item.file;
|
||||
var linkfile = file + ".link";
|
||||
var url = fs.readFileSync(linkfile).toString();
|
||||
|
@ -143,13 +143,13 @@ function downloadManifestFiles(manifest, callback) {
|
|||
function calculateMD5(file, callback) {
|
||||
var hash = crypto.createHash("md5");
|
||||
var stream = fs.createReadStream(file);
|
||||
stream.on("data", function(data) {
|
||||
stream.on("data", function (data) {
|
||||
hash.update(data);
|
||||
});
|
||||
stream.on("error", function(err) {
|
||||
stream.on("error", function (err) {
|
||||
callback(err);
|
||||
});
|
||||
stream.on("end", function() {
|
||||
stream.on("end", function () {
|
||||
var result = hash.digest("hex");
|
||||
callback(null, result);
|
||||
});
|
||||
|
@ -171,7 +171,7 @@ function verifyManifestFiles(manifest, callback) {
|
|||
verifyNext();
|
||||
return;
|
||||
}
|
||||
calculateMD5(item.file, function(err, md5) {
|
||||
calculateMD5(item.file, function (err, md5) {
|
||||
if (err) {
|
||||
console.log('WARNING: Unable to open file for reading "' + err + '".');
|
||||
error = true;
|
||||
|
|
|
@ -34,10 +34,10 @@ var rasterizeTextLayer = (function rasterizeTextLayerClosure() {
|
|||
if (textLayerStylePromise) {
|
||||
return textLayerStylePromise;
|
||||
}
|
||||
textLayerStylePromise = new Promise(function(resolve) {
|
||||
textLayerStylePromise = new Promise(function (resolve) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "./text_layer_test.css");
|
||||
xhr.onload = function() {
|
||||
xhr.onload = function () {
|
||||
resolve(xhr.responseText);
|
||||
};
|
||||
xhr.send(null);
|
||||
|
@ -52,7 +52,7 @@ var rasterizeTextLayer = (function rasterizeTextLayerClosure() {
|
|||
textContent,
|
||||
enhanceTextSelection
|
||||
) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
// Building SVG with size of the viewport.
|
||||
var svg = document.createElementNS(SVG_NS, "svg:svg");
|
||||
svg.setAttribute("width", viewport.width + "px");
|
||||
|
@ -80,7 +80,7 @@ var rasterizeTextLayer = (function rasterizeTextLayerClosure() {
|
|||
viewport,
|
||||
enhanceTextSelection,
|
||||
});
|
||||
Promise.all([stylePromise, task.promise]).then(function(results) {
|
||||
Promise.all([stylePromise, task.promise]).then(function (results) {
|
||||
task.expandTextDivs(true);
|
||||
style.textContent = results[0];
|
||||
svg.appendChild(foreignObject);
|
||||
|
@ -91,11 +91,11 @@ var rasterizeTextLayer = (function rasterizeTextLayerClosure() {
|
|||
);
|
||||
var img = new Image();
|
||||
img.src = "data:image/svg+xml;base64," + btoa(svg_xml);
|
||||
img.onload = function() {
|
||||
img.onload = function () {
|
||||
ctx.drawImage(img, 0, 0);
|
||||
resolve();
|
||||
};
|
||||
img.onerror = function(e) {
|
||||
img.onerror = function (e) {
|
||||
reject(new Error("Error rasterizing text layer " + e));
|
||||
};
|
||||
});
|
||||
|
@ -139,13 +139,13 @@ var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {
|
|||
|
||||
// Load the style files and cache the results.
|
||||
for (const key in styles) {
|
||||
styles[key].promise = new Promise(function(resolve, reject) {
|
||||
styles[key].promise = new Promise(function (resolve, reject) {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", styles[key].file);
|
||||
xhr.onload = function() {
|
||||
xhr.onload = function () {
|
||||
resolve(xhr.responseText);
|
||||
};
|
||||
xhr.onerror = function(e) {
|
||||
xhr.onerror = function (e) {
|
||||
reject(new Error("Error fetching annotation style " + e));
|
||||
};
|
||||
xhr.send(null);
|
||||
|
@ -158,17 +158,17 @@ var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {
|
|||
function inlineAnnotationImages(images) {
|
||||
var imagePromises = [];
|
||||
for (var i = 0, ii = images.length; i < ii; i++) {
|
||||
var imagePromise = new Promise(function(resolve, reject) {
|
||||
var imagePromise = new Promise(function (resolve, reject) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = "blob";
|
||||
xhr.onload = function() {
|
||||
xhr.onload = function () {
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function() {
|
||||
reader.onloadend = function () {
|
||||
resolve(reader.result);
|
||||
};
|
||||
reader.readAsDataURL(xhr.response);
|
||||
};
|
||||
xhr.onerror = function(e) {
|
||||
xhr.onerror = function (e) {
|
||||
reject(new Error("Error fetching inline annotation image " + e));
|
||||
};
|
||||
xhr.open("GET", images[i].src);
|
||||
|
@ -188,7 +188,7 @@ var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {
|
|||
imageResourcesPath,
|
||||
renderInteractiveForms
|
||||
) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
// Building SVG with size of the viewport.
|
||||
var svg = document.createElementNS(SVG_NS, "svg:svg");
|
||||
svg.setAttribute("width", viewport.width + "px");
|
||||
|
@ -207,7 +207,7 @@ var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {
|
|||
div.className = "annotationLayer";
|
||||
|
||||
// Rendering annotation layer as HTML.
|
||||
stylePromise.then(function(common, overrides) {
|
||||
stylePromise.then(function (common, overrides) {
|
||||
style.textContent = common + overrides;
|
||||
|
||||
var annotation_viewport = viewport.clone({ dontFlip: true });
|
||||
|
@ -225,14 +225,14 @@ var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {
|
|||
// Inline SVG images from text annotations.
|
||||
var images = div.getElementsByTagName("img");
|
||||
var imagePromises = inlineAnnotationImages(images);
|
||||
var converted = Promise.all(imagePromises).then(function(data) {
|
||||
var converted = Promise.all(imagePromises).then(function (data) {
|
||||
var loadedPromises = [];
|
||||
for (var i = 0, ii = data.length; i < ii; i++) {
|
||||
images[i].src = data[i];
|
||||
loadedPromises.push(
|
||||
new Promise(function(resolveImage, rejectImage) {
|
||||
new Promise(function (resolveImage, rejectImage) {
|
||||
images[i].onload = resolveImage;
|
||||
images[i].onerror = function(e) {
|
||||
images[i].onerror = function (e) {
|
||||
rejectImage(new Error("Error loading image " + e));
|
||||
};
|
||||
})
|
||||
|
@ -245,17 +245,17 @@ var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {
|
|||
svg.appendChild(foreignObject);
|
||||
|
||||
// We need to have UTF-8 encoded XML.
|
||||
converted.then(function() {
|
||||
converted.then(function () {
|
||||
var svg_xml = unescape(
|
||||
encodeURIComponent(new XMLSerializer().serializeToString(svg))
|
||||
);
|
||||
var img = new Image();
|
||||
img.src = "data:image/svg+xml;base64," + btoa(svg_xml);
|
||||
img.onload = function() {
|
||||
img.onload = function () {
|
||||
ctx.drawImage(img, 0, 0);
|
||||
resolve();
|
||||
};
|
||||
img.onerror = function(e) {
|
||||
img.onerror = function (e) {
|
||||
reject(new Error("Error rasterizing annotation layer " + e));
|
||||
};
|
||||
});
|
||||
|
@ -325,7 +325,7 @@ var Driver = (function DriverClosure() {
|
|||
|
||||
run: function Driver_run() {
|
||||
var self = this;
|
||||
window.onerror = function(message, source, line, column, error) {
|
||||
window.onerror = function (message, source, line, column, error) {
|
||||
self._info(
|
||||
"Error: " +
|
||||
message +
|
||||
|
@ -351,12 +351,12 @@ var Driver = (function DriverClosure() {
|
|||
|
||||
var r = new XMLHttpRequest();
|
||||
r.open("GET", this.manifestFile, false);
|
||||
r.onreadystatechange = function() {
|
||||
r.onreadystatechange = function () {
|
||||
if (r.readyState === 4) {
|
||||
self._log("done\n");
|
||||
self.manifest = JSON.parse(r.responseText);
|
||||
if (self.testFilter && self.testFilter.length) {
|
||||
self.manifest = self.manifest.filter(function(item) {
|
||||
self.manifest = self.manifest.filter(function (item) {
|
||||
return self.testFilter.includes(item.id);
|
||||
});
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ var Driver = (function DriverClosure() {
|
|||
}
|
||||
// When gathering the stats the numbers seem to be more reliable
|
||||
// if the browser is given more time to start.
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
r.send(null);
|
||||
}, this.delay);
|
||||
},
|
||||
|
@ -472,7 +472,7 @@ var Driver = (function DriverClosure() {
|
|||
|
||||
if (!task.pdfDoc) {
|
||||
var dataUrl = this.canvas.toDataURL("image/png");
|
||||
this._sendResult(dataUrl, task, failure, function() {
|
||||
this._sendResult(dataUrl, task, failure, function () {
|
||||
self._log(
|
||||
"done" + (failure ? " (failed !: " + failure + ")" : "") + "\n"
|
||||
);
|
||||
|
@ -518,7 +518,7 @@ var Driver = (function DriverClosure() {
|
|||
this.canvas.mozOpaque = true;
|
||||
ctx = this.canvas.getContext("2d", { alpha: false });
|
||||
task.pdfDoc.getPage(task.pageNum).then(
|
||||
function(page) {
|
||||
function (page) {
|
||||
var viewport = page.getViewport({ scale: PDF_TO_CSS_UNITS });
|
||||
self.canvas.width = viewport.width;
|
||||
self.canvas.height = viewport.height;
|
||||
|
@ -552,7 +552,7 @@ var Driver = (function DriverClosure() {
|
|||
.getTextContent({
|
||||
normalizeWhitespace: true,
|
||||
})
|
||||
.then(function(textContent) {
|
||||
.then(function (textContent) {
|
||||
return rasterizeTextLayer(
|
||||
textLayerContext,
|
||||
viewport,
|
||||
|
@ -590,7 +590,7 @@ var Driver = (function DriverClosure() {
|
|||
// The annotation builder will draw its content on the canvas.
|
||||
initPromise = page
|
||||
.getAnnotations({ intent: "display" })
|
||||
.then(function(annotations) {
|
||||
.then(function (annotations) {
|
||||
return rasterizeAnnotationLayer(
|
||||
annotationLayerContext,
|
||||
viewport,
|
||||
|
@ -611,7 +611,7 @@ var Driver = (function DriverClosure() {
|
|||
viewport,
|
||||
renderInteractiveForms: renderForms,
|
||||
};
|
||||
var completeRender = function(error) {
|
||||
var completeRender = function (error) {
|
||||
// if text layer is present, compose it on top of the page
|
||||
if (textLayerCanvas) {
|
||||
ctx.save();
|
||||
|
@ -633,16 +633,16 @@ var Driver = (function DriverClosure() {
|
|||
self._snapshot(task, error);
|
||||
};
|
||||
initPromise
|
||||
.then(function() {
|
||||
return page.render(renderContext).promise.then(function() {
|
||||
.then(function () {
|
||||
return page.render(renderContext).promise.then(function () {
|
||||
completeRender(false);
|
||||
});
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
completeRender("render : " + error);
|
||||
});
|
||||
},
|
||||
function(error) {
|
||||
function (error) {
|
||||
self._snapshot(task, "render : " + error);
|
||||
}
|
||||
);
|
||||
|
@ -664,7 +664,7 @@ var Driver = (function DriverClosure() {
|
|||
this._log("Snapshotting... ");
|
||||
|
||||
var dataUrl = this.canvas.toDataURL("image/png");
|
||||
this._sendResult(dataUrl, task, failure, function() {
|
||||
this._sendResult(dataUrl, task, failure, function () {
|
||||
self._log(
|
||||
"done" + (failure ? " (failed !: " + failure + ")" : "") + "\n"
|
||||
);
|
||||
|
@ -680,7 +680,7 @@ var Driver = (function DriverClosure() {
|
|||
// Send the quit request
|
||||
var r = new XMLHttpRequest();
|
||||
r.open("POST", "/tellMeToQuit?path=" + escape(this.appPath), false);
|
||||
r.onreadystatechange = function(e) {
|
||||
r.onreadystatechange = function (e) {
|
||||
if (r.readyState === 4) {
|
||||
window.close();
|
||||
}
|
||||
|
@ -744,13 +744,13 @@ var Driver = (function DriverClosure() {
|
|||
var r = new XMLHttpRequest();
|
||||
r.open("POST", url, true);
|
||||
r.setRequestHeader("Content-Type", "application/json");
|
||||
r.onreadystatechange = function(e) {
|
||||
r.onreadystatechange = function (e) {
|
||||
if (r.readyState === 4) {
|
||||
self.inFlightRequests--;
|
||||
|
||||
// Retry until successful
|
||||
if (r.status !== 200) {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
self._send(url, message);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ function initializePDFJS(callback) {
|
|||
SystemJS.import("pdfjs/core/stream.js"),
|
||||
SystemJS.import("pdfjs/core/primitives.js"),
|
||||
SystemJS.import("pdfjs/core/cmap.js"),
|
||||
]).then(function(modules) {
|
||||
]).then(function (modules) {
|
||||
var fonts = modules[0],
|
||||
stream = modules[1],
|
||||
primitives = modules[2],
|
||||
|
@ -62,7 +62,7 @@ function initializePDFJS(callback) {
|
|||
});
|
||||
}
|
||||
|
||||
(function() {
|
||||
(function () {
|
||||
window.jasmine = jasmineRequire.core(jasmineRequire);
|
||||
|
||||
jasmineRequire.html(jasmine);
|
||||
|
@ -134,7 +134,7 @@ function initializePDFJS(callback) {
|
|||
},
|
||||
});
|
||||
|
||||
config.specFilter = function(spec) {
|
||||
config.specFilter = function (spec) {
|
||||
return specFilter.matches(spec.getFullName());
|
||||
};
|
||||
|
||||
|
@ -148,12 +148,12 @@ function initializePDFJS(callback) {
|
|||
// instance and then executing the loaded Jasmine environment.
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
window.onload = function () {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
|
||||
initializePDFJS(function() {
|
||||
initializePDFJS(function () {
|
||||
htmlReporter.initialize();
|
||||
env.execute();
|
||||
});
|
||||
|
|
|
@ -25,9 +25,9 @@ var ttxResourcesHome = path.join(__dirname, "..", "ttx");
|
|||
var nextTTXTaskId = Date.now();
|
||||
|
||||
function runTtx(ttxResourcesHomePath, fontPath, registerOnCancel, callback) {
|
||||
fs.realpath(ttxResourcesHomePath, function(error, realTtxResourcesHomePath) {
|
||||
fs.realpath(ttxResourcesHomePath, function (error, realTtxResourcesHomePath) {
|
||||
var fontToolsHome = path.join(realTtxResourcesHomePath, "fonttools-code");
|
||||
fs.realpath(fontPath, function(errorFontPath, realFontPath) {
|
||||
fs.realpath(fontPath, function (errorFontPath, realFontPath) {
|
||||
var ttxPath = path.join("Tools", "ttx");
|
||||
if (!fs.existsSync(path.join(fontToolsHome, ttxPath))) {
|
||||
callback("TTX was not found, please checkout PDF.js submodules");
|
||||
|
@ -44,16 +44,16 @@ function runTtx(ttxResourcesHomePath, fontPath, registerOnCancel, callback) {
|
|||
env: ttxEnv,
|
||||
});
|
||||
var ttxRunError;
|
||||
registerOnCancel(function(reason) {
|
||||
registerOnCancel(function (reason) {
|
||||
ttxRunError = reason;
|
||||
callback(reason);
|
||||
ttx.kill();
|
||||
});
|
||||
ttx.on("error", function(errorTtx) {
|
||||
ttx.on("error", function (errorTtx) {
|
||||
ttxRunError = errorTtx;
|
||||
callback("Unable to execute ttx");
|
||||
});
|
||||
ttx.on("close", function(code) {
|
||||
ttx.on("close", function (code) {
|
||||
if (ttxRunError) {
|
||||
return;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ exports.translateFont = function translateFont(
|
|||
var resultPath = path.join(ttxResourcesHome, taskId + ".ttx");
|
||||
|
||||
fs.writeFileSync(fontPath, buffer);
|
||||
runTtx(ttxResourcesHome, fontPath, registerOnCancel, function(err) {
|
||||
runTtx(ttxResourcesHome, fontPath, registerOnCancel, function (err) {
|
||||
fs.unlinkSync(fontPath);
|
||||
if (err) {
|
||||
console.error(err);
|
||||
|
|
|
@ -57,8 +57,8 @@ function group(stats, groupBy) {
|
|||
*/
|
||||
function flatten(stats) {
|
||||
var rows = [];
|
||||
stats.forEach(function(curStat) {
|
||||
curStat["stats"].forEach(function(s) {
|
||||
stats.forEach(function (curStat) {
|
||||
curStat["stats"].forEach(function (s) {
|
||||
rows.push({
|
||||
browser: curStat["browser"],
|
||||
page: curStat["page"],
|
||||
|
@ -71,7 +71,7 @@ function flatten(stats) {
|
|||
});
|
||||
// Use only overall results if not grouped by 'stat'
|
||||
if (!options.groupBy.includes("stat")) {
|
||||
rows = rows.filter(function(s) {
|
||||
rows = rows.filter(function (s) {
|
||||
return s.stat === "Overall";
|
||||
});
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ function stat(baseline, current) {
|
|||
row,
|
||||
rows = [];
|
||||
// collect rows and measure column widths
|
||||
var width = labels.map(function(s) {
|
||||
var width = labels.map(function (s) {
|
||||
return s.length;
|
||||
});
|
||||
rows.push(labels);
|
||||
|
@ -172,7 +172,7 @@ function stat(baseline, current) {
|
|||
}
|
||||
|
||||
// add horizontal line
|
||||
var hline = width.map(function(w) {
|
||||
var hline = width.map(function (w) {
|
||||
return new Array(w + 1).join("-");
|
||||
});
|
||||
rows.splice(1, 0, hline);
|
||||
|
|
70
test/test.js
70
test/test.js
|
@ -27,7 +27,7 @@ var testUtils = require("./testutils.js");
|
|||
|
||||
function parseOptions() {
|
||||
function describeCheck(fn, text) {
|
||||
fn.toString = function() {
|
||||
fn.toString = function () {
|
||||
return text;
|
||||
};
|
||||
return fn;
|
||||
|
@ -102,7 +102,7 @@ function parseOptions() {
|
|||
)
|
||||
.default("statsDelay", 0)
|
||||
.check(
|
||||
describeCheck(function(argv) {
|
||||
describeCheck(function (argv) {
|
||||
return (
|
||||
+argv.reftest + argv.unitTest + argv.fontTest + argv.masterMode <= 1
|
||||
);
|
||||
|
@ -110,18 +110,18 @@ function parseOptions() {
|
|||
"specified at the same time.")
|
||||
)
|
||||
.check(
|
||||
describeCheck(function(argv) {
|
||||
describeCheck(function (argv) {
|
||||
return !argv.noDownload || !argv.downloadOnly;
|
||||
}, "--noDownload and --downloadOnly cannot be used together.")
|
||||
)
|
||||
.check(
|
||||
describeCheck(function(argv) {
|
||||
describeCheck(function (argv) {
|
||||
return !argv.masterMode || argv.manifestFile === "test_manifest.json";
|
||||
}, "when --masterMode is specified --manifestFile shall be equal " +
|
||||
"test_manifest.json")
|
||||
)
|
||||
.check(
|
||||
describeCheck(function(argv) {
|
||||
describeCheck(function (argv) {
|
||||
return !argv.browser || !argv.browserManifestFile;
|
||||
}, "--browser and --browserManifestFile must not be specified at the " +
|
||||
"same time.")
|
||||
|
@ -151,7 +151,7 @@ function monitorBrowserTimeout(session, onTimeout) {
|
|||
session.timeoutMonitor = null;
|
||||
return;
|
||||
}
|
||||
session.timeoutMonitor = setTimeout(function() {
|
||||
session.timeoutMonitor = setTimeout(function () {
|
||||
onTimeout(session);
|
||||
}, browserTimeout * 1000);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ function updateRefImages() {
|
|||
}
|
||||
testUtils.confirm(
|
||||
"Would you like to update the master copy in ref/? [yn] ",
|
||||
function(confirmed) {
|
||||
function (confirmed) {
|
||||
if (confirmed) {
|
||||
sync(true);
|
||||
} else {
|
||||
|
@ -203,7 +203,7 @@ function startRefTest(masterMode, showRefImages) {
|
|||
var numFBFFailures = 0;
|
||||
var numEqFailures = 0;
|
||||
var numEqNoSnapshot = 0;
|
||||
sessions.forEach(function(session) {
|
||||
sessions.forEach(function (session) {
|
||||
numErrors += session.numErrors;
|
||||
numFBFFailures += session.numFBFFailures;
|
||||
numEqFailures += session.numEqFailures;
|
||||
|
@ -274,12 +274,12 @@ function startRefTest(masterMode, showRefImages) {
|
|||
server.hooks["POST"].push(refTestPostHandler);
|
||||
onAllSessionsClosed = finalize;
|
||||
|
||||
startBrowsers("/test/test_slave.html", function(session) {
|
||||
startBrowsers("/test/test_slave.html", function (session) {
|
||||
session.masterMode = masterMode;
|
||||
session.taskResults = {};
|
||||
session.tasks = {};
|
||||
session.remaining = manifest.length;
|
||||
manifest.forEach(function(item) {
|
||||
manifest.forEach(function (item) {
|
||||
var rounds = item.rounds || 1;
|
||||
var roundsResults = [];
|
||||
roundsResults.length = rounds;
|
||||
|
@ -304,7 +304,7 @@ function startRefTest(masterMode, showRefImages) {
|
|||
console.log("tmp/ can be removed if it has nothing you need.");
|
||||
testUtils.confirm(
|
||||
"SHOULD THIS SCRIPT REMOVE tmp/? THINK CAREFULLY [yn] ",
|
||||
function(confirmed) {
|
||||
function (confirmed) {
|
||||
if (confirmed) {
|
||||
testUtils.removeDirSync(refsTmpDir);
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ function getTestManifest() {
|
|||
|
||||
var testFilter = options.testfilter.slice(0);
|
||||
if (testFilter.length) {
|
||||
manifest = manifest.filter(function(item) {
|
||||
manifest = manifest.filter(function (item) {
|
||||
var i = testFilter.indexOf(item.id);
|
||||
if (i !== -1) {
|
||||
testFilter.splice(i, 1);
|
||||
|
@ -533,8 +533,8 @@ function checkRefTestResults(browser, id, results) {
|
|||
var failed = false;
|
||||
var session = getSession(browser);
|
||||
var task = session.tasks[id];
|
||||
results.forEach(function(roundResults, round) {
|
||||
roundResults.forEach(function(pageResult, page) {
|
||||
results.forEach(function (roundResults, round) {
|
||||
roundResults.forEach(function (pageResult, page) {
|
||||
if (!pageResult) {
|
||||
return; // no results
|
||||
}
|
||||
|
@ -589,8 +589,8 @@ function checkRefTestResults(browser, id, results) {
|
|||
throw new Error("Unknown test type");
|
||||
}
|
||||
// clear memory
|
||||
results.forEach(function(roundResults, round) {
|
||||
roundResults.forEach(function(pageResult, page) {
|
||||
results.forEach(function (roundResults, round) {
|
||||
roundResults.forEach(function (pageResult, page) {
|
||||
pageResult.snapshot = null;
|
||||
});
|
||||
});
|
||||
|
@ -608,10 +608,10 @@ function refTestPostHandler(req, res) {
|
|||
}
|
||||
|
||||
var body = "";
|
||||
req.on("data", function(data) {
|
||||
req.on("data", function (data) {
|
||||
body += data;
|
||||
});
|
||||
req.on("end", function() {
|
||||
req.on("end", function () {
|
||||
res.writeHead(200, { "Content-Type": "text/plain" });
|
||||
res.end();
|
||||
|
||||
|
@ -619,7 +619,7 @@ function refTestPostHandler(req, res) {
|
|||
if (pathname === "/tellMeToQuit") {
|
||||
// finding by path
|
||||
var browserPath = parsedUrl.query.path;
|
||||
session = sessions.filter(function(curSession) {
|
||||
session = sessions.filter(function (curSession) {
|
||||
return curSession.config.path === browserPath;
|
||||
})[0];
|
||||
monitorBrowserTimeout(session, null);
|
||||
|
@ -693,11 +693,11 @@ function startUnitTest(testUrl, name) {
|
|||
var startTime = Date.now();
|
||||
startServer();
|
||||
server.hooks["POST"].push(unitTestPostHandler);
|
||||
onAllSessionsClosed = function() {
|
||||
onAllSessionsClosed = function () {
|
||||
stopServer();
|
||||
var numRuns = 0,
|
||||
numErrors = 0;
|
||||
sessions.forEach(function(session) {
|
||||
sessions.forEach(function (session) {
|
||||
numRuns += session.numRuns;
|
||||
numErrors += session.numErrors;
|
||||
});
|
||||
|
@ -712,7 +712,7 @@ function startUnitTest(testUrl, name) {
|
|||
var runtime = (Date.now() - startTime) / 1000;
|
||||
console.log(name + " tests runtime was " + runtime.toFixed(1) + " seconds");
|
||||
};
|
||||
startBrowsers(testUrl, function(session) {
|
||||
startBrowsers(testUrl, function (session) {
|
||||
session.numRuns = 0;
|
||||
session.numErrors = 0;
|
||||
});
|
||||
|
@ -731,25 +731,25 @@ function unitTestPostHandler(req, res) {
|
|||
}
|
||||
|
||||
var body = "";
|
||||
req.on("data", function(data) {
|
||||
req.on("data", function (data) {
|
||||
body += data;
|
||||
});
|
||||
req.on("end", function() {
|
||||
req.on("end", function () {
|
||||
if (pathname === "/ttx") {
|
||||
var translateFont = require("./font/ttxdriver.js").translateFont;
|
||||
var onCancel = null,
|
||||
ttxTimeout = 10000;
|
||||
var timeoutId = setTimeout(function() {
|
||||
var timeoutId = setTimeout(function () {
|
||||
if (onCancel) {
|
||||
onCancel("TTX timeout");
|
||||
}
|
||||
}, ttxTimeout);
|
||||
translateFont(
|
||||
body,
|
||||
function(fn) {
|
||||
function (fn) {
|
||||
onCancel = fn;
|
||||
},
|
||||
function(err, xml) {
|
||||
function (err, xml) {
|
||||
clearTimeout(timeoutId);
|
||||
res.writeHead(200, { "Content-Type": "text/xml" });
|
||||
res.end(err ? "<error>" + err + "</error>" : xml);
|
||||
|
@ -797,7 +797,7 @@ function startBrowsers(testUrl, initSessionCallback) {
|
|||
process.exit(1);
|
||||
}
|
||||
sessions = [];
|
||||
browsers.forEach(function(b) {
|
||||
browsers.forEach(function (b) {
|
||||
var browser = WebBrowser.create(b);
|
||||
var startUrl =
|
||||
getServerBaseAddress() +
|
||||
|
@ -846,7 +846,7 @@ function stopServer() {
|
|||
}
|
||||
|
||||
function getSession(browser) {
|
||||
return sessions.filter(function(session) {
|
||||
return sessions.filter(function (session) {
|
||||
return session.name === browser;
|
||||
})[0];
|
||||
}
|
||||
|
@ -858,9 +858,9 @@ function closeSession(browser) {
|
|||
}
|
||||
if (i < sessions.length) {
|
||||
var session = sessions[i];
|
||||
session.browser.stop(function() {
|
||||
session.browser.stop(function () {
|
||||
session.closed = true;
|
||||
var allClosed = sessions.every(function(s) {
|
||||
var allClosed = sessions.every(function (s) {
|
||||
return s.closed;
|
||||
});
|
||||
if (allClosed && onAllSessionsClosed) {
|
||||
|
@ -873,8 +873,8 @@ function closeSession(browser) {
|
|||
function ensurePDFsDownloaded(callback) {
|
||||
var downloadUtils = require("./downloadutils.js");
|
||||
var manifest = getTestManifest();
|
||||
downloadUtils.downloadManifestFiles(manifest, function() {
|
||||
downloadUtils.verifyManifestFiles(manifest, function(hasErrors) {
|
||||
downloadUtils.downloadManifestFiles(manifest, function () {
|
||||
downloadUtils.verifyManifestFiles(manifest, function (hasErrors) {
|
||||
if (hasErrors) {
|
||||
console.log(
|
||||
"Unable to verify the checksum for the files that are " +
|
||||
|
@ -899,12 +899,12 @@ function main() {
|
|||
}
|
||||
|
||||
if (options.downloadOnly) {
|
||||
ensurePDFsDownloaded(function() {});
|
||||
ensurePDFsDownloaded(function () {});
|
||||
} else if (!options.browser && !options.browserManifestFile) {
|
||||
startServer();
|
||||
} else if (options.unitTest) {
|
||||
// Allows linked PDF files in unit-tests as well.
|
||||
ensurePDFsDownloaded(function() {
|
||||
ensurePDFsDownloaded(function () {
|
||||
startUnitTest("/test/unit/unit_test.html", "unit");
|
||||
});
|
||||
} else if (options.fontTest) {
|
||||
|
|
|
@ -32,7 +32,7 @@ exports.copySubtreeSync = function copySubtreeSync(src, dest) {
|
|||
if (!fs.existsSync(dest)) {
|
||||
fs.mkdirSync(dest);
|
||||
}
|
||||
files.forEach(function(filename) {
|
||||
files.forEach(function (filename) {
|
||||
var srcFile = path.join(src, filename);
|
||||
var file = path.join(dest, filename);
|
||||
var stats = fs.statSync(srcFile);
|
||||
|
@ -99,12 +99,12 @@ function handleStdinBuffer() {
|
|||
function initStdin() {
|
||||
process.stdin.setEncoding("utf8");
|
||||
|
||||
process.stdin.on("data", function(chunk) {
|
||||
process.stdin.on("data", function (chunk) {
|
||||
stdinBuffer += chunk;
|
||||
handleStdinBuffer();
|
||||
});
|
||||
|
||||
process.stdin.on("end", function() {
|
||||
process.stdin.on("end", function () {
|
||||
endOfStdin = true;
|
||||
handleStdinBuffer();
|
||||
});
|
||||
|
@ -125,7 +125,7 @@ exports.prompt = function prompt(message, callback) {
|
|||
};
|
||||
|
||||
exports.confirm = function confirm(message, callback) {
|
||||
exports.prompt(message, function(answer) {
|
||||
exports.prompt(message, function (answer) {
|
||||
if (answer === undefined) {
|
||||
callback();
|
||||
return;
|
||||
|
|
|
@ -33,14 +33,14 @@ import { Dict, Name, Ref } from "../../src/core/primitives.js";
|
|||
import { Lexer, Parser } from "../../src/core/parser.js";
|
||||
import { StringStream } from "../../src/core/stream.js";
|
||||
|
||||
describe("annotation", function() {
|
||||
describe("annotation", function () {
|
||||
class PDFManagerMock {
|
||||
constructor(params) {
|
||||
this.docBaseUrl = params.docBaseUrl || null;
|
||||
}
|
||||
|
||||
ensure(obj, prop, args) {
|
||||
return new Promise(function(resolve) {
|
||||
return new Promise(function (resolve) {
|
||||
const value = obj[prop];
|
||||
if (typeof value === "function") {
|
||||
resolve(value.apply(obj, args));
|
||||
|
@ -53,7 +53,7 @@ describe("annotation", function() {
|
|||
|
||||
let pdfManagerMock, idFactoryMock;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
pdfManagerMock = new PDFManagerMock({
|
||||
docBaseUrl: null,
|
||||
});
|
||||
|
@ -61,13 +61,13 @@ describe("annotation", function() {
|
|||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
pdfManagerMock = null;
|
||||
idFactoryMock = null;
|
||||
});
|
||||
|
||||
describe("AnnotationFactory", function() {
|
||||
it("should get id for annotation", function(done) {
|
||||
describe("AnnotationFactory", function () {
|
||||
it("should get id for annotation", function (done) {
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
annotationDict.set("Subtype", Name.get("Link"));
|
||||
|
@ -90,7 +90,7 @@ describe("annotation", function() {
|
|||
it(
|
||||
"should handle, and get fallback IDs for, annotations that are not " +
|
||||
"indirect objects (issue 7569)",
|
||||
function(done) {
|
||||
function (done) {
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
annotationDict.set("Subtype", Name.get("Link"));
|
||||
|
@ -122,7 +122,7 @@ describe("annotation", function() {
|
|||
}
|
||||
);
|
||||
|
||||
it("should handle missing /Subtype", function(done) {
|
||||
it("should handle missing /Subtype", function (done) {
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
|
||||
|
@ -141,35 +141,35 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("getQuadPoints", function() {
|
||||
describe("getQuadPoints", function () {
|
||||
let dict, rect;
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
dict = new Dict();
|
||||
rect = [];
|
||||
done();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
dict = null;
|
||||
rect = null;
|
||||
});
|
||||
|
||||
it("should ignore missing quadpoints", function() {
|
||||
it("should ignore missing quadpoints", function () {
|
||||
expect(getQuadPoints(dict, rect)).toEqual(null);
|
||||
});
|
||||
|
||||
it("should ignore non-array values", function() {
|
||||
it("should ignore non-array values", function () {
|
||||
dict.set("QuadPoints", "foo");
|
||||
expect(getQuadPoints(dict, rect)).toEqual(null);
|
||||
});
|
||||
|
||||
it("should ignore arrays where the length is not a multiple of eight", function() {
|
||||
it("should ignore arrays where the length is not a multiple of eight", function () {
|
||||
dict.set("QuadPoints", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
||||
expect(getQuadPoints(dict, rect)).toEqual(null);
|
||||
});
|
||||
|
||||
it("should ignore quadpoints if one coordinate lies outside the rectangle", function() {
|
||||
it("should ignore quadpoints if one coordinate lies outside the rectangle", function () {
|
||||
rect = [10, 10, 20, 20];
|
||||
const inputs = [
|
||||
[11, 11, 12, 12, 9, 13, 14, 14], // Smaller than lower x coordinate.
|
||||
|
@ -183,7 +183,7 @@ describe("annotation", function() {
|
|||
}
|
||||
});
|
||||
|
||||
it("should process valid quadpoints arrays", function() {
|
||||
it("should process valid quadpoints arrays", function () {
|
||||
rect = [10, 10, 20, 20];
|
||||
dict.set("QuadPoints", [
|
||||
11,
|
||||
|
@ -220,48 +220,48 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Annotation", function() {
|
||||
describe("Annotation", function () {
|
||||
let dict, ref;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
dict = new Dict();
|
||||
ref = Ref.get(1, 0);
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
dict = ref = null;
|
||||
});
|
||||
|
||||
it("should set and get valid contents", function() {
|
||||
it("should set and get valid contents", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setContents("Foo bar baz");
|
||||
|
||||
expect(annotation.contents).toEqual("Foo bar baz");
|
||||
});
|
||||
|
||||
it("should not set and get invalid contents", function() {
|
||||
it("should not set and get invalid contents", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setContents(undefined);
|
||||
|
||||
expect(annotation.contents).toEqual("");
|
||||
});
|
||||
|
||||
it("should set and get a valid modification date", function() {
|
||||
it("should set and get a valid modification date", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setModificationDate("D:20190422");
|
||||
|
||||
expect(annotation.modificationDate).toEqual("D:20190422");
|
||||
});
|
||||
|
||||
it("should not set and get an invalid modification date", function() {
|
||||
it("should not set and get an invalid modification date", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setModificationDate(undefined);
|
||||
|
||||
expect(annotation.modificationDate).toEqual(null);
|
||||
});
|
||||
|
||||
it("should set and get flags", function() {
|
||||
it("should set and get flags", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setFlags(13);
|
||||
|
||||
|
@ -271,63 +271,63 @@ describe("annotation", function() {
|
|||
expect(annotation.hasFlag(AnnotationFlag.READONLY)).toEqual(false);
|
||||
});
|
||||
|
||||
it("should be viewable and not printable by default", function() {
|
||||
it("should be viewable and not printable by default", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
|
||||
expect(annotation.viewable).toEqual(true);
|
||||
expect(annotation.printable).toEqual(false);
|
||||
});
|
||||
|
||||
it("should set and get a valid rectangle", function() {
|
||||
it("should set and get a valid rectangle", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setRectangle([117, 694, 164.298, 720]);
|
||||
|
||||
expect(annotation.rectangle).toEqual([117, 694, 164.298, 720]);
|
||||
});
|
||||
|
||||
it("should not set and get an invalid rectangle", function() {
|
||||
it("should not set and get an invalid rectangle", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setRectangle([117, 694, 164.298]);
|
||||
|
||||
expect(annotation.rectangle).toEqual([0, 0, 0, 0]);
|
||||
});
|
||||
|
||||
it("should reject a color if it is not an array", function() {
|
||||
it("should reject a color if it is not an array", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setColor("red");
|
||||
|
||||
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
|
||||
});
|
||||
|
||||
it("should set and get a transparent color", function() {
|
||||
it("should set and get a transparent color", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setColor([]);
|
||||
|
||||
expect(annotation.color).toEqual(null);
|
||||
});
|
||||
|
||||
it("should set and get a grayscale color", function() {
|
||||
it("should set and get a grayscale color", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setColor([0.4]);
|
||||
|
||||
expect(annotation.color).toEqual(new Uint8ClampedArray([102, 102, 102]));
|
||||
});
|
||||
|
||||
it("should set and get an RGB color", function() {
|
||||
it("should set and get an RGB color", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setColor([0, 0, 1]);
|
||||
|
||||
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
||||
});
|
||||
|
||||
it("should set and get a CMYK color", function() {
|
||||
it("should set and get a CMYK color", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setColor([0.1, 0.92, 0.84, 0.02]);
|
||||
|
||||
expect(annotation.color).toEqual(new Uint8ClampedArray([234, 59, 48]));
|
||||
});
|
||||
|
||||
it("should not set and get an invalid color", function() {
|
||||
it("should not set and get an invalid color", function () {
|
||||
const annotation = new Annotation({ dict, ref });
|
||||
annotation.setColor([0.4, 0.6]);
|
||||
|
||||
|
@ -335,22 +335,22 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("AnnotationBorderStyle", function() {
|
||||
it("should set and get a valid width", function() {
|
||||
describe("AnnotationBorderStyle", function () {
|
||||
it("should set and get a valid width", function () {
|
||||
const borderStyle = new AnnotationBorderStyle();
|
||||
borderStyle.setWidth(3);
|
||||
|
||||
expect(borderStyle.width).toEqual(3);
|
||||
});
|
||||
|
||||
it("should not set and get an invalid width", function() {
|
||||
it("should not set and get an invalid width", function () {
|
||||
const borderStyle = new AnnotationBorderStyle();
|
||||
borderStyle.setWidth("three");
|
||||
|
||||
expect(borderStyle.width).toEqual(1);
|
||||
});
|
||||
|
||||
it("should set the width to zero, when the input is a `Name` (issue 10385)", function() {
|
||||
it("should set the width to zero, when the input is a `Name` (issue 10385)", function () {
|
||||
const borderStyleZero = new AnnotationBorderStyle();
|
||||
borderStyleZero.setWidth(Name.get("0"));
|
||||
const borderStyleFive = new AnnotationBorderStyle();
|
||||
|
@ -360,56 +360,56 @@ describe("annotation", function() {
|
|||
expect(borderStyleFive.width).toEqual(0);
|
||||
});
|
||||
|
||||
it("should set and get a valid style", function() {
|
||||
it("should set and get a valid style", function () {
|
||||
const borderStyle = new AnnotationBorderStyle();
|
||||
borderStyle.setStyle(Name.get("D"));
|
||||
|
||||
expect(borderStyle.style).toEqual(AnnotationBorderStyleType.DASHED);
|
||||
});
|
||||
|
||||
it("should not set and get an invalid style", function() {
|
||||
it("should not set and get an invalid style", function () {
|
||||
const borderStyle = new AnnotationBorderStyle();
|
||||
borderStyle.setStyle("Dashed");
|
||||
|
||||
expect(borderStyle.style).toEqual(AnnotationBorderStyleType.SOLID);
|
||||
});
|
||||
|
||||
it("should set and get a valid dash array", function() {
|
||||
it("should set and get a valid dash array", function () {
|
||||
const borderStyle = new AnnotationBorderStyle();
|
||||
borderStyle.setDashArray([1, 2, 3]);
|
||||
|
||||
expect(borderStyle.dashArray).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
it("should not set and get an invalid dash array", function() {
|
||||
it("should not set and get an invalid dash array", function () {
|
||||
const borderStyle = new AnnotationBorderStyle();
|
||||
borderStyle.setDashArray([0, 0]);
|
||||
|
||||
expect(borderStyle.dashArray).toEqual([3]);
|
||||
});
|
||||
|
||||
it("should set and get a valid horizontal corner radius", function() {
|
||||
it("should set and get a valid horizontal corner radius", function () {
|
||||
const borderStyle = new AnnotationBorderStyle();
|
||||
borderStyle.setHorizontalCornerRadius(3);
|
||||
|
||||
expect(borderStyle.horizontalCornerRadius).toEqual(3);
|
||||
});
|
||||
|
||||
it("should not set and get an invalid horizontal corner radius", function() {
|
||||
it("should not set and get an invalid horizontal corner radius", function () {
|
||||
const borderStyle = new AnnotationBorderStyle();
|
||||
borderStyle.setHorizontalCornerRadius("three");
|
||||
|
||||
expect(borderStyle.horizontalCornerRadius).toEqual(0);
|
||||
});
|
||||
|
||||
it("should set and get a valid vertical corner radius", function() {
|
||||
it("should set and get a valid vertical corner radius", function () {
|
||||
const borderStyle = new AnnotationBorderStyle();
|
||||
borderStyle.setVerticalCornerRadius(3);
|
||||
|
||||
expect(borderStyle.verticalCornerRadius).toEqual(3);
|
||||
});
|
||||
|
||||
it("should not set and get an invalid vertical corner radius", function() {
|
||||
it("should not set and get an invalid vertical corner radius", function () {
|
||||
const borderStyle = new AnnotationBorderStyle();
|
||||
borderStyle.setVerticalCornerRadius("three");
|
||||
|
||||
|
@ -417,34 +417,34 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("MarkupAnnotation", function() {
|
||||
describe("MarkupAnnotation", function () {
|
||||
let dict, ref;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
dict = new Dict();
|
||||
ref = Ref.get(1, 0);
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
dict = ref = null;
|
||||
});
|
||||
|
||||
it("should set and get a valid creation date", function() {
|
||||
it("should set and get a valid creation date", function () {
|
||||
const markupAnnotation = new MarkupAnnotation({ dict, ref });
|
||||
markupAnnotation.setCreationDate("D:20190422");
|
||||
|
||||
expect(markupAnnotation.creationDate).toEqual("D:20190422");
|
||||
});
|
||||
|
||||
it("should not set and get an invalid creation date", function() {
|
||||
it("should not set and get an invalid creation date", function () {
|
||||
const markupAnnotation = new MarkupAnnotation({ dict, ref });
|
||||
markupAnnotation.setCreationDate(undefined);
|
||||
|
||||
expect(markupAnnotation.creationDate).toEqual(null);
|
||||
});
|
||||
|
||||
it("should not parse IRT/RT when not defined", function(done) {
|
||||
it("should not parse IRT/RT when not defined", function (done) {
|
||||
dict.set("Type", Name.get("Annot"));
|
||||
dict.set("Subtype", Name.get("Text"));
|
||||
|
||||
|
@ -460,7 +460,7 @@ describe("annotation", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("should parse IRT and set default RT when not defined.", function(done) {
|
||||
it("should parse IRT and set default RT when not defined.", function (done) {
|
||||
const annotationRef = Ref.get(819, 0);
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
|
@ -491,7 +491,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should parse IRT/RT for a group type", function(done) {
|
||||
it("should parse IRT/RT for a group type", function (done) {
|
||||
const annotationRef = Ref.get(819, 0);
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
|
@ -548,7 +548,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should parse IRT/RT for a reply type", function(done) {
|
||||
it("should parse IRT/RT for a reply type", function (done) {
|
||||
const annotationRef = Ref.get(819, 0);
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
|
@ -606,8 +606,8 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("TextAnnotation", function() {
|
||||
it("should not parse state model and state when not defined", function(done) {
|
||||
describe("TextAnnotation", function () {
|
||||
it("should not parse state model and state when not defined", function (done) {
|
||||
const annotationRef = Ref.get(819, 0);
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
|
@ -641,7 +641,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should correctly parse state model and state when defined", function(done) {
|
||||
it("should correctly parse state model and state when defined", function (done) {
|
||||
const annotationRef = Ref.get(819, 0);
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
|
@ -676,8 +676,8 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("LinkAnnotation", function() {
|
||||
it("should correctly parse a URI action", function(done) {
|
||||
describe("LinkAnnotation", function () {
|
||||
it("should correctly parse a URI action", function (done) {
|
||||
const actionDict = new Dict();
|
||||
actionDict.set("Type", Name.get("Action"));
|
||||
actionDict.set("S", Name.get("URI"));
|
||||
|
@ -710,7 +710,7 @@ describe("annotation", function() {
|
|||
it(
|
||||
"should correctly parse a URI action, where the URI entry " +
|
||||
"is missing a protocol",
|
||||
function(done) {
|
||||
function (done) {
|
||||
const actionDict = new Dict();
|
||||
actionDict.set("Type", Name.get("Action"));
|
||||
actionDict.set("S", Name.get("URI"));
|
||||
|
@ -744,7 +744,7 @@ describe("annotation", function() {
|
|||
it(
|
||||
"should correctly parse a URI action, where the URI entry " +
|
||||
"has an incorrect encoding (bug 1122280)",
|
||||
function(done) {
|
||||
function (done) {
|
||||
const actionStream = new StringStream(
|
||||
"<<\n" +
|
||||
"/Type /Action\n" +
|
||||
|
@ -793,7 +793,7 @@ describe("annotation", function() {
|
|||
}
|
||||
);
|
||||
|
||||
it("should correctly parse a GoTo action", function(done) {
|
||||
it("should correctly parse a GoTo action", function (done) {
|
||||
const actionDict = new Dict();
|
||||
actionDict.set("Type", Name.get("Action"));
|
||||
actionDict.set("S", Name.get("GoTo"));
|
||||
|
@ -824,7 +824,7 @@ describe("annotation", function() {
|
|||
it(
|
||||
"should correctly parse a GoToR action, where the FileSpec entry " +
|
||||
"is a string containing a relative URL",
|
||||
function(done) {
|
||||
function (done) {
|
||||
const actionDict = new Dict();
|
||||
actionDict.set("Type", Name.get("Action"));
|
||||
actionDict.set("S", Name.get("GoToR"));
|
||||
|
@ -861,7 +861,7 @@ describe("annotation", function() {
|
|||
it(
|
||||
"should correctly parse a GoToR action, containing a relative URL, " +
|
||||
'with the "docBaseUrl" parameter specified',
|
||||
function(done) {
|
||||
function (done) {
|
||||
const actionDict = new Dict();
|
||||
actionDict.set("Type", Name.get("Action"));
|
||||
actionDict.set("S", Name.get("GoToR"));
|
||||
|
@ -898,7 +898,7 @@ describe("annotation", function() {
|
|||
}
|
||||
);
|
||||
|
||||
it("should correctly parse a GoToR action, with named destination", function(done) {
|
||||
it("should correctly parse a GoToR action, with named destination", function (done) {
|
||||
const actionDict = new Dict();
|
||||
actionDict.set("Type", Name.get("Action"));
|
||||
actionDict.set("S", Name.get("GoToR"));
|
||||
|
@ -928,7 +928,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should correctly parse a GoToR action, with explicit destination array", function(done) {
|
||||
it("should correctly parse a GoToR action, with explicit destination array", function (done) {
|
||||
const actionDict = new Dict();
|
||||
actionDict.set("Type", Name.get("Action"));
|
||||
actionDict.set("S", Name.get("GoToR"));
|
||||
|
@ -969,7 +969,7 @@ describe("annotation", function() {
|
|||
it(
|
||||
"should correctly parse a Launch action, where the FileSpec dict " +
|
||||
'contains a relative URL, with the "docBaseUrl" parameter specified',
|
||||
function(done) {
|
||||
function (done) {
|
||||
const fileSpecDict = new Dict();
|
||||
fileSpecDict.set("Type", Name.get("FileSpec"));
|
||||
fileSpecDict.set("F", "Part II/Part II.pdf");
|
||||
|
@ -1015,7 +1015,7 @@ describe("annotation", function() {
|
|||
it(
|
||||
"should recover valid URLs from JavaScript actions having certain " +
|
||||
"white-listed formats",
|
||||
function(done) {
|
||||
function (done) {
|
||||
function checkJsAction(params) {
|
||||
const jsEntry = params.jsEntry;
|
||||
const expectedUrl = params.expectedUrl;
|
||||
|
@ -1084,7 +1084,7 @@ describe("annotation", function() {
|
|||
}
|
||||
);
|
||||
|
||||
it("should correctly parse a Named action", function(done) {
|
||||
it("should correctly parse a Named action", function (done) {
|
||||
const actionDict = new Dict();
|
||||
actionDict.set("Type", Name.get("Action"));
|
||||
actionDict.set("S", Name.get("Named"));
|
||||
|
@ -1112,7 +1112,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should correctly parse a simple Dest", function(done) {
|
||||
it("should correctly parse a simple Dest", function (done) {
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
annotationDict.set("Subtype", Name.get("Link"));
|
||||
|
@ -1135,7 +1135,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should correctly parse a simple Dest, with explicit destination array", function(done) {
|
||||
it("should correctly parse a simple Dest, with explicit destination array", function (done) {
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
annotationDict.set("Subtype", Name.get("Link"));
|
||||
|
@ -1173,7 +1173,7 @@ describe("annotation", function() {
|
|||
it(
|
||||
"should correctly parse a Dest, which violates the specification " +
|
||||
"by containing a dictionary",
|
||||
function(done) {
|
||||
function (done) {
|
||||
const destDict = new Dict();
|
||||
destDict.set("Type", Name.get("Action"));
|
||||
destDict.set("S", Name.get("GoTo"));
|
||||
|
@ -1206,7 +1206,7 @@ describe("annotation", function() {
|
|||
}
|
||||
);
|
||||
|
||||
it("should not set quadpoints if not defined", function(done) {
|
||||
it("should not set quadpoints if not defined", function (done) {
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
annotationDict.set("Subtype", Name.get("Link"));
|
||||
|
@ -1226,7 +1226,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should set quadpoints if defined", function(done) {
|
||||
it("should set quadpoints if defined", function (done) {
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
annotationDict.set("Subtype", Name.get("Link"));
|
||||
|
@ -1256,21 +1256,21 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("WidgetAnnotation", function() {
|
||||
describe("WidgetAnnotation", function () {
|
||||
let widgetDict;
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
widgetDict = new Dict();
|
||||
widgetDict.set("Type", Name.get("Annot"));
|
||||
widgetDict.set("Subtype", Name.get("Widget"));
|
||||
done();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
widgetDict = null;
|
||||
});
|
||||
|
||||
it("should handle unknown field names", function(done) {
|
||||
it("should handle unknown field names", function (done) {
|
||||
const widgetRef = Ref.get(20, 0);
|
||||
const xref = new XRefMock([{ ref: widgetRef, data: widgetDict }]);
|
||||
|
||||
|
@ -1286,7 +1286,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should construct the field name when there are no ancestors", function(done) {
|
||||
it("should construct the field name when there are no ancestors", function (done) {
|
||||
widgetDict.set("T", "foo");
|
||||
|
||||
const widgetRef = Ref.get(21, 0);
|
||||
|
@ -1304,7 +1304,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should construct the field name when there are ancestors", function(done) {
|
||||
it("should construct the field name when there are ancestors", function (done) {
|
||||
const firstParent = new Dict();
|
||||
firstParent.set("T", "foo");
|
||||
|
||||
|
@ -1333,7 +1333,7 @@ describe("annotation", function() {
|
|||
it(
|
||||
"should construct the field name if a parent is not a dictionary " +
|
||||
"(issue 8143)",
|
||||
function(done) {
|
||||
function (done) {
|
||||
const parentDict = new Dict();
|
||||
parentDict.set("Parent", null);
|
||||
parentDict.set("T", "foo");
|
||||
|
@ -1358,10 +1358,10 @@ describe("annotation", function() {
|
|||
);
|
||||
});
|
||||
|
||||
describe("TextWidgetAnnotation", function() {
|
||||
describe("TextWidgetAnnotation", function () {
|
||||
let textWidgetDict;
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
textWidgetDict = new Dict();
|
||||
textWidgetDict.set("Type", Name.get("Annot"));
|
||||
textWidgetDict.set("Subtype", Name.get("Widget"));
|
||||
|
@ -1369,11 +1369,11 @@ describe("annotation", function() {
|
|||
done();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
textWidgetDict = null;
|
||||
});
|
||||
|
||||
it("should handle unknown text alignment, maximum length and flags", function(done) {
|
||||
it("should handle unknown text alignment, maximum length and flags", function (done) {
|
||||
const textWidgetRef = Ref.get(124, 0);
|
||||
const xref = new XRefMock([{ ref: textWidgetRef, data: textWidgetDict }]);
|
||||
|
||||
|
@ -1393,7 +1393,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should not set invalid text alignment, maximum length and flags", function(done) {
|
||||
it("should not set invalid text alignment, maximum length and flags", function (done) {
|
||||
textWidgetDict.set("Q", "center");
|
||||
textWidgetDict.set("MaxLen", "five");
|
||||
textWidgetDict.set("Ff", "readonly");
|
||||
|
@ -1417,7 +1417,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should set valid text alignment, maximum length and flags", function(done) {
|
||||
it("should set valid text alignment, maximum length and flags", function (done) {
|
||||
textWidgetDict.set("Q", 1);
|
||||
textWidgetDict.set("MaxLen", 20);
|
||||
textWidgetDict.set(
|
||||
|
@ -1443,7 +1443,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should reject comb fields without a maximum length", function(done) {
|
||||
it("should reject comb fields without a maximum length", function (done) {
|
||||
textWidgetDict.set("Ff", AnnotationFieldFlag.COMB);
|
||||
|
||||
const textWidgetRef = Ref.get(46, 0);
|
||||
|
@ -1461,7 +1461,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should accept comb fields with a maximum length", function(done) {
|
||||
it("should accept comb fields with a maximum length", function (done) {
|
||||
textWidgetDict.set("MaxLen", 20);
|
||||
textWidgetDict.set("Ff", AnnotationFieldFlag.COMB);
|
||||
|
||||
|
@ -1480,7 +1480,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should only accept comb fields when the flags are valid", function(done) {
|
||||
it("should only accept comb fields when the flags are valid", function (done) {
|
||||
const invalidFieldFlags = [
|
||||
AnnotationFieldFlag.MULTILINE,
|
||||
AnnotationFieldFlag.PASSWORD,
|
||||
|
@ -1528,10 +1528,10 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("ButtonWidgetAnnotation", function() {
|
||||
describe("ButtonWidgetAnnotation", function () {
|
||||
let buttonWidgetDict;
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
buttonWidgetDict = new Dict();
|
||||
buttonWidgetDict.set("Type", Name.get("Annot"));
|
||||
buttonWidgetDict.set("Subtype", Name.get("Widget"));
|
||||
|
@ -1539,11 +1539,11 @@ describe("annotation", function() {
|
|||
done();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
buttonWidgetDict = null;
|
||||
});
|
||||
|
||||
it("should handle checkboxes with export value", function(done) {
|
||||
it("should handle checkboxes with export value", function (done) {
|
||||
buttonWidgetDict.set("V", Name.get("1"));
|
||||
|
||||
const appearanceStatesDict = new Dict();
|
||||
|
@ -1574,7 +1574,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should handle checkboxes without export value", function(done) {
|
||||
it("should handle checkboxes without export value", function (done) {
|
||||
buttonWidgetDict.set("V", Name.get("1"));
|
||||
|
||||
const buttonWidgetRef = Ref.get(124, 0);
|
||||
|
@ -1596,7 +1596,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should handle radio buttons with a field value", function(done) {
|
||||
it("should handle radio buttons with a field value", function (done) {
|
||||
const parentDict = new Dict();
|
||||
parentDict.set("V", Name.get("1"));
|
||||
|
||||
|
@ -1630,7 +1630,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should handle radio buttons without a field value", function(done) {
|
||||
it("should handle radio buttons without a field value", function (done) {
|
||||
const normalAppearanceStateDict = new Dict();
|
||||
normalAppearanceStateDict.set("2", null);
|
||||
|
||||
|
@ -1661,10 +1661,10 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("ChoiceWidgetAnnotation", function() {
|
||||
describe("ChoiceWidgetAnnotation", function () {
|
||||
let choiceWidgetDict;
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
choiceWidgetDict = new Dict();
|
||||
choiceWidgetDict.set("Type", Name.get("Annot"));
|
||||
choiceWidgetDict.set("Subtype", Name.get("Widget"));
|
||||
|
@ -1672,11 +1672,11 @@ describe("annotation", function() {
|
|||
done();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
choiceWidgetDict = null;
|
||||
});
|
||||
|
||||
it("should handle missing option arrays", function(done) {
|
||||
it("should handle missing option arrays", function (done) {
|
||||
const choiceWidgetRef = Ref.get(122, 0);
|
||||
const xref = new XRefMock([
|
||||
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
||||
|
@ -1694,7 +1694,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should handle option arrays with array elements", function(done) {
|
||||
it("should handle option arrays with array elements", function (done) {
|
||||
const optionBarRef = Ref.get(20, 0);
|
||||
const optionBarStr = "Bar";
|
||||
const optionOneRef = Ref.get(10, 0);
|
||||
|
@ -1727,7 +1727,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should handle option arrays with string elements", function(done) {
|
||||
it("should handle option arrays with string elements", function (done) {
|
||||
const optionBarRef = Ref.get(10, 0);
|
||||
const optionBarStr = "Bar";
|
||||
|
||||
|
@ -1757,7 +1757,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should handle inherited option arrays (issue 8094)", function(done) {
|
||||
it("should handle inherited option arrays (issue 8094)", function (done) {
|
||||
const options = [
|
||||
["Value1", "Description1"],
|
||||
["Value2", "Description2"],
|
||||
|
@ -1789,7 +1789,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should sanitize display values in option arrays (issue 8947)", function(done) {
|
||||
it("should sanitize display values in option arrays (issue 8947)", function (done) {
|
||||
// The option value is a UTF-16BE string. The display value should be
|
||||
// sanitized, but the export value should remain the same since that
|
||||
// may be used as a unique identifier when exporting form values.
|
||||
|
@ -1817,7 +1817,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should handle array field values", function(done) {
|
||||
it("should handle array field values", function (done) {
|
||||
const fieldValue = ["Foo", "Bar"];
|
||||
|
||||
choiceWidgetDict.set("V", fieldValue);
|
||||
|
@ -1839,7 +1839,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should handle string field values", function(done) {
|
||||
it("should handle string field values", function (done) {
|
||||
const fieldValue = "Foo";
|
||||
|
||||
choiceWidgetDict.set("V", fieldValue);
|
||||
|
@ -1861,7 +1861,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should handle unknown flags", function(done) {
|
||||
it("should handle unknown flags", function (done) {
|
||||
const choiceWidgetRef = Ref.get(166, 0);
|
||||
const xref = new XRefMock([
|
||||
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
||||
|
@ -1881,7 +1881,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should not set invalid flags", function(done) {
|
||||
it("should not set invalid flags", function (done) {
|
||||
choiceWidgetDict.set("Ff", "readonly");
|
||||
|
||||
const choiceWidgetRef = Ref.get(165, 0);
|
||||
|
@ -1903,7 +1903,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should set valid flags", function(done) {
|
||||
it("should set valid flags", function (done) {
|
||||
choiceWidgetDict.set(
|
||||
"Ff",
|
||||
AnnotationFieldFlag.READONLY +
|
||||
|
@ -1931,8 +1931,8 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("LineAnnotation", function() {
|
||||
it("should set the line coordinates", function(done) {
|
||||
describe("LineAnnotation", function () {
|
||||
it("should set the line coordinates", function (done) {
|
||||
const lineDict = new Dict();
|
||||
lineDict.set("Type", Name.get("Annot"));
|
||||
lineDict.set("Subtype", Name.get("Line"));
|
||||
|
@ -1954,8 +1954,8 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("FileAttachmentAnnotation", function() {
|
||||
it("should correctly parse a file attachment", function(done) {
|
||||
describe("FileAttachmentAnnotation", function () {
|
||||
it("should correctly parse a file attachment", function (done) {
|
||||
const fileStream = new StringStream(
|
||||
"<<\n" +
|
||||
"/Type /EmbeddedFile\n" +
|
||||
|
@ -2015,8 +2015,8 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("PopupAnnotation", function() {
|
||||
it("should inherit properties from its parent", function(done) {
|
||||
describe("PopupAnnotation", function () {
|
||||
it("should inherit properties from its parent", function (done) {
|
||||
const parentDict = new Dict();
|
||||
parentDict.set("Type", Name.get("Annot"));
|
||||
parentDict.set("Subtype", Name.get("Text"));
|
||||
|
@ -2044,7 +2044,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should handle missing parent properties", function(done) {
|
||||
it("should handle missing parent properties", function (done) {
|
||||
const parentDict = new Dict();
|
||||
parentDict.set("Type", Name.get("Annot"));
|
||||
parentDict.set("Subtype", Name.get("Text"));
|
||||
|
@ -2073,7 +2073,7 @@ describe("annotation", function() {
|
|||
it(
|
||||
"should inherit the parent flags when the Popup is not viewable, " +
|
||||
"but the parent is (PR 7352)",
|
||||
function(done) {
|
||||
function (done) {
|
||||
const parentDict = new Dict();
|
||||
parentDict.set("Type", Name.get("Annot"));
|
||||
parentDict.set("Subtype", Name.get("Text"));
|
||||
|
@ -2108,7 +2108,7 @@ describe("annotation", function() {
|
|||
it(
|
||||
"should correctly inherit Contents from group-master annotation " +
|
||||
"if parent has ReplyType == Group",
|
||||
function(done) {
|
||||
function (done) {
|
||||
const annotationRef = Ref.get(819, 0);
|
||||
const annotationDict = new Dict();
|
||||
annotationDict.set("Type", Name.get("Annot"));
|
||||
|
@ -2165,8 +2165,8 @@ describe("annotation", function() {
|
|||
);
|
||||
});
|
||||
|
||||
describe("InkAnnotation", function() {
|
||||
it("should handle a single ink list", function(done) {
|
||||
describe("InkAnnotation", function () {
|
||||
it("should handle a single ink list", function (done) {
|
||||
const inkDict = new Dict();
|
||||
inkDict.set("Type", Name.get("Annot"));
|
||||
inkDict.set("Subtype", Name.get("Ink"));
|
||||
|
@ -2193,7 +2193,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should handle multiple ink lists", function(done) {
|
||||
it("should handle multiple ink lists", function (done) {
|
||||
const inkDict = new Dict();
|
||||
inkDict.set("Type", Name.get("Annot"));
|
||||
inkDict.set("Subtype", Name.get("Ink"));
|
||||
|
@ -2226,8 +2226,8 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("HightlightAnnotation", function() {
|
||||
it("should not set quadpoints if not defined", function(done) {
|
||||
describe("HightlightAnnotation", function () {
|
||||
it("should not set quadpoints if not defined", function (done) {
|
||||
const highlightDict = new Dict();
|
||||
highlightDict.set("Type", Name.get("Annot"));
|
||||
highlightDict.set("Subtype", Name.get("Highlight"));
|
||||
|
@ -2247,7 +2247,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should set quadpoints if defined", function(done) {
|
||||
it("should set quadpoints if defined", function (done) {
|
||||
const highlightDict = new Dict();
|
||||
highlightDict.set("Type", Name.get("Annot"));
|
||||
highlightDict.set("Subtype", Name.get("Highlight"));
|
||||
|
@ -2277,8 +2277,8 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("UnderlineAnnotation", function() {
|
||||
it("should not set quadpoints if not defined", function(done) {
|
||||
describe("UnderlineAnnotation", function () {
|
||||
it("should not set quadpoints if not defined", function (done) {
|
||||
const underlineDict = new Dict();
|
||||
underlineDict.set("Type", Name.get("Annot"));
|
||||
underlineDict.set("Subtype", Name.get("Underline"));
|
||||
|
@ -2298,7 +2298,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should set quadpoints if defined", function(done) {
|
||||
it("should set quadpoints if defined", function (done) {
|
||||
const underlineDict = new Dict();
|
||||
underlineDict.set("Type", Name.get("Annot"));
|
||||
underlineDict.set("Subtype", Name.get("Underline"));
|
||||
|
@ -2328,8 +2328,8 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("SquigglyAnnotation", function() {
|
||||
it("should not set quadpoints if not defined", function(done) {
|
||||
describe("SquigglyAnnotation", function () {
|
||||
it("should not set quadpoints if not defined", function (done) {
|
||||
const squigglyDict = new Dict();
|
||||
squigglyDict.set("Type", Name.get("Annot"));
|
||||
squigglyDict.set("Subtype", Name.get("Squiggly"));
|
||||
|
@ -2349,7 +2349,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should set quadpoints if defined", function(done) {
|
||||
it("should set quadpoints if defined", function (done) {
|
||||
const squigglyDict = new Dict();
|
||||
squigglyDict.set("Type", Name.get("Annot"));
|
||||
squigglyDict.set("Subtype", Name.get("Squiggly"));
|
||||
|
@ -2379,8 +2379,8 @@ describe("annotation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("StrikeOutAnnotation", function() {
|
||||
it("should not set quadpoints if not defined", function(done) {
|
||||
describe("StrikeOutAnnotation", function () {
|
||||
it("should not set quadpoints if not defined", function (done) {
|
||||
const strikeOutDict = new Dict();
|
||||
strikeOutDict.set("Type", Name.get("Annot"));
|
||||
strikeOutDict.set("Subtype", Name.get("StrikeOut"));
|
||||
|
@ -2400,7 +2400,7 @@ describe("annotation", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should set quadpoints if defined", function(done) {
|
||||
it("should set quadpoints if defined", function (done) {
|
||||
const strikeOutDict = new Dict();
|
||||
strikeOutDict.set("Type", Name.get("Annot"));
|
||||
strikeOutDict.set("Subtype", Name.get("StrikeOut"));
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -15,8 +15,8 @@
|
|||
|
||||
import { bidi } from "../../src/core/bidi.js";
|
||||
|
||||
describe("bidi", function() {
|
||||
it("should mark text as RTL if more than 30% of text is RTL", function() {
|
||||
describe("bidi", function () {
|
||||
it("should mark text as RTL if more than 30% of text is RTL", function () {
|
||||
// 33% of test text are RTL characters
|
||||
var test = "\u0645\u0635\u0631 Egypt";
|
||||
var result = "Egypt \u0631\u0635\u0645";
|
||||
|
@ -26,7 +26,7 @@ describe("bidi", function() {
|
|||
expect(bidiText.dir).toEqual("rtl");
|
||||
});
|
||||
|
||||
it("should mark text as LTR if less than 30% of text is RTL", function() {
|
||||
it("should mark text as LTR if less than 30% of text is RTL", function () {
|
||||
var test = "Egypt is known as \u0645\u0635\u0631 in Arabic.";
|
||||
var result = "Egypt is known as \u0631\u0635\u0645 in Arabic.";
|
||||
var bidiText = bidi(test, -1, false);
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
import { SEAC_ANALYSIS_ENABLED } from "../../src/core/fonts.js";
|
||||
import { Stream } from "../../src/core/stream.js";
|
||||
|
||||
describe("CFFParser", function() {
|
||||
describe("CFFParser", function () {
|
||||
function createWithNullProto(obj) {
|
||||
var result = Object.create(null);
|
||||
for (var i in obj) {
|
||||
|
@ -41,7 +41,7 @@ describe("CFFParser", function() {
|
|||
|
||||
var fontData, parser, cff;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
// This example font comes from the CFF spec:
|
||||
// http://www.adobe.com/content/dam/Adobe/en/devnet/font/pdfs/5176.CFF.pdf
|
||||
var exampleFont =
|
||||
|
@ -64,22 +64,22 @@ describe("CFFParser", function() {
|
|||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
fontData = null;
|
||||
});
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
parser = new CFFParser(fontData, {}, SEAC_ANALYSIS_ENABLED);
|
||||
cff = parser.parse();
|
||||
done();
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function (done) {
|
||||
parser = cff = null;
|
||||
done();
|
||||
});
|
||||
|
||||
it("parses header", function() {
|
||||
it("parses header", function () {
|
||||
var header = cff.header;
|
||||
expect(header.major).toEqual(1);
|
||||
expect(header.minor).toEqual(0);
|
||||
|
@ -87,20 +87,20 @@ describe("CFFParser", function() {
|
|||
expect(header.offSize).toEqual(1);
|
||||
});
|
||||
|
||||
it("parses name index", function() {
|
||||
it("parses name index", function () {
|
||||
var names = cff.names;
|
||||
expect(names.length).toEqual(1);
|
||||
expect(names[0]).toEqual("ABCDEF+Times-Roman");
|
||||
});
|
||||
|
||||
it("parses string index", function() {
|
||||
it("parses string index", function () {
|
||||
var strings = cff.strings;
|
||||
expect(strings.count).toEqual(3);
|
||||
expect(strings.get(0)).toEqual(".notdef");
|
||||
expect(strings.get(391)).toEqual("001.007");
|
||||
});
|
||||
|
||||
it("parses top dict", function() {
|
||||
it("parses top dict", function () {
|
||||
var topDict = cff.topDict;
|
||||
// 391 version 392 FullName 393 FamilyName 389 Weight 28416 UniqueID
|
||||
// -168 -218 1000 898 FontBBox 94 CharStrings 45 102 Private
|
||||
|
@ -114,7 +114,7 @@ describe("CFFParser", function() {
|
|||
expect(topDict.getByName("Private")).toEqual([45, 102]);
|
||||
});
|
||||
|
||||
it("refuses to add topDict key with invalid value (bug 1068432)", function() {
|
||||
it("refuses to add topDict key with invalid value (bug 1068432)", function () {
|
||||
var topDict = cff.topDict;
|
||||
var defaultValue = topDict.getByName("UnderlinePosition");
|
||||
|
||||
|
@ -125,7 +125,7 @@ describe("CFFParser", function() {
|
|||
it(
|
||||
"ignores reserved commands in parseDict, and refuses to add privateDict " +
|
||||
"keys with invalid values (bug 1308536)",
|
||||
function() {
|
||||
function () {
|
||||
// prettier-ignore
|
||||
var bytes = new Uint8Array([
|
||||
64, 39, 31, 30, 252, 114, 137, 115, 79, 30, 197, 119, 2, 99, 127, 6
|
||||
|
@ -134,7 +134,7 @@ describe("CFFParser", function() {
|
|||
var topDict = cff.topDict;
|
||||
topDict.setByName("Private", [bytes.length, 0]);
|
||||
|
||||
var parsePrivateDict = function() {
|
||||
var parsePrivateDict = function () {
|
||||
parser.parsePrivateDict(topDict);
|
||||
};
|
||||
expect(parsePrivateDict).not.toThrow();
|
||||
|
@ -144,7 +144,7 @@ describe("CFFParser", function() {
|
|||
}
|
||||
);
|
||||
|
||||
it("parses a CharString having cntrmask", function() {
|
||||
it("parses a CharString having cntrmask", function () {
|
||||
// prettier-ignore
|
||||
var bytes = new Uint8Array([0, 1, // count
|
||||
1, // offsetSize
|
||||
|
@ -171,7 +171,7 @@ describe("CFFParser", function() {
|
|||
expect(charStrings.get(0).length).toEqual(38);
|
||||
});
|
||||
|
||||
it("parses a CharString endchar with 4 args w/seac enabled", function() {
|
||||
it("parses a CharString endchar with 4 args w/seac enabled", function () {
|
||||
const cffParser = new CFFParser(
|
||||
fontData,
|
||||
{},
|
||||
|
@ -200,7 +200,7 @@ describe("CFFParser", function() {
|
|||
expect(result.seacs[0][3]).toEqual(194);
|
||||
});
|
||||
|
||||
it("parses a CharString endchar with 4 args w/seac disabled", function() {
|
||||
it("parses a CharString endchar with 4 args w/seac disabled", function () {
|
||||
const cffParser = new CFFParser(
|
||||
fontData,
|
||||
{},
|
||||
|
@ -224,7 +224,7 @@ describe("CFFParser", function() {
|
|||
expect(result.seacs.length).toEqual(0);
|
||||
});
|
||||
|
||||
it("parses a CharString endchar no args", function() {
|
||||
it("parses a CharString endchar no args", function () {
|
||||
// prettier-ignore
|
||||
var bytes = new Uint8Array([0, 1, // count
|
||||
1, // offsetSize
|
||||
|
@ -241,12 +241,12 @@ describe("CFFParser", function() {
|
|||
expect(result.seacs.length).toEqual(0);
|
||||
});
|
||||
|
||||
it("parses predefined charsets", function() {
|
||||
it("parses predefined charsets", function () {
|
||||
var charset = parser.parseCharsets(0, 0, null, true);
|
||||
expect(charset.predefined).toEqual(true);
|
||||
});
|
||||
|
||||
it("parses charset format 0", function() {
|
||||
it("parses charset format 0", function () {
|
||||
// The first three bytes make the offset large enough to skip predefined.
|
||||
// prettier-ignore
|
||||
var bytes = new Uint8Array([0x00, 0x00, 0x00,
|
||||
|
@ -262,7 +262,7 @@ describe("CFFParser", function() {
|
|||
expect(charset.charset[1]).toEqual(2);
|
||||
});
|
||||
|
||||
it("parses charset format 1", function() {
|
||||
it("parses charset format 1", function () {
|
||||
// The first three bytes make the offset large enough to skip predefined.
|
||||
// prettier-ignore
|
||||
var bytes = new Uint8Array([0x00, 0x00, 0x00,
|
||||
|
@ -279,7 +279,7 @@ describe("CFFParser", function() {
|
|||
expect(charset.charset).toEqual([0, 8, 9]);
|
||||
});
|
||||
|
||||
it("parses charset format 2", function() {
|
||||
it("parses charset format 2", function () {
|
||||
// format 2 is the same as format 1 but the left is card16
|
||||
// The first three bytes make the offset large enough to skip predefined.
|
||||
// prettier-ignore
|
||||
|
@ -297,7 +297,7 @@ describe("CFFParser", function() {
|
|||
expect(charset.charset).toEqual([0, 8, 9]);
|
||||
});
|
||||
|
||||
it("parses encoding format 0", function() {
|
||||
it("parses encoding format 0", function () {
|
||||
// The first two bytes make the offset large enough to skip predefined.
|
||||
// prettier-ignore
|
||||
var bytes = new Uint8Array([0x00, 0x00,
|
||||
|
@ -310,7 +310,7 @@ describe("CFFParser", function() {
|
|||
expect(encoding.encoding).toEqual(createWithNullProto({ 0x8: 1 }));
|
||||
});
|
||||
|
||||
it("parses encoding format 1", function() {
|
||||
it("parses encoding format 1", function () {
|
||||
// The first two bytes make the offset large enough to skip predefined.
|
||||
// prettier-ignore
|
||||
var bytes = new Uint8Array([0x00, 0x00,
|
||||
|
@ -326,7 +326,7 @@ describe("CFFParser", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("parses fdselect format 0", function() {
|
||||
it("parses fdselect format 0", function () {
|
||||
// prettier-ignore
|
||||
var bytes = new Uint8Array([0x00, // format
|
||||
0x00, // gid: 0 fd: 0
|
||||
|
@ -339,7 +339,7 @@ describe("CFFParser", function() {
|
|||
expect(fdSelect.format).toEqual(0);
|
||||
});
|
||||
|
||||
it("parses fdselect format 3", function() {
|
||||
it("parses fdselect format 3", function () {
|
||||
// prettier-ignore
|
||||
var bytes = new Uint8Array([0x03, // format
|
||||
0x00, 0x02, // range count
|
||||
|
@ -356,7 +356,7 @@ describe("CFFParser", function() {
|
|||
expect(fdSelect.format).toEqual(3);
|
||||
});
|
||||
|
||||
it("parses invalid fdselect format 3 (bug 1146106)", function() {
|
||||
it("parses invalid fdselect format 3 (bug 1146106)", function () {
|
||||
// prettier-ignore
|
||||
var bytes = new Uint8Array([0x03, // format
|
||||
0x00, 0x02, // range count
|
||||
|
@ -376,7 +376,7 @@ describe("CFFParser", function() {
|
|||
// TODO fdArray
|
||||
});
|
||||
|
||||
describe("CFFCompiler", function() {
|
||||
describe("CFFCompiler", function () {
|
||||
function testParser(bytes) {
|
||||
bytes = new Uint8Array(bytes);
|
||||
return new CFFParser(
|
||||
|
@ -390,7 +390,7 @@ describe("CFFCompiler", function() {
|
|||
);
|
||||
}
|
||||
|
||||
it("encodes integers", function() {
|
||||
it("encodes integers", function () {
|
||||
var c = new CFFCompiler();
|
||||
// all the examples from the spec
|
||||
expect(c.encodeInteger(0)).toEqual([0x8b]);
|
||||
|
@ -404,13 +404,13 @@ describe("CFFCompiler", function() {
|
|||
expect(c.encodeInteger(-100000)).toEqual([0x1d, 0xff, 0xfe, 0x79, 0x60]);
|
||||
});
|
||||
|
||||
it("encodes floats", function() {
|
||||
it("encodes floats", function () {
|
||||
var c = new CFFCompiler();
|
||||
expect(c.encodeFloat(-2.25)).toEqual([0x1e, 0xe2, 0xa2, 0x5f]);
|
||||
expect(c.encodeFloat(5e-11)).toEqual([0x1e, 0x5c, 0x11, 0xff]);
|
||||
});
|
||||
|
||||
it("sanitizes name index", function() {
|
||||
it("sanitizes name index", function () {
|
||||
var c = new CFFCompiler();
|
||||
var nameIndexCompiled = c.compileNameIndex(["[a"]);
|
||||
var parser = testParser(nameIndexCompiled);
|
||||
|
@ -429,7 +429,7 @@ describe("CFFCompiler", function() {
|
|||
expect(names[0].length).toEqual(127);
|
||||
});
|
||||
|
||||
it("compiles fdselect format 0", function() {
|
||||
it("compiles fdselect format 0", function () {
|
||||
var fdSelect = new CFFFDSelect(0, [3, 2, 1]);
|
||||
var c = new CFFCompiler();
|
||||
var out = c.compileFDSelect(fdSelect);
|
||||
|
@ -441,7 +441,7 @@ describe("CFFCompiler", function() {
|
|||
]);
|
||||
});
|
||||
|
||||
it("compiles fdselect format 3", function() {
|
||||
it("compiles fdselect format 3", function () {
|
||||
var fdSelect = new CFFFDSelect(3, [0, 0, 1, 1]);
|
||||
var c = new CFFCompiler();
|
||||
var out = c.compileFDSelect(fdSelect);
|
||||
|
@ -460,7 +460,7 @@ describe("CFFCompiler", function() {
|
|||
]);
|
||||
});
|
||||
|
||||
it("compiles fdselect format 3, single range", function() {
|
||||
it("compiles fdselect format 3, single range", function () {
|
||||
var fdSelect = new CFFFDSelect(3, [0, 0]);
|
||||
var c = new CFFCompiler();
|
||||
var out = c.compileFDSelect(fdSelect);
|
||||
|
@ -476,7 +476,7 @@ describe("CFFCompiler", function() {
|
|||
]);
|
||||
});
|
||||
|
||||
it("compiles charset of CID font", function() {
|
||||
it("compiles charset of CID font", function () {
|
||||
var charset = new CFFCharset();
|
||||
var c = new CFFCompiler();
|
||||
var numGlyphs = 7;
|
||||
|
@ -491,7 +491,7 @@ describe("CFFCompiler", function() {
|
|||
]);
|
||||
});
|
||||
|
||||
it("compiles charset of non CID font", function() {
|
||||
it("compiles charset of non CID font", function () {
|
||||
var charset = new CFFCharset(false, 0, ["space", "exclam"]);
|
||||
var c = new CFFCompiler();
|
||||
var numGlyphs = 3;
|
||||
|
|
|
@ -31,6 +31,6 @@ if (!isNodeJS) {
|
|||
setVerbosityLevel(VerbosityLevel.ERRORS);
|
||||
|
||||
// Set the network stream factory for the unit-tests.
|
||||
setPDFNetworkStreamFactory(function(params) {
|
||||
setPDFNetworkStreamFactory(function (params) {
|
||||
return new PDFNodeStream(params);
|
||||
});
|
||||
|
|
|
@ -26,10 +26,10 @@ var cMapUrl = {
|
|||
};
|
||||
var cMapPacked = true;
|
||||
|
||||
describe("cmap", function() {
|
||||
describe("cmap", function () {
|
||||
var fetchBuiltInCMap;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
// Allow CMap testing in Node.js, e.g. for Travis.
|
||||
var CMapReaderFactory;
|
||||
if (isNodeJS) {
|
||||
|
@ -44,7 +44,7 @@ describe("cmap", function() {
|
|||
});
|
||||
}
|
||||
|
||||
fetchBuiltInCMap = function(name) {
|
||||
fetchBuiltInCMap = function (name) {
|
||||
return CMapReaderFactory.fetch({
|
||||
name,
|
||||
});
|
||||
|
@ -52,11 +52,11 @@ describe("cmap", function() {
|
|||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
fetchBuiltInCMap = null;
|
||||
});
|
||||
|
||||
it("parses beginbfchar", function(done) {
|
||||
it("parses beginbfchar", function (done) {
|
||||
// prettier-ignore
|
||||
var str = "2 beginbfchar\n" +
|
||||
"<03> <00>\n" +
|
||||
|
@ -65,17 +65,17 @@ describe("cmap", function() {
|
|||
var stream = new StringStream(str);
|
||||
var cmapPromise = CMapFactory.create({ encoding: stream });
|
||||
cmapPromise
|
||||
.then(function(cmap) {
|
||||
.then(function (cmap) {
|
||||
expect(cmap.lookup(0x03)).toEqual(String.fromCharCode(0x00));
|
||||
expect(cmap.lookup(0x04)).toEqual(String.fromCharCode(0x01));
|
||||
expect(cmap.lookup(0x05)).toBeUndefined();
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
it("parses beginbfrange with range", function(done) {
|
||||
it("parses beginbfrange with range", function (done) {
|
||||
// prettier-ignore
|
||||
var str = "1 beginbfrange\n" +
|
||||
"<06> <0B> 0\n" +
|
||||
|
@ -83,18 +83,18 @@ describe("cmap", function() {
|
|||
var stream = new StringStream(str);
|
||||
var cmapPromise = CMapFactory.create({ encoding: stream });
|
||||
cmapPromise
|
||||
.then(function(cmap) {
|
||||
.then(function (cmap) {
|
||||
expect(cmap.lookup(0x05)).toBeUndefined();
|
||||
expect(cmap.lookup(0x06)).toEqual(String.fromCharCode(0x00));
|
||||
expect(cmap.lookup(0x0b)).toEqual(String.fromCharCode(0x05));
|
||||
expect(cmap.lookup(0x0c)).toBeUndefined();
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
it("parses beginbfrange with array", function(done) {
|
||||
it("parses beginbfrange with array", function (done) {
|
||||
// prettier-ignore
|
||||
var str = "1 beginbfrange\n" +
|
||||
"<0D> <12> [ 0 1 2 3 4 5 ]\n" +
|
||||
|
@ -102,18 +102,18 @@ describe("cmap", function() {
|
|||
var stream = new StringStream(str);
|
||||
var cmapPromise = CMapFactory.create({ encoding: stream });
|
||||
cmapPromise
|
||||
.then(function(cmap) {
|
||||
.then(function (cmap) {
|
||||
expect(cmap.lookup(0x0c)).toBeUndefined();
|
||||
expect(cmap.lookup(0x0d)).toEqual(0x00);
|
||||
expect(cmap.lookup(0x12)).toEqual(0x05);
|
||||
expect(cmap.lookup(0x13)).toBeUndefined();
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
it("parses begincidchar", function(done) {
|
||||
it("parses begincidchar", function (done) {
|
||||
// prettier-ignore
|
||||
var str = "1 begincidchar\n" +
|
||||
"<14> 0\n" +
|
||||
|
@ -121,16 +121,16 @@ describe("cmap", function() {
|
|||
var stream = new StringStream(str);
|
||||
var cmapPromise = CMapFactory.create({ encoding: stream });
|
||||
cmapPromise
|
||||
.then(function(cmap) {
|
||||
.then(function (cmap) {
|
||||
expect(cmap.lookup(0x14)).toEqual(0x00);
|
||||
expect(cmap.lookup(0x15)).toBeUndefined();
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
it("parses begincidrange", function(done) {
|
||||
it("parses begincidrange", function (done) {
|
||||
// prettier-ignore
|
||||
var str = "1 begincidrange\n" +
|
||||
"<0016> <001B> 0\n" +
|
||||
|
@ -138,18 +138,18 @@ describe("cmap", function() {
|
|||
var stream = new StringStream(str);
|
||||
var cmapPromise = CMapFactory.create({ encoding: stream });
|
||||
cmapPromise
|
||||
.then(function(cmap) {
|
||||
.then(function (cmap) {
|
||||
expect(cmap.lookup(0x15)).toBeUndefined();
|
||||
expect(cmap.lookup(0x16)).toEqual(0x00);
|
||||
expect(cmap.lookup(0x1b)).toEqual(0x05);
|
||||
expect(cmap.lookup(0x1c)).toBeUndefined();
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
it("decodes codespace ranges", function(done) {
|
||||
it("decodes codespace ranges", function (done) {
|
||||
// prettier-ignore
|
||||
var str = "1 begincodespacerange\n" +
|
||||
"<01> <02>\n" +
|
||||
|
@ -158,7 +158,7 @@ describe("cmap", function() {
|
|||
var stream = new StringStream(str);
|
||||
var cmapPromise = CMapFactory.create({ encoding: stream });
|
||||
cmapPromise
|
||||
.then(function(cmap) {
|
||||
.then(function (cmap) {
|
||||
var c = {};
|
||||
cmap.readCharCode(String.fromCharCode(1), 0, c);
|
||||
expect(c.charcode).toEqual(1);
|
||||
|
@ -168,11 +168,11 @@ describe("cmap", function() {
|
|||
expect(c.length).toEqual(4);
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
it("decodes 4 byte codespace ranges", function(done) {
|
||||
it("decodes 4 byte codespace ranges", function (done) {
|
||||
// prettier-ignore
|
||||
var str = "1 begincodespacerange\n" +
|
||||
"<8EA1A1A1> <8EA1FEFE>\n" +
|
||||
|
@ -180,18 +180,18 @@ describe("cmap", function() {
|
|||
var stream = new StringStream(str);
|
||||
var cmapPromise = CMapFactory.create({ encoding: stream });
|
||||
cmapPromise
|
||||
.then(function(cmap) {
|
||||
.then(function (cmap) {
|
||||
var c = {};
|
||||
cmap.readCharCode(String.fromCharCode(0x8e, 0xa1, 0xa1, 0xa1), 0, c);
|
||||
expect(c.charcode).toEqual(0x8ea1a1a1);
|
||||
expect(c.length).toEqual(4);
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
it("read usecmap", function(done) {
|
||||
it("read usecmap", function (done) {
|
||||
var str = "/Adobe-Japan1-1 usecmap\n";
|
||||
var stream = new StringStream(str);
|
||||
var cmapPromise = CMapFactory.create({
|
||||
|
@ -200,7 +200,7 @@ describe("cmap", function() {
|
|||
useCMap: null,
|
||||
});
|
||||
cmapPromise
|
||||
.then(function(cmap) {
|
||||
.then(function (cmap) {
|
||||
expect(cmap instanceof CMap).toEqual(true);
|
||||
expect(cmap.useCMap).not.toBeNull();
|
||||
expect(cmap.builtInCMap).toBeFalsy();
|
||||
|
@ -208,44 +208,44 @@ describe("cmap", function() {
|
|||
expect(cmap.isIdentityCMap).toEqual(false);
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
it("parses cmapname", function(done) {
|
||||
it("parses cmapname", function (done) {
|
||||
var str = "/CMapName /Identity-H def\n";
|
||||
var stream = new StringStream(str);
|
||||
var cmapPromise = CMapFactory.create({ encoding: stream });
|
||||
cmapPromise
|
||||
.then(function(cmap) {
|
||||
.then(function (cmap) {
|
||||
expect(cmap.name).toEqual("Identity-H");
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
it("parses wmode", function(done) {
|
||||
it("parses wmode", function (done) {
|
||||
var str = "/WMode 1 def\n";
|
||||
var stream = new StringStream(str);
|
||||
var cmapPromise = CMapFactory.create({ encoding: stream });
|
||||
cmapPromise
|
||||
.then(function(cmap) {
|
||||
.then(function (cmap) {
|
||||
expect(cmap.vertical).toEqual(true);
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
it("loads built in cmap", function(done) {
|
||||
it("loads built in cmap", function (done) {
|
||||
var cmapPromise = CMapFactory.create({
|
||||
encoding: Name.get("Adobe-Japan1-1"),
|
||||
fetchBuiltInCMap,
|
||||
useCMap: null,
|
||||
});
|
||||
cmapPromise
|
||||
.then(function(cmap) {
|
||||
.then(function (cmap) {
|
||||
expect(cmap instanceof CMap).toEqual(true);
|
||||
expect(cmap.useCMap).toBeNull();
|
||||
expect(cmap.builtInCMap).toBeTruthy();
|
||||
|
@ -253,42 +253,42 @@ describe("cmap", function() {
|
|||
expect(cmap.isIdentityCMap).toEqual(false);
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
it("loads built in identity cmap", function(done) {
|
||||
it("loads built in identity cmap", function (done) {
|
||||
var cmapPromise = CMapFactory.create({
|
||||
encoding: Name.get("Identity-H"),
|
||||
fetchBuiltInCMap,
|
||||
useCMap: null,
|
||||
});
|
||||
cmapPromise
|
||||
.then(function(cmap) {
|
||||
.then(function (cmap) {
|
||||
expect(cmap instanceof IdentityCMap).toEqual(true);
|
||||
expect(cmap.vertical).toEqual(false);
|
||||
expect(cmap.length).toEqual(0x10000);
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return cmap.isIdentityCMap;
|
||||
}).toThrow(new Error("should not access .isIdentityCMap"));
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
|
||||
it("attempts to load a non-existent built-in CMap", function(done) {
|
||||
it("attempts to load a non-existent built-in CMap", function (done) {
|
||||
var cmapPromise = CMapFactory.create({
|
||||
encoding: Name.get("null"),
|
||||
fetchBuiltInCMap,
|
||||
useCMap: null,
|
||||
});
|
||||
cmapPromise.then(
|
||||
function() {
|
||||
function () {
|
||||
done.fail("No CMap should be loaded");
|
||||
},
|
||||
function(reason) {
|
||||
function (reason) {
|
||||
expect(reason instanceof Error).toEqual(true);
|
||||
expect(reason.message).toEqual("Unknown CMap name: null");
|
||||
done();
|
||||
|
@ -296,7 +296,7 @@ describe("cmap", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("attempts to load a built-in CMap without the necessary API parameters", function(done) {
|
||||
it("attempts to load a built-in CMap without the necessary API parameters", function (done) {
|
||||
function tmpFetchBuiltInCMap(name) {
|
||||
var CMapReaderFactory = isNodeJS
|
||||
? new NodeCMapReaderFactory({})
|
||||
|
@ -312,10 +312,10 @@ describe("cmap", function() {
|
|||
useCMap: null,
|
||||
});
|
||||
cmapPromise.then(
|
||||
function() {
|
||||
function () {
|
||||
done.fail("No CMap should be loaded");
|
||||
},
|
||||
function(reason) {
|
||||
function (reason) {
|
||||
expect(reason instanceof Error).toEqual(true);
|
||||
expect(reason.message).toEqual(
|
||||
'The CMap "baseUrl" parameter must be specified, ensure that ' +
|
||||
|
@ -326,7 +326,7 @@ describe("cmap", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("attempts to load a built-in CMap with inconsistent API parameters", function(done) {
|
||||
it("attempts to load a built-in CMap with inconsistent API parameters", function (done) {
|
||||
function tmpFetchBuiltInCMap(name) {
|
||||
let CMapReaderFactory;
|
||||
if (isNodeJS) {
|
||||
|
@ -351,10 +351,10 @@ describe("cmap", function() {
|
|||
useCMap: null,
|
||||
});
|
||||
cmapPromise.then(
|
||||
function() {
|
||||
function () {
|
||||
done.fail("No CMap should be loaded");
|
||||
},
|
||||
function(reason) {
|
||||
function (reason) {
|
||||
expect(reason instanceof Error).toEqual(true);
|
||||
const message = reason.message;
|
||||
expect(message.startsWith("Unable to load CMap at: ")).toEqual(true);
|
||||
|
|
|
@ -19,16 +19,16 @@ import { ColorSpace } from "../../src/core/colorspace.js";
|
|||
import { PDFFunctionFactory } from "../../src/core/function.js";
|
||||
import { XRefMock } from "./test_utils.js";
|
||||
|
||||
describe("colorspace", function() {
|
||||
describe("ColorSpace", function() {
|
||||
it("should be true if decode is not an array", function() {
|
||||
describe("colorspace", function () {
|
||||
describe("ColorSpace", function () {
|
||||
it("should be true if decode is not an array", function () {
|
||||
expect(ColorSpace.isDefaultDecode("string", 0)).toBeTruthy();
|
||||
});
|
||||
it("should be true if length of decode array is not correct", function() {
|
||||
it("should be true if length of decode array is not correct", function () {
|
||||
expect(ColorSpace.isDefaultDecode([0], 1)).toBeTruthy();
|
||||
expect(ColorSpace.isDefaultDecode([0, 1, 0], 1)).toBeTruthy();
|
||||
});
|
||||
it("should be true if decode map matches the default decode map", function() {
|
||||
it("should be true if decode map matches the default decode map", function () {
|
||||
expect(ColorSpace.isDefaultDecode([], 0)).toBeTruthy();
|
||||
|
||||
expect(ColorSpace.isDefaultDecode([0, 0], 1)).toBeFalsy();
|
||||
|
@ -46,8 +46,8 @@ describe("colorspace", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("DeviceGrayCS", function() {
|
||||
it("should handle the case when cs is a Name object", function() {
|
||||
describe("DeviceGrayCS", function () {
|
||||
it("should handle the case when cs is a Name object", function () {
|
||||
const cs = Name.get("DeviceGray");
|
||||
const xref = new XRefMock([
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ describe("colorspace", function() {
|
|||
expect(colorSpace.isPassthrough(8)).toBeFalsy();
|
||||
expect(testDest).toEqual(expectedDest);
|
||||
});
|
||||
it("should handle the case when cs is an indirect object", function() {
|
||||
it("should handle the case when cs is an indirect object", function () {
|
||||
const cs = Ref.get(10, 0);
|
||||
const xref = new XRefMock([
|
||||
{
|
||||
|
@ -132,8 +132,8 @@ describe("colorspace", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("DeviceRgbCS", function() {
|
||||
it("should handle the case when cs is a Name object", function() {
|
||||
describe("DeviceRgbCS", function () {
|
||||
it("should handle the case when cs is a Name object", function () {
|
||||
const cs = Name.get("DeviceRGB");
|
||||
const xref = new XRefMock([
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ describe("colorspace", function() {
|
|||
expect(colorSpace.isPassthrough(8)).toBeTruthy();
|
||||
expect(testDest).toEqual(expectedDest);
|
||||
});
|
||||
it("should handle the case when cs is an indirect object", function() {
|
||||
it("should handle the case when cs is an indirect object", function () {
|
||||
const cs = Ref.get(10, 0);
|
||||
const xref = new XRefMock([
|
||||
{
|
||||
|
@ -230,8 +230,8 @@ describe("colorspace", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("DeviceCmykCS", function() {
|
||||
it("should handle the case when cs is a Name object", function() {
|
||||
describe("DeviceCmykCS", function () {
|
||||
it("should handle the case when cs is a Name object", function () {
|
||||
const cs = Name.get("DeviceCMYK");
|
||||
const xref = new XRefMock([
|
||||
{
|
||||
|
@ -282,7 +282,7 @@ describe("colorspace", function() {
|
|||
expect(colorSpace.isPassthrough(8)).toBeFalsy();
|
||||
expect(testDest).toEqual(expectedDest);
|
||||
});
|
||||
it("should handle the case when cs is an indirect object", function() {
|
||||
it("should handle the case when cs is an indirect object", function () {
|
||||
const cs = Ref.get(10, 0);
|
||||
const xref = new XRefMock([
|
||||
{
|
||||
|
@ -328,8 +328,8 @@ describe("colorspace", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("CalGrayCS", function() {
|
||||
it("should handle the case when cs is an array", function() {
|
||||
describe("CalGrayCS", function () {
|
||||
it("should handle the case when cs is an array", function () {
|
||||
const params = new Dict();
|
||||
params.set("WhitePoint", [1, 1, 1]);
|
||||
params.set("BlackPoint", [0, 0, 0]);
|
||||
|
@ -381,8 +381,8 @@ describe("colorspace", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("CalRGBCS", function() {
|
||||
it("should handle the case when cs is an array", function() {
|
||||
describe("CalRGBCS", function () {
|
||||
it("should handle the case when cs is an array", function () {
|
||||
const params = new Dict();
|
||||
params.set("WhitePoint", [1, 1, 1]);
|
||||
params.set("BlackPoint", [0, 0, 0]);
|
||||
|
@ -434,8 +434,8 @@ describe("colorspace", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("LabCS", function() {
|
||||
it("should handle the case when cs is an array", function() {
|
||||
describe("LabCS", function () {
|
||||
it("should handle the case when cs is an array", function () {
|
||||
const params = new Dict();
|
||||
params.set("WhitePoint", [1, 1, 1]);
|
||||
params.set("BlackPoint", [0, 0, 0]);
|
||||
|
@ -487,8 +487,8 @@ describe("colorspace", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("IndexedCS", function() {
|
||||
it("should handle the case when cs is an array", function() {
|
||||
describe("IndexedCS", function () {
|
||||
it("should handle the case when cs is an array", function () {
|
||||
// prettier-ignore
|
||||
const lookup = new Uint8Array([
|
||||
23, 155, 35,
|
||||
|
@ -534,8 +534,8 @@ describe("colorspace", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("AlternateCS", function() {
|
||||
it("should handle the case when cs is an array", function() {
|
||||
describe("AlternateCS", function () {
|
||||
it("should handle the case when cs is an array", function () {
|
||||
const fnDict = new Dict();
|
||||
fnDict.set("FunctionType", 4);
|
||||
fnDict.set("Domain", [0.0, 1.0]);
|
||||
|
|
|
@ -22,9 +22,9 @@ import {
|
|||
} from "../../src/core/core_utils.js";
|
||||
import { XRefMock } from "./test_utils.js";
|
||||
|
||||
describe("core_utils", function() {
|
||||
describe("getInheritableProperty", function() {
|
||||
it("handles non-dictionary arguments", function() {
|
||||
describe("core_utils", function () {
|
||||
describe("getInheritableProperty", function () {
|
||||
it("handles non-dictionary arguments", function () {
|
||||
expect(getInheritableProperty({ dict: null, key: "foo" })).toEqual(
|
||||
undefined
|
||||
);
|
||||
|
@ -33,7 +33,7 @@ describe("core_utils", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("handles dictionaries that do not contain the property", function() {
|
||||
it("handles dictionaries that do not contain the property", function () {
|
||||
// Empty dictionary.
|
||||
const emptyDict = new Dict();
|
||||
expect(getInheritableProperty({ dict: emptyDict, key: "foo" })).toEqual(
|
||||
|
@ -48,7 +48,7 @@ describe("core_utils", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("fetches the property if it is not inherited", function() {
|
||||
it("fetches the property if it is not inherited", function () {
|
||||
const ref = Ref.get(10, 0);
|
||||
const xref = new XRefMock([{ ref, data: "quux" }]);
|
||||
const dict = new Dict(xref);
|
||||
|
@ -64,7 +64,7 @@ describe("core_utils", function() {
|
|||
).toEqual(["qux", "quux"]);
|
||||
});
|
||||
|
||||
it("fetches the property if it is inherited and present on one level", function() {
|
||||
it("fetches the property if it is inherited and present on one level", function () {
|
||||
const ref = Ref.get(10, 0);
|
||||
const xref = new XRefMock([{ ref, data: "quux" }]);
|
||||
const firstDict = new Dict(xref);
|
||||
|
@ -84,7 +84,7 @@ describe("core_utils", function() {
|
|||
).toEqual(["qux", "quux"]);
|
||||
});
|
||||
|
||||
it("fetches the property if it is inherited and present on multiple levels", function() {
|
||||
it("fetches the property if it is inherited and present on multiple levels", function () {
|
||||
const ref = Ref.get(10, 0);
|
||||
const xref = new XRefMock([{ ref, data: "quux" }]);
|
||||
const firstDict = new Dict(xref);
|
||||
|
@ -122,7 +122,7 @@ describe("core_utils", function() {
|
|||
]);
|
||||
});
|
||||
|
||||
it("stops searching when the loop limit is reached", function() {
|
||||
it("stops searching when the loop limit is reached", function () {
|
||||
const dict = new Dict();
|
||||
let currentDict = dict;
|
||||
let parentDict = null;
|
||||
|
@ -147,16 +147,16 @@ describe("core_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("toRomanNumerals", function() {
|
||||
it("handles invalid arguments", function() {
|
||||
describe("toRomanNumerals", function () {
|
||||
it("handles invalid arguments", function () {
|
||||
for (const input of ["foo", -1, 0]) {
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
toRomanNumerals(input);
|
||||
}).toThrow(new Error("The number should be a positive integer."));
|
||||
}
|
||||
});
|
||||
|
||||
it("converts numbers to uppercase Roman numerals", function() {
|
||||
it("converts numbers to uppercase Roman numerals", function () {
|
||||
expect(toRomanNumerals(1)).toEqual("I");
|
||||
expect(toRomanNumerals(6)).toEqual("VI");
|
||||
expect(toRomanNumerals(7)).toEqual("VII");
|
||||
|
@ -169,7 +169,7 @@ describe("core_utils", function() {
|
|||
expect(toRomanNumerals(2019)).toEqual("MMXIX");
|
||||
});
|
||||
|
||||
it("converts numbers to lowercase Roman numerals", function() {
|
||||
it("converts numbers to lowercase Roman numerals", function () {
|
||||
expect(toRomanNumerals(1, /* lowercase = */ true)).toEqual("i");
|
||||
expect(toRomanNumerals(6, /* lowercase = */ true)).toEqual("vi");
|
||||
expect(toRomanNumerals(7, /* lowercase = */ true)).toEqual("vii");
|
||||
|
@ -183,13 +183,13 @@ describe("core_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("log2", function() {
|
||||
it("handles values smaller than/equal to zero", function() {
|
||||
describe("log2", function () {
|
||||
it("handles values smaller than/equal to zero", function () {
|
||||
expect(log2(0)).toEqual(0);
|
||||
expect(log2(-1)).toEqual(0);
|
||||
});
|
||||
|
||||
it("handles values larger than zero", function() {
|
||||
it("handles values larger than zero", function () {
|
||||
expect(log2(1)).toEqual(0);
|
||||
expect(log2(2)).toEqual(1);
|
||||
expect(log2(3)).toEqual(2);
|
||||
|
@ -197,15 +197,15 @@ describe("core_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isWhiteSpace", function() {
|
||||
it("handles space characters", function() {
|
||||
describe("isWhiteSpace", function () {
|
||||
it("handles space characters", function () {
|
||||
expect(isWhiteSpace(0x20)).toEqual(true);
|
||||
expect(isWhiteSpace(0x09)).toEqual(true);
|
||||
expect(isWhiteSpace(0x0d)).toEqual(true);
|
||||
expect(isWhiteSpace(0x0a)).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles non-space characters", function() {
|
||||
it("handles non-space characters", function () {
|
||||
expect(isWhiteSpace(0x0b)).toEqual(false);
|
||||
expect(isWhiteSpace(null)).toEqual(false);
|
||||
expect(isWhiteSpace(undefined)).toEqual(false);
|
||||
|
|
|
@ -32,7 +32,7 @@ import {
|
|||
stringToBytes,
|
||||
} from "../../src/shared/util.js";
|
||||
|
||||
describe("crypto", function() {
|
||||
describe("crypto", function () {
|
||||
function hex2binary(s) {
|
||||
var digits = "0123456789ABCDEF";
|
||||
s = s.toUpperCase();
|
||||
|
@ -50,43 +50,43 @@ describe("crypto", function() {
|
|||
}
|
||||
|
||||
// RFC 1321, A.5 Test suite
|
||||
describe("calculateMD5", function() {
|
||||
it("should pass RFC 1321 test #1", function() {
|
||||
describe("calculateMD5", function () {
|
||||
it("should pass RFC 1321 test #1", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes("");
|
||||
result = calculateMD5(input, 0, input.length);
|
||||
expected = hex2binary("d41d8cd98f00b204e9800998ecf8427e");
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should pass RFC 1321 test #2", function() {
|
||||
it("should pass RFC 1321 test #2", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes("a");
|
||||
result = calculateMD5(input, 0, input.length);
|
||||
expected = hex2binary("0cc175b9c0f1b6a831c399e269772661");
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should pass RFC 1321 test #3", function() {
|
||||
it("should pass RFC 1321 test #3", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes("abc");
|
||||
result = calculateMD5(input, 0, input.length);
|
||||
expected = hex2binary("900150983cd24fb0d6963f7d28e17f72");
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should pass RFC 1321 test #4", function() {
|
||||
it("should pass RFC 1321 test #4", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes("message digest");
|
||||
result = calculateMD5(input, 0, input.length);
|
||||
expected = hex2binary("f96b697d7cb7938d525a2f31aaf161d0");
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should pass RFC 1321 test #5", function() {
|
||||
it("should pass RFC 1321 test #5", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes("abcdefghijklmnopqrstuvwxyz");
|
||||
result = calculateMD5(input, 0, input.length);
|
||||
expected = hex2binary("c3fcd3d76192e4007dfb496cca67e13b");
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should pass RFC 1321 test #6", function() {
|
||||
it("should pass RFC 1321 test #6", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes(
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
|
@ -95,7 +95,7 @@ describe("crypto", function() {
|
|||
expected = hex2binary("d174ab98d277d9f5a5611c2c9f419d9f");
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should pass RFC 1321 test #7", function() {
|
||||
it("should pass RFC 1321 test #7", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes(
|
||||
"123456789012345678901234567890123456789012345678" +
|
||||
|
@ -108,8 +108,8 @@ describe("crypto", function() {
|
|||
});
|
||||
|
||||
// http://www.freemedialibrary.com/index.php/RC4_test_vectors are used
|
||||
describe("ARCFourCipher", function() {
|
||||
it("should pass test #1", function() {
|
||||
describe("ARCFourCipher", function () {
|
||||
it("should pass test #1", function () {
|
||||
var key, input, result, expected, cipher;
|
||||
key = hex2binary("0123456789abcdef");
|
||||
input = hex2binary("0123456789abcdef");
|
||||
|
@ -118,7 +118,7 @@ describe("crypto", function() {
|
|||
expected = hex2binary("75b7878099e0c596");
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should pass test #2", function() {
|
||||
it("should pass test #2", function () {
|
||||
var key, input, result, expected, cipher;
|
||||
key = hex2binary("0123456789abcdef");
|
||||
input = hex2binary("0000000000000000");
|
||||
|
@ -127,7 +127,7 @@ describe("crypto", function() {
|
|||
expected = hex2binary("7494c2e7104b0879");
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should pass test #3", function() {
|
||||
it("should pass test #3", function () {
|
||||
var key, input, result, expected, cipher;
|
||||
key = hex2binary("0000000000000000");
|
||||
input = hex2binary("0000000000000000");
|
||||
|
@ -136,7 +136,7 @@ describe("crypto", function() {
|
|||
expected = hex2binary("de188941a3375d3a");
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should pass test #4", function() {
|
||||
it("should pass test #4", function () {
|
||||
var key, input, result, expected, cipher;
|
||||
key = hex2binary("ef012345");
|
||||
input = hex2binary("00000000000000000000");
|
||||
|
@ -145,7 +145,7 @@ describe("crypto", function() {
|
|||
expected = hex2binary("d6a141a7ec3c38dfbd61");
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should pass test #5", function() {
|
||||
it("should pass test #5", function () {
|
||||
var key, input, result, expected, cipher;
|
||||
key = hex2binary("0123456789abcdef");
|
||||
input = hex2binary(
|
||||
|
@ -188,7 +188,7 @@ describe("crypto", function() {
|
|||
);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should pass test #6", function() {
|
||||
it("should pass test #6", function () {
|
||||
var key, input, result, expected, cipher;
|
||||
key = hex2binary("fb029e3031323334");
|
||||
input = hex2binary(
|
||||
|
@ -205,7 +205,7 @@ describe("crypto", function() {
|
|||
);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should pass test #7", function() {
|
||||
it("should pass test #7", function () {
|
||||
var key, input, result, expected, cipher;
|
||||
key = hex2binary("0123456789abcdef");
|
||||
input = hex2binary(
|
||||
|
@ -220,8 +220,8 @@ describe("crypto", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("calculateSHA256", function() {
|
||||
it("should properly hash abc", function() {
|
||||
describe("calculateSHA256", function () {
|
||||
it("should properly hash abc", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes("abc");
|
||||
result = calculateSHA256(input, 0, input.length);
|
||||
|
@ -230,7 +230,7 @@ describe("crypto", function() {
|
|||
);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should properly hash a multiblock input", function() {
|
||||
it("should properly hash a multiblock input", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes(
|
||||
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
|
||||
|
@ -243,8 +243,8 @@ describe("crypto", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("calculateSHA384", function() {
|
||||
it("should properly hash abc", function() {
|
||||
describe("calculateSHA384", function () {
|
||||
it("should properly hash abc", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes("abc");
|
||||
result = calculateSHA384(input, 0, input.length);
|
||||
|
@ -254,7 +254,7 @@ describe("crypto", function() {
|
|||
);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should properly hash a multiblock input", function() {
|
||||
it("should properly hash a multiblock input", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes(
|
||||
"abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" +
|
||||
|
@ -270,8 +270,8 @@ describe("crypto", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("calculateSHA512", function() {
|
||||
it("should properly hash abc", function() {
|
||||
describe("calculateSHA512", function () {
|
||||
it("should properly hash abc", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes("abc");
|
||||
result = calculateSHA512(input, 0, input.length);
|
||||
|
@ -282,7 +282,7 @@ describe("crypto", function() {
|
|||
);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should properly hash a multiblock input", function() {
|
||||
it("should properly hash a multiblock input", function () {
|
||||
var input, result, expected;
|
||||
input = stringToBytes(
|
||||
"abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" +
|
||||
|
@ -299,9 +299,9 @@ describe("crypto", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("AES128", function() {
|
||||
describe("Encryption", function() {
|
||||
it("should be able to encrypt a block", function() {
|
||||
describe("AES128", function () {
|
||||
describe("Encryption", function () {
|
||||
it("should be able to encrypt a block", function () {
|
||||
var input, key, result, expected, iv, cipher;
|
||||
input = hex2binary("00112233445566778899aabbccddeeff");
|
||||
key = hex2binary("000102030405060708090a0b0c0d0e0f");
|
||||
|
@ -313,8 +313,8 @@ describe("crypto", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Decryption", function() {
|
||||
it("should be able to decrypt a block with IV in stream", function() {
|
||||
describe("Decryption", function () {
|
||||
it("should be able to decrypt a block with IV in stream", function () {
|
||||
var input, key, result, expected, cipher;
|
||||
input = hex2binary(
|
||||
"0000000000000000000000000000000069c4e0d86a7b0430d" +
|
||||
|
@ -329,9 +329,9 @@ describe("crypto", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("AES256", function() {
|
||||
describe("Encryption", function() {
|
||||
it("should be able to encrypt a block", function() {
|
||||
describe("AES256", function () {
|
||||
describe("Encryption", function () {
|
||||
it("should be able to encrypt a block", function () {
|
||||
var input, key, result, expected, iv, cipher;
|
||||
input = hex2binary("00112233445566778899aabbccddeeff");
|
||||
key = hex2binary(
|
||||
|
@ -346,8 +346,8 @@ describe("crypto", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Decryption", function() {
|
||||
it("should be able to decrypt a block with specified iv", function() {
|
||||
describe("Decryption", function () {
|
||||
it("should be able to decrypt a block with specified iv", function () {
|
||||
var input, key, result, expected, cipher, iv;
|
||||
input = hex2binary("8ea2b7ca516745bfeafc49904b496089");
|
||||
key = hex2binary(
|
||||
|
@ -360,7 +360,7 @@ describe("crypto", function() {
|
|||
expected = hex2binary("00112233445566778899aabbccddeeff");
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should be able to decrypt a block with IV in stream", function() {
|
||||
it("should be able to decrypt a block with IV in stream", function () {
|
||||
var input, key, result, expected, cipher;
|
||||
input = hex2binary(
|
||||
"000000000000000000000000000000008ea2b7ca516745bf" +
|
||||
|
@ -378,8 +378,8 @@ describe("crypto", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("PDF17Algorithm", function() {
|
||||
it("should correctly check a user key", function() {
|
||||
describe("PDF17Algorithm", function () {
|
||||
it("should correctly check a user key", function () {
|
||||
var password, userValidation, userPassword, alg, result;
|
||||
alg = new PDF17();
|
||||
password = new Uint8Array([117, 115, 101, 114]);
|
||||
|
@ -393,7 +393,7 @@ describe("crypto", function() {
|
|||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
it("should correctly check an owner key", function() {
|
||||
it("should correctly check an owner key", function () {
|
||||
var password, ownerValidation, ownerPassword, alg, result, uBytes;
|
||||
alg = new PDF17();
|
||||
password = new Uint8Array([111, 119, 110, 101, 114]);
|
||||
|
@ -418,7 +418,7 @@ describe("crypto", function() {
|
|||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
it("should generate a file encryption key from the user key", function() {
|
||||
it("should generate a file encryption key from the user key", function () {
|
||||
var password, userKeySalt, expected, alg, result, userEncryption;
|
||||
alg = new PDF17();
|
||||
password = new Uint8Array([117, 115, 101, 114]);
|
||||
|
@ -437,7 +437,7 @@ describe("crypto", function() {
|
|||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it("should generate a file encryption key from the owner key", function() {
|
||||
it("should generate a file encryption key from the owner key", function () {
|
||||
var password, ownerKeySalt, expected, alg, result, ownerEncryption;
|
||||
var uBytes;
|
||||
alg = new PDF17();
|
||||
|
@ -464,8 +464,8 @@ describe("crypto", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("PDF20Algorithm", function() {
|
||||
it("should correctly check a user key", function() {
|
||||
describe("PDF20Algorithm", function () {
|
||||
it("should correctly check a user key", function () {
|
||||
var password, userValidation, userPassword, alg, result;
|
||||
alg = new PDF20();
|
||||
password = new Uint8Array([117, 115, 101, 114]);
|
||||
|
@ -479,7 +479,7 @@ describe("crypto", function() {
|
|||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
it("should correctly check an owner key", function() {
|
||||
it("should correctly check an owner key", function () {
|
||||
var password, ownerValidation, ownerPassword, alg, result, uBytes;
|
||||
alg = new PDF20();
|
||||
password = new Uint8Array([111, 119, 110, 101, 114]);
|
||||
|
@ -504,7 +504,7 @@ describe("crypto", function() {
|
|||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
it("should generate a file encryption key from the user key", function() {
|
||||
it("should generate a file encryption key from the user key", function () {
|
||||
var password, userKeySalt, expected, alg, result, userEncryption;
|
||||
alg = new PDF20();
|
||||
password = new Uint8Array([117, 115, 101, 114]);
|
||||
|
@ -523,7 +523,7 @@ describe("crypto", function() {
|
|||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it("should generate a file encryption key from the owner key", function() {
|
||||
it("should generate a file encryption key from the owner key", function () {
|
||||
var password, ownerKeySalt, expected, alg, result, ownerEncryption;
|
||||
var uBytes;
|
||||
alg = new PDF20();
|
||||
|
@ -551,7 +551,7 @@ describe("crypto", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("CipherTransformFactory", function() {
|
||||
describe("CipherTransformFactory", function () {
|
||||
function buildDict(map) {
|
||||
var dict = new Dict();
|
||||
for (var key in map) {
|
||||
|
@ -602,7 +602,7 @@ describe("CipherTransformFactory", function() {
|
|||
var fileId1, fileId2, dict1, dict2;
|
||||
var aes256Dict, aes256IsoDict, aes256BlankDict, aes256IsoBlankDict;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
fileId1 = unescape("%F6%C6%AF%17%F3rR%8DRM%9A%80%D1%EF%DF%18");
|
||||
fileId2 = unescape("%3CL_%3AD%96%AF@%9A%9D%B3%3Cx%1Cv%AC");
|
||||
|
||||
|
@ -741,61 +741,61 @@ describe("CipherTransformFactory", function() {
|
|||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
fileId1 = fileId2 = dict1 = dict2 = null;
|
||||
aes256Dict = aes256IsoDict = aes256BlankDict = aes256IsoBlankDict = null;
|
||||
});
|
||||
|
||||
describe("#ctor", function() {
|
||||
describe("AES256 Revision 5", function() {
|
||||
it("should accept user password", function(done) {
|
||||
describe("#ctor", function () {
|
||||
describe("AES256 Revision 5", function () {
|
||||
it("should accept user password", function (done) {
|
||||
ensurePasswordCorrect(done, aes256Dict, fileId1, "user");
|
||||
});
|
||||
it("should accept owner password", function(done) {
|
||||
it("should accept owner password", function (done) {
|
||||
ensurePasswordCorrect(done, aes256Dict, fileId1, "owner");
|
||||
});
|
||||
it("should not accept blank password", function(done) {
|
||||
it("should not accept blank password", function (done) {
|
||||
ensurePasswordNeeded(done, aes256Dict, fileId1);
|
||||
});
|
||||
it("should not accept wrong password", function(done) {
|
||||
it("should not accept wrong password", function (done) {
|
||||
ensurePasswordIncorrect(done, aes256Dict, fileId1, "wrong");
|
||||
});
|
||||
it("should accept blank password", function(done) {
|
||||
it("should accept blank password", function (done) {
|
||||
ensurePasswordCorrect(done, aes256BlankDict, fileId1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("AES256 Revision 6", function() {
|
||||
it("should accept user password", function(done) {
|
||||
describe("AES256 Revision 6", function () {
|
||||
it("should accept user password", function (done) {
|
||||
ensurePasswordCorrect(done, aes256IsoDict, fileId1, "user");
|
||||
});
|
||||
it("should accept owner password", function(done) {
|
||||
it("should accept owner password", function (done) {
|
||||
ensurePasswordCorrect(done, aes256IsoDict, fileId1, "owner");
|
||||
});
|
||||
it("should not accept blank password", function(done) {
|
||||
it("should not accept blank password", function (done) {
|
||||
ensurePasswordNeeded(done, aes256IsoDict, fileId1);
|
||||
});
|
||||
it("should not accept wrong password", function(done) {
|
||||
it("should not accept wrong password", function (done) {
|
||||
ensurePasswordIncorrect(done, aes256IsoDict, fileId1, "wrong");
|
||||
});
|
||||
it("should accept blank password", function(done) {
|
||||
it("should accept blank password", function (done) {
|
||||
ensurePasswordCorrect(done, aes256IsoBlankDict, fileId1);
|
||||
});
|
||||
});
|
||||
|
||||
it("should accept user password", function(done) {
|
||||
it("should accept user password", function (done) {
|
||||
ensurePasswordCorrect(done, dict1, fileId1, "123456");
|
||||
});
|
||||
it("should accept owner password", function(done) {
|
||||
it("should accept owner password", function (done) {
|
||||
ensurePasswordCorrect(done, dict1, fileId1, "654321");
|
||||
});
|
||||
it("should not accept blank password", function(done) {
|
||||
it("should not accept blank password", function (done) {
|
||||
ensurePasswordNeeded(done, dict1, fileId1);
|
||||
});
|
||||
it("should not accept wrong password", function(done) {
|
||||
it("should not accept wrong password", function (done) {
|
||||
ensurePasswordIncorrect(done, dict1, fileId1, "wrong");
|
||||
});
|
||||
it("should accept blank password", function(done) {
|
||||
it("should accept blank password", function (done) {
|
||||
ensurePasswordCorrect(done, dict2, fileId2);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -28,7 +28,7 @@ function getTopLeftPixel(canvasContext) {
|
|||
};
|
||||
}
|
||||
|
||||
describe("custom canvas rendering", function() {
|
||||
describe("custom canvas rendering", function () {
|
||||
const transparentGetDocumentParams = buildGetDocumentParams(
|
||||
"transparent.pdf"
|
||||
);
|
||||
|
@ -37,7 +37,7 @@ describe("custom canvas rendering", function() {
|
|||
let loadingTask;
|
||||
let page;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
if (isNodeJS) {
|
||||
CanvasFactory = new NodeCanvasFactory();
|
||||
} else {
|
||||
|
@ -45,23 +45,23 @@ describe("custom canvas rendering", function() {
|
|||
}
|
||||
loadingTask = getDocument(transparentGetDocumentParams);
|
||||
loadingTask.promise
|
||||
.then(function(doc) {
|
||||
.then(function (doc) {
|
||||
return doc.getPage(1);
|
||||
})
|
||||
.then(function(data) {
|
||||
.then(function (data) {
|
||||
page = data;
|
||||
done();
|
||||
})
|
||||
.catch(done.fail);
|
||||
});
|
||||
|
||||
afterAll(function(done) {
|
||||
afterAll(function (done) {
|
||||
CanvasFactory = null;
|
||||
page = null;
|
||||
loadingTask.destroy().then(done);
|
||||
});
|
||||
|
||||
it("renders to canvas with a default white background", function(done) {
|
||||
it("renders to canvas with a default white background", function (done) {
|
||||
var viewport = page.getViewport({ scale: 1 });
|
||||
var canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
|
||||
|
||||
|
@ -70,7 +70,7 @@ describe("custom canvas rendering", function() {
|
|||
viewport,
|
||||
});
|
||||
renderTask.promise
|
||||
.then(function() {
|
||||
.then(function () {
|
||||
expect(getTopLeftPixel(canvasAndCtx.context)).toEqual({
|
||||
r: 255,
|
||||
g: 255,
|
||||
|
@ -83,7 +83,7 @@ describe("custom canvas rendering", function() {
|
|||
.catch(done.fail);
|
||||
});
|
||||
|
||||
it("renders to canvas with a custom background", function(done) {
|
||||
it("renders to canvas with a custom background", function (done) {
|
||||
var viewport = page.getViewport({ scale: 1 });
|
||||
var canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
|
||||
|
||||
|
@ -93,7 +93,7 @@ describe("custom canvas rendering", function() {
|
|||
background: "rgba(255,0,0,1.0)",
|
||||
});
|
||||
renderTask.promise
|
||||
.then(function() {
|
||||
.then(function () {
|
||||
expect(getTopLeftPixel(canvasAndCtx.context)).toEqual({
|
||||
r: 255,
|
||||
g: 0,
|
||||
|
|
|
@ -58,37 +58,37 @@ function withZlib(isZlibRequired, callback) {
|
|||
return promise;
|
||||
}
|
||||
|
||||
describe("SVGGraphics", function() {
|
||||
describe("SVGGraphics", function () {
|
||||
var loadingTask;
|
||||
var page;
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
loadingTask = getDocument(
|
||||
buildGetDocumentParams("xobject-image.pdf", {
|
||||
nativeImageDecoderSupport: NativeImageDecoding.DISPLAY,
|
||||
})
|
||||
);
|
||||
loadingTask.promise.then(function(doc) {
|
||||
doc.getPage(1).then(function(firstPage) {
|
||||
loadingTask.promise.then(function (doc) {
|
||||
doc.getPage(1).then(function (firstPage) {
|
||||
page = firstPage;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
afterAll(function(done) {
|
||||
afterAll(function (done) {
|
||||
loadingTask.destroy().then(done);
|
||||
});
|
||||
|
||||
describe("paintImageXObject", function() {
|
||||
describe("paintImageXObject", function () {
|
||||
function getSVGImage() {
|
||||
var svgGfx;
|
||||
return page
|
||||
.getOperatorList()
|
||||
.then(function(opList) {
|
||||
.then(function (opList) {
|
||||
var forceDataSchema = true;
|
||||
svgGfx = new SVGGraphics(page.commonObjs, page.objs, forceDataSchema);
|
||||
return svgGfx.loadDependencies(opList);
|
||||
})
|
||||
.then(function() {
|
||||
.then(function () {
|
||||
var svgImg;
|
||||
// A mock to steal the svg:image element from paintInlineImageXObject.
|
||||
var elementContainer = {
|
||||
|
@ -114,7 +114,7 @@ describe("SVGGraphics", function() {
|
|||
});
|
||||
}
|
||||
|
||||
it('should fail require("zlib") unless in Node.js', function() {
|
||||
it('should fail require("zlib") unless in Node.js', function () {
|
||||
function testFunc() {
|
||||
__non_webpack_require__("zlib");
|
||||
}
|
||||
|
@ -129,12 +129,12 @@ describe("SVGGraphics", function() {
|
|||
}
|
||||
});
|
||||
|
||||
it("should produce a reasonably small svg:image", function(done) {
|
||||
it("should produce a reasonably small svg:image", function (done) {
|
||||
if (!isNodeJS) {
|
||||
pending("zlib.deflateSync is not supported in non-Node environments.");
|
||||
}
|
||||
withZlib(true, getSVGImage)
|
||||
.then(function(svgImg) {
|
||||
.then(function (svgImg) {
|
||||
expect(svgImg.nodeName).toBe("svg:image");
|
||||
expect(svgImg.getAttributeNS(null, "width")).toBe("200px");
|
||||
expect(svgImg.getAttributeNS(null, "height")).toBe("100px");
|
||||
|
@ -150,9 +150,9 @@ describe("SVGGraphics", function() {
|
|||
.then(done, done.fail);
|
||||
});
|
||||
|
||||
it("should be able to produce a svg:image without zlib", function(done) {
|
||||
it("should be able to produce a svg:image without zlib", function (done) {
|
||||
withZlib(false, getSVGImage)
|
||||
.then(function(svgImg) {
|
||||
.then(function (svgImg) {
|
||||
expect(svgImg.nodeName).toBe("svg:image");
|
||||
expect(svgImg.getAttributeNS(null, "width")).toBe("200px");
|
||||
expect(svgImg.getAttributeNS(null, "height")).toBe("100px");
|
||||
|
|
|
@ -23,32 +23,32 @@ import {
|
|||
} from "../../src/display/display_utils.js";
|
||||
import { isNodeJS } from "../../src/shared/is_node.js";
|
||||
|
||||
describe("display_utils", function() {
|
||||
describe("DOMCanvasFactory", function() {
|
||||
describe("display_utils", function () {
|
||||
describe("DOMCanvasFactory", function () {
|
||||
let canvasFactory;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
canvasFactory = new DOMCanvasFactory();
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
canvasFactory = null;
|
||||
});
|
||||
|
||||
it("`create` should throw an error if the dimensions are invalid", function() {
|
||||
it("`create` should throw an error if the dimensions are invalid", function () {
|
||||
// Invalid width.
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return canvasFactory.create(-1, 1);
|
||||
}).toThrow(new Error("Invalid canvas size"));
|
||||
|
||||
// Invalid height.
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return canvasFactory.create(1, -1);
|
||||
}).toThrow(new Error("Invalid canvas size"));
|
||||
});
|
||||
|
||||
it("`create` should return a canvas if the dimensions are valid", function() {
|
||||
it("`create` should return a canvas if the dimensions are valid", function () {
|
||||
if (isNodeJS) {
|
||||
pending("Document is not supported in Node.js.");
|
||||
}
|
||||
|
@ -60,29 +60,29 @@ describe("display_utils", function() {
|
|||
expect(canvas.height).toBe(40);
|
||||
});
|
||||
|
||||
it("`reset` should throw an error if no canvas is provided", function() {
|
||||
it("`reset` should throw an error if no canvas is provided", function () {
|
||||
const canvasAndContext = { canvas: null, context: null };
|
||||
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return canvasFactory.reset(canvasAndContext, 20, 40);
|
||||
}).toThrow(new Error("Canvas is not specified"));
|
||||
});
|
||||
|
||||
it("`reset` should throw an error if the dimensions are invalid", function() {
|
||||
it("`reset` should throw an error if the dimensions are invalid", function () {
|
||||
const canvasAndContext = { canvas: "foo", context: "bar" };
|
||||
|
||||
// Invalid width.
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return canvasFactory.reset(canvasAndContext, -1, 1);
|
||||
}).toThrow(new Error("Invalid canvas size"));
|
||||
|
||||
// Invalid height.
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return canvasFactory.reset(canvasAndContext, 1, -1);
|
||||
}).toThrow(new Error("Invalid canvas size"));
|
||||
});
|
||||
|
||||
it("`reset` should alter the canvas/context if the dimensions are valid", function() {
|
||||
it("`reset` should alter the canvas/context if the dimensions are valid", function () {
|
||||
if (isNodeJS) {
|
||||
pending("Document is not supported in Node.js.");
|
||||
}
|
||||
|
@ -97,13 +97,13 @@ describe("display_utils", function() {
|
|||
expect(canvas.height).toBe(80);
|
||||
});
|
||||
|
||||
it("`destroy` should throw an error if no canvas is provided", function() {
|
||||
expect(function() {
|
||||
it("`destroy` should throw an error if no canvas is provided", function () {
|
||||
expect(function () {
|
||||
return canvasFactory.destroy({});
|
||||
}).toThrow(new Error("Canvas is not specified"));
|
||||
});
|
||||
|
||||
it("`destroy` should clear the canvas/context", function() {
|
||||
it("`destroy` should clear the canvas/context", function () {
|
||||
if (isNodeJS) {
|
||||
pending("Document is not supported in Node.js.");
|
||||
}
|
||||
|
@ -117,31 +117,31 @@ describe("display_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("DOMSVGFactory", function() {
|
||||
describe("DOMSVGFactory", function () {
|
||||
let svgFactory;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
svgFactory = new DOMSVGFactory();
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
svgFactory = null;
|
||||
});
|
||||
|
||||
it("`create` should throw an error if the dimensions are invalid", function() {
|
||||
it("`create` should throw an error if the dimensions are invalid", function () {
|
||||
// Invalid width.
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return svgFactory.create(-1, 0);
|
||||
}).toThrow(new Error("Invalid SVG dimensions"));
|
||||
|
||||
// Invalid height.
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return svgFactory.create(0, -1);
|
||||
}).toThrow(new Error("Invalid SVG dimensions"));
|
||||
});
|
||||
|
||||
it("`create` should return an SVG element if the dimensions are valid", function() {
|
||||
it("`create` should return an SVG element if the dimensions are valid", function () {
|
||||
if (isNodeJS) {
|
||||
pending("Document is not supported in Node.js.");
|
||||
}
|
||||
|
@ -155,13 +155,13 @@ describe("display_utils", function() {
|
|||
expect(svg.getAttribute("viewBox")).toBe("0 0 20 40");
|
||||
});
|
||||
|
||||
it("`createElement` should throw an error if the type is not a string", function() {
|
||||
expect(function() {
|
||||
it("`createElement` should throw an error if the type is not a string", function () {
|
||||
expect(function () {
|
||||
return svgFactory.createElement(true);
|
||||
}).toThrow(new Error("Invalid SVG element type"));
|
||||
});
|
||||
|
||||
it("`createElement` should return an SVG element if the type is valid", function() {
|
||||
it("`createElement` should return an SVG element if the type is valid", function () {
|
||||
if (isNodeJS) {
|
||||
pending("Document is not supported in Node.js.");
|
||||
}
|
||||
|
@ -171,55 +171,55 @@ describe("display_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("getFilenameFromUrl", function() {
|
||||
it("should get the filename from an absolute URL", function() {
|
||||
describe("getFilenameFromUrl", function () {
|
||||
it("should get the filename from an absolute URL", function () {
|
||||
const url = "https://server.org/filename.pdf";
|
||||
expect(getFilenameFromUrl(url)).toEqual("filename.pdf");
|
||||
});
|
||||
|
||||
it("should get the filename from a relative URL", function() {
|
||||
it("should get the filename from a relative URL", function () {
|
||||
const url = "../../filename.pdf";
|
||||
expect(getFilenameFromUrl(url)).toEqual("filename.pdf");
|
||||
});
|
||||
|
||||
it("should get the filename from a URL with an anchor", function() {
|
||||
it("should get the filename from a URL with an anchor", function () {
|
||||
const url = "https://server.org/filename.pdf#foo";
|
||||
expect(getFilenameFromUrl(url)).toEqual("filename.pdf");
|
||||
});
|
||||
|
||||
it("should get the filename from a URL with query parameters", function() {
|
||||
it("should get the filename from a URL with query parameters", function () {
|
||||
const url = "https://server.org/filename.pdf?foo=bar";
|
||||
expect(getFilenameFromUrl(url)).toEqual("filename.pdf");
|
||||
});
|
||||
});
|
||||
|
||||
describe("isValidFetchUrl", function() {
|
||||
it("handles invalid Fetch URLs", function() {
|
||||
describe("isValidFetchUrl", function () {
|
||||
it("handles invalid Fetch URLs", function () {
|
||||
expect(isValidFetchUrl(null)).toEqual(false);
|
||||
expect(isValidFetchUrl(100)).toEqual(false);
|
||||
expect(isValidFetchUrl("foo")).toEqual(false);
|
||||
expect(isValidFetchUrl("/foo", 100)).toEqual(false);
|
||||
});
|
||||
|
||||
it("handles relative Fetch URLs", function() {
|
||||
it("handles relative Fetch URLs", function () {
|
||||
expect(isValidFetchUrl("/foo", "file://www.example.com")).toEqual(false);
|
||||
expect(isValidFetchUrl("/foo", "http://www.example.com")).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles unsupported Fetch protocols", function() {
|
||||
it("handles unsupported Fetch protocols", function () {
|
||||
expect(isValidFetchUrl("file://www.example.com")).toEqual(false);
|
||||
expect(isValidFetchUrl("ftp://www.example.com")).toEqual(false);
|
||||
});
|
||||
|
||||
it("handles supported Fetch protocols", function() {
|
||||
it("handles supported Fetch protocols", function () {
|
||||
expect(isValidFetchUrl("http://www.example.com")).toEqual(true);
|
||||
expect(isValidFetchUrl("https://www.example.com")).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("PDFDateString", function() {
|
||||
describe("toDateObject", function() {
|
||||
it("converts PDF date strings to JavaScript `Date` objects", function() {
|
||||
describe("PDFDateString", function () {
|
||||
describe("toDateObject", function () {
|
||||
it("converts PDF date strings to JavaScript `Date` objects", function () {
|
||||
const expectations = {
|
||||
undefined: null,
|
||||
null: null,
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
import { createIdFactory } from "./test_utils.js";
|
||||
|
||||
describe("document", function() {
|
||||
describe("Page", function() {
|
||||
it("should create correct objId using the idFactory", function() {
|
||||
describe("document", function () {
|
||||
describe("Page", function () {
|
||||
it("should create correct objId using the idFactory", function () {
|
||||
const idFactory1 = createIdFactory(/* pageIndex = */ 0);
|
||||
const idFactory2 = createIdFactory(/* pageIndex = */ 1);
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
import { getEncoding } from "../../src/core/encodings.js";
|
||||
|
||||
describe("encodings", function() {
|
||||
describe("getEncoding", function() {
|
||||
it("fetches a valid array for known encoding names", function() {
|
||||
describe("encodings", function () {
|
||||
describe("getEncoding", function () {
|
||||
it("fetches a valid array for known encoding names", function () {
|
||||
const knownEncodingNames = [
|
||||
"ExpertEncoding",
|
||||
"MacExpertEncoding",
|
||||
|
@ -39,7 +39,7 @@ describe("encodings", function() {
|
|||
}
|
||||
});
|
||||
|
||||
it("fetches `null` for unknown encoding names", function() {
|
||||
it("fetches `null` for unknown encoding names", function () {
|
||||
expect(getEncoding("FooBarEncoding")).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ import { OperatorList } from "../../src/core/operator_list.js";
|
|||
import { PartialEvaluator } from "../../src/core/evaluator.js";
|
||||
import { WorkerTask } from "../../src/core/worker.js";
|
||||
|
||||
describe("evaluator", function() {
|
||||
describe("evaluator", function () {
|
||||
function HandlerMock() {
|
||||
this.inputs = [];
|
||||
}
|
||||
|
@ -48,10 +48,10 @@ describe("evaluator", function() {
|
|||
operatorList: result,
|
||||
})
|
||||
.then(
|
||||
function() {
|
||||
function () {
|
||||
callback(result);
|
||||
},
|
||||
function(reason) {
|
||||
function (reason) {
|
||||
callback(reason);
|
||||
}
|
||||
);
|
||||
|
@ -59,7 +59,7 @@ describe("evaluator", function() {
|
|||
|
||||
var partialEvaluator;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
partialEvaluator = new PartialEvaluator({
|
||||
xref: new XRefMock(),
|
||||
handler: new HandlerMock(),
|
||||
|
@ -69,18 +69,18 @@ describe("evaluator", function() {
|
|||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
partialEvaluator = null;
|
||||
});
|
||||
|
||||
describe("splitCombinedOperations", function() {
|
||||
it("should reject unknown operations", function(done) {
|
||||
describe("splitCombinedOperations", function () {
|
||||
it("should reject unknown operations", function (done) {
|
||||
var stream = new StringStream("fTT");
|
||||
runOperatorListCheck(
|
||||
partialEvaluator,
|
||||
stream,
|
||||
new ResourcesMock(),
|
||||
function(result) {
|
||||
function (result) {
|
||||
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
|
||||
expect(result.fnArray.length).toEqual(1);
|
||||
expect(result.fnArray[0]).toEqual(OPS.fill);
|
||||
|
@ -90,13 +90,13 @@ describe("evaluator", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("should handle one operation", function(done) {
|
||||
it("should handle one operation", function (done) {
|
||||
var stream = new StringStream("Q");
|
||||
runOperatorListCheck(
|
||||
partialEvaluator,
|
||||
stream,
|
||||
new ResourcesMock(),
|
||||
function(result) {
|
||||
function (result) {
|
||||
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
|
||||
expect(result.fnArray.length).toEqual(1);
|
||||
expect(result.fnArray[0]).toEqual(OPS.restore);
|
||||
|
@ -105,11 +105,11 @@ describe("evaluator", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("should handle two glued operations", function(done) {
|
||||
it("should handle two glued operations", function (done) {
|
||||
var resources = new ResourcesMock();
|
||||
resources.Res1 = {};
|
||||
var stream = new StringStream("/Res1 DoQ");
|
||||
runOperatorListCheck(partialEvaluator, stream, resources, function(
|
||||
runOperatorListCheck(partialEvaluator, stream, resources, function (
|
||||
result
|
||||
) {
|
||||
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
|
||||
|
@ -120,13 +120,13 @@ describe("evaluator", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("should handle three glued operations", function(done) {
|
||||
it("should handle three glued operations", function (done) {
|
||||
var stream = new StringStream("fff");
|
||||
runOperatorListCheck(
|
||||
partialEvaluator,
|
||||
stream,
|
||||
new ResourcesMock(),
|
||||
function(result) {
|
||||
function (result) {
|
||||
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
|
||||
expect(result.fnArray.length).toEqual(3);
|
||||
expect(result.fnArray[0]).toEqual(OPS.fill);
|
||||
|
@ -137,11 +137,11 @@ describe("evaluator", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("should handle three glued operations #2", function(done) {
|
||||
it("should handle three glued operations #2", function (done) {
|
||||
var resources = new ResourcesMock();
|
||||
resources.Res1 = {};
|
||||
var stream = new StringStream("B*Bf*");
|
||||
runOperatorListCheck(partialEvaluator, stream, resources, function(
|
||||
runOperatorListCheck(partialEvaluator, stream, resources, function (
|
||||
result
|
||||
) {
|
||||
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
|
||||
|
@ -153,13 +153,13 @@ describe("evaluator", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("should handle glued operations and operands", function(done) {
|
||||
it("should handle glued operations and operands", function (done) {
|
||||
var stream = new StringStream("f5 Ts");
|
||||
runOperatorListCheck(
|
||||
partialEvaluator,
|
||||
stream,
|
||||
new ResourcesMock(),
|
||||
function(result) {
|
||||
function (result) {
|
||||
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
|
||||
expect(result.fnArray.length).toEqual(2);
|
||||
expect(result.fnArray[0]).toEqual(OPS.fill);
|
||||
|
@ -172,13 +172,13 @@ describe("evaluator", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("should handle glued operations and literals", function(done) {
|
||||
it("should handle glued operations and literals", function (done) {
|
||||
var stream = new StringStream("trueifalserinulln");
|
||||
runOperatorListCheck(
|
||||
partialEvaluator,
|
||||
stream,
|
||||
new ResourcesMock(),
|
||||
function(result) {
|
||||
function (result) {
|
||||
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
|
||||
expect(result.fnArray.length).toEqual(3);
|
||||
expect(result.fnArray[0]).toEqual(OPS.setFlatness);
|
||||
|
@ -196,14 +196,14 @@ describe("evaluator", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("validateNumberOfArgs", function() {
|
||||
it("should execute if correct number of arguments", function(done) {
|
||||
describe("validateNumberOfArgs", function () {
|
||||
it("should execute if correct number of arguments", function (done) {
|
||||
var stream = new StringStream("5 1 d0");
|
||||
runOperatorListCheck(
|
||||
partialEvaluator,
|
||||
stream,
|
||||
new ResourcesMock(),
|
||||
function(result) {
|
||||
function (result) {
|
||||
expect(result.argsArray[0][0]).toEqual(5);
|
||||
expect(result.argsArray[0][1]).toEqual(1);
|
||||
expect(result.fnArray[0]).toEqual(OPS.setCharWidth);
|
||||
|
@ -211,13 +211,13 @@ describe("evaluator", function() {
|
|||
}
|
||||
);
|
||||
});
|
||||
it("should execute if too many arguments", function(done) {
|
||||
it("should execute if too many arguments", function (done) {
|
||||
var stream = new StringStream("5 1 4 d0");
|
||||
runOperatorListCheck(
|
||||
partialEvaluator,
|
||||
stream,
|
||||
new ResourcesMock(),
|
||||
function(result) {
|
||||
function (result) {
|
||||
expect(result.argsArray[0][0]).toEqual(1);
|
||||
expect(result.argsArray[0][1]).toEqual(4);
|
||||
expect(result.fnArray[0]).toEqual(OPS.setCharWidth);
|
||||
|
@ -225,13 +225,13 @@ describe("evaluator", function() {
|
|||
}
|
||||
);
|
||||
});
|
||||
it("should execute if nested commands", function(done) {
|
||||
it("should execute if nested commands", function (done) {
|
||||
var stream = new StringStream("/F2 /GS2 gs 5.711 Tf");
|
||||
runOperatorListCheck(
|
||||
partialEvaluator,
|
||||
stream,
|
||||
new ResourcesMock(),
|
||||
function(result) {
|
||||
function (result) {
|
||||
expect(result.fnArray.length).toEqual(3);
|
||||
expect(result.fnArray[0]).toEqual(OPS.setGState);
|
||||
expect(result.fnArray[1]).toEqual(OPS.dependency);
|
||||
|
@ -244,13 +244,13 @@ describe("evaluator", function() {
|
|||
}
|
||||
);
|
||||
});
|
||||
it("should skip if too few arguments", function(done) {
|
||||
it("should skip if too few arguments", function (done) {
|
||||
var stream = new StringStream("5 d0");
|
||||
runOperatorListCheck(
|
||||
partialEvaluator,
|
||||
stream,
|
||||
new ResourcesMock(),
|
||||
function(result) {
|
||||
function (result) {
|
||||
expect(result.argsArray).toEqual([]);
|
||||
expect(result.fnArray).toEqual([]);
|
||||
done();
|
||||
|
@ -261,7 +261,7 @@ describe("evaluator", function() {
|
|||
it(
|
||||
"should error if (many) path operators have too few arguments " +
|
||||
"(bug 1443140)",
|
||||
function(done) {
|
||||
function (done) {
|
||||
const NUM_INVALID_OPS = 25;
|
||||
const tempArr = new Array(NUM_INVALID_OPS + 1);
|
||||
|
||||
|
@ -272,7 +272,7 @@ describe("evaluator", function() {
|
|||
partialEvaluator,
|
||||
moveTextStream,
|
||||
new ResourcesMock(),
|
||||
function(result) {
|
||||
function (result) {
|
||||
expect(result.argsArray).toEqual([]);
|
||||
expect(result.fnArray).toEqual([]);
|
||||
done();
|
||||
|
@ -286,7 +286,7 @@ describe("evaluator", function() {
|
|||
partialEvaluator,
|
||||
lineToStream,
|
||||
new ResourcesMock(),
|
||||
function(error) {
|
||||
function (error) {
|
||||
expect(error instanceof FormatError).toEqual(true);
|
||||
expect(error.message).toEqual(
|
||||
"Invalid command l: expected 2 args, but received 1 args."
|
||||
|
@ -297,13 +297,13 @@ describe("evaluator", function() {
|
|||
}
|
||||
);
|
||||
|
||||
it("should close opened saves", function(done) {
|
||||
it("should close opened saves", function (done) {
|
||||
var stream = new StringStream("qq");
|
||||
runOperatorListCheck(
|
||||
partialEvaluator,
|
||||
stream,
|
||||
new ResourcesMock(),
|
||||
function(result) {
|
||||
function (result) {
|
||||
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
|
||||
expect(result.fnArray.length).toEqual(4);
|
||||
expect(result.fnArray[0]).toEqual(OPS.save);
|
||||
|
@ -314,13 +314,13 @@ describe("evaluator", function() {
|
|||
}
|
||||
);
|
||||
});
|
||||
it("should error on paintXObject if name is missing", function(done) {
|
||||
it("should error on paintXObject if name is missing", function (done) {
|
||||
var stream = new StringStream("/ Do");
|
||||
runOperatorListCheck(
|
||||
partialEvaluator,
|
||||
stream,
|
||||
new ResourcesMock(),
|
||||
function(result) {
|
||||
function (result) {
|
||||
expect(result instanceof FormatError).toEqual(true);
|
||||
expect(result.message).toEqual(
|
||||
"XObject must be referred to by name."
|
||||
|
@ -329,7 +329,7 @@ describe("evaluator", function() {
|
|||
}
|
||||
);
|
||||
});
|
||||
it("should skip paintXObject if subtype is PS", function(done) {
|
||||
it("should skip paintXObject if subtype is PS", function (done) {
|
||||
var xobjStreamDict = new Dict();
|
||||
xobjStreamDict.set("Subtype", Name.get("PS"));
|
||||
var xobjStream = new Stream([], 0, 0, xobjStreamDict);
|
||||
|
@ -341,7 +341,7 @@ describe("evaluator", function() {
|
|||
resources.set("XObject", xobjs);
|
||||
|
||||
var stream = new StringStream("/Res1 Do");
|
||||
runOperatorListCheck(partialEvaluator, stream, resources, function(
|
||||
runOperatorListCheck(partialEvaluator, stream, resources, function (
|
||||
result
|
||||
) {
|
||||
expect(result.argsArray).toEqual([]);
|
||||
|
@ -351,8 +351,8 @@ describe("evaluator", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("thread control", function() {
|
||||
it("should abort operator list parsing", function(done) {
|
||||
describe("thread control", function () {
|
||||
it("should abort operator list parsing", function (done) {
|
||||
var stream = new StringStream("qqQQ");
|
||||
var resources = new ResourcesMock();
|
||||
var result = new OperatorList();
|
||||
|
@ -365,13 +365,13 @@ describe("evaluator", function() {
|
|||
resources,
|
||||
operatorList: result,
|
||||
})
|
||||
.catch(function() {
|
||||
.catch(function () {
|
||||
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
|
||||
expect(result.fnArray.length).toEqual(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("should abort text parsing parsing", function(done) {
|
||||
it("should abort text parsing parsing", function (done) {
|
||||
var resources = new ResourcesMock();
|
||||
var stream = new StringStream("qqQQ");
|
||||
var task = new WorkerTask("TextContentAbort");
|
||||
|
@ -382,19 +382,19 @@ describe("evaluator", function() {
|
|||
task,
|
||||
resources,
|
||||
})
|
||||
.catch(function() {
|
||||
.catch(function () {
|
||||
expect(true).toEqual(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("operator list", function() {
|
||||
describe("operator list", function () {
|
||||
class StreamSinkMock {
|
||||
enqueue() {}
|
||||
}
|
||||
|
||||
it("should get correct total length after flushing", function() {
|
||||
it("should get correct total length after flushing", function () {
|
||||
var operatorList = new OperatorList(null, new StreamSinkMock());
|
||||
operatorList.addOp(OPS.save, null);
|
||||
operatorList.addOp(OPS.restore, null);
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
import { AbortException } from "../../src/shared/util.js";
|
||||
import { PDFFetchStream } from "../../src/display/fetch_stream.js";
|
||||
|
||||
describe("fetch_stream", function() {
|
||||
describe("fetch_stream", function () {
|
||||
const pdfUrl = new URL("../pdfs/tracemonkey.pdf", window.location).href;
|
||||
const pdfLength = 1016315;
|
||||
|
||||
it("read with streaming", function(done) {
|
||||
it("read with streaming", function (done) {
|
||||
const stream = new PDFFetchStream({
|
||||
url: pdfUrl,
|
||||
disableStream: false,
|
||||
|
@ -31,14 +31,14 @@ describe("fetch_stream", function() {
|
|||
const fullReader = stream.getFullReader();
|
||||
|
||||
let isStreamingSupported, isRangeSupported;
|
||||
const promise = fullReader.headersReady.then(function() {
|
||||
const promise = fullReader.headersReady.then(function () {
|
||||
isStreamingSupported = fullReader.isStreamingSupported;
|
||||
isRangeSupported = fullReader.isRangeSupported;
|
||||
});
|
||||
|
||||
let len = 0;
|
||||
const read = function() {
|
||||
return fullReader.read().then(function(result) {
|
||||
const read = function () {
|
||||
return fullReader.read().then(function (result) {
|
||||
if (result.done) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ describe("fetch_stream", function() {
|
|||
|
||||
const readPromise = Promise.all([read(), promise]);
|
||||
readPromise
|
||||
.then(function() {
|
||||
.then(function () {
|
||||
expect(len).toEqual(pdfLength);
|
||||
expect(isStreamingSupported).toEqual(true);
|
||||
expect(isRangeSupported).toEqual(false);
|
||||
|
@ -59,7 +59,7 @@ describe("fetch_stream", function() {
|
|||
.catch(done.fail);
|
||||
});
|
||||
|
||||
it("read ranges with streaming", function(done) {
|
||||
it("read ranges with streaming", function (done) {
|
||||
const rangeSize = 32768;
|
||||
const stream = new PDFFetchStream({
|
||||
url: pdfUrl,
|
||||
|
@ -71,7 +71,7 @@ describe("fetch_stream", function() {
|
|||
const fullReader = stream.getFullReader();
|
||||
|
||||
let isStreamingSupported, isRangeSupported, fullReaderCancelled;
|
||||
const promise = fullReader.headersReady.then(function() {
|
||||
const promise = fullReader.headersReady.then(function () {
|
||||
isStreamingSupported = fullReader.isStreamingSupported;
|
||||
isRangeSupported = fullReader.isRangeSupported;
|
||||
// We shall be able to close full reader without any issue.
|
||||
|
@ -88,8 +88,8 @@ describe("fetch_stream", function() {
|
|||
|
||||
const result1 = { value: 0 },
|
||||
result2 = { value: 0 };
|
||||
const read = function(reader, lenResult) {
|
||||
return reader.read().then(function(result) {
|
||||
const read = function (reader, lenResult) {
|
||||
return reader.read().then(function (result) {
|
||||
if (result.done) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ describe("fetch_stream", function() {
|
|||
promise,
|
||||
]);
|
||||
readPromise
|
||||
.then(function() {
|
||||
.then(function () {
|
||||
expect(isStreamingSupported).toEqual(true);
|
||||
expect(isRangeSupported).toEqual(true);
|
||||
expect(fullReaderCancelled).toEqual(true);
|
||||
|
|
|
@ -20,8 +20,8 @@ import {
|
|||
import { PostScriptLexer, PostScriptParser } from "../../src/core/ps_parser.js";
|
||||
import { StringStream } from "../../src/core/stream.js";
|
||||
|
||||
describe("function", function() {
|
||||
beforeEach(function() {
|
||||
describe("function", function () {
|
||||
beforeEach(function () {
|
||||
jasmine.addMatchers({
|
||||
toMatchArray(util, customEqualityTesters) {
|
||||
return {
|
||||
|
@ -67,55 +67,55 @@ describe("function", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("PostScriptParser", function() {
|
||||
describe("PostScriptParser", function () {
|
||||
function parse(program) {
|
||||
var stream = new StringStream(program);
|
||||
var parser = new PostScriptParser(new PostScriptLexer(stream));
|
||||
return parser.parse();
|
||||
}
|
||||
it("parses empty programs", function() {
|
||||
it("parses empty programs", function () {
|
||||
var output = parse("{}");
|
||||
expect(output.length).toEqual(0);
|
||||
});
|
||||
it("parses positive numbers", function() {
|
||||
it("parses positive numbers", function () {
|
||||
var number = 999;
|
||||
var program = parse("{ " + number + " }");
|
||||
var expectedProgram = [number];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
});
|
||||
it("parses negative numbers", function() {
|
||||
it("parses negative numbers", function () {
|
||||
var number = -999;
|
||||
var program = parse("{ " + number + " }");
|
||||
var expectedProgram = [number];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
});
|
||||
it("parses negative floats", function() {
|
||||
it("parses negative floats", function () {
|
||||
var number = 3.3;
|
||||
var program = parse("{ " + number + " }");
|
||||
var expectedProgram = [number];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
});
|
||||
it("parses operators", function() {
|
||||
it("parses operators", function () {
|
||||
var program = parse("{ sub }");
|
||||
var expectedProgram = ["sub"];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
});
|
||||
it("parses if statements", function() {
|
||||
it("parses if statements", function () {
|
||||
var program = parse("{ { 99 } if }");
|
||||
var expectedProgram = [3, "jz", 99];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
});
|
||||
it("parses ifelse statements", function() {
|
||||
it("parses ifelse statements", function () {
|
||||
var program = parse("{ { 99 } { 44 } ifelse }");
|
||||
var expectedProgram = [5, "jz", 99, 6, "j", 44];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
});
|
||||
it("handles missing brackets", function() {
|
||||
expect(function() {
|
||||
it("handles missing brackets", function () {
|
||||
expect(function () {
|
||||
parse("{");
|
||||
}).toThrow(new Error("Unexpected symbol: found undefined expected 1."));
|
||||
});
|
||||
it("handles junk after the end", function() {
|
||||
it("handles junk after the end", function () {
|
||||
var number = 3.3;
|
||||
var program = parse("{ " + number + " }#");
|
||||
var expectedProgram = [number];
|
||||
|
@ -123,7 +123,7 @@ describe("function", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("PostScriptEvaluator", function() {
|
||||
describe("PostScriptEvaluator", function () {
|
||||
function evaluate(program) {
|
||||
var stream = new StringStream(program);
|
||||
var parser = new PostScriptParser(new PostScriptLexer(stream));
|
||||
|
@ -133,320 +133,320 @@ describe("function", function() {
|
|||
return output;
|
||||
}
|
||||
|
||||
it("pushes stack", function() {
|
||||
it("pushes stack", function () {
|
||||
var stack = evaluate("{ 99 }");
|
||||
var expectedStack = [99];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("handles if with true", function() {
|
||||
it("handles if with true", function () {
|
||||
var stack = evaluate("{ 1 {99} if }");
|
||||
var expectedStack = [99];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("handles if with false", function() {
|
||||
it("handles if with false", function () {
|
||||
var stack = evaluate("{ 0 {99} if }");
|
||||
var expectedStack = [];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("handles ifelse with true", function() {
|
||||
it("handles ifelse with true", function () {
|
||||
var stack = evaluate("{ 1 {99} {77} ifelse }");
|
||||
var expectedStack = [99];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("handles ifelse with false", function() {
|
||||
it("handles ifelse with false", function () {
|
||||
var stack = evaluate("{ 0 {99} {77} ifelse }");
|
||||
var expectedStack = [77];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("handles nested if", function() {
|
||||
it("handles nested if", function () {
|
||||
var stack = evaluate("{ 1 {1 {77} if} if }");
|
||||
var expectedStack = [77];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
|
||||
it("abs", function() {
|
||||
it("abs", function () {
|
||||
var stack = evaluate("{ -2 abs }");
|
||||
var expectedStack = [2];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("adds", function() {
|
||||
it("adds", function () {
|
||||
var stack = evaluate("{ 1 2 add }");
|
||||
var expectedStack = [3];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("boolean and", function() {
|
||||
it("boolean and", function () {
|
||||
var stack = evaluate("{ true false and }");
|
||||
var expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("bitwise and", function() {
|
||||
it("bitwise and", function () {
|
||||
var stack = evaluate("{ 254 1 and }");
|
||||
var expectedStack = [254 & 1];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("calculates the inverse tangent of a number", function() {
|
||||
it("calculates the inverse tangent of a number", function () {
|
||||
var stack = evaluate("{ 90 atan }");
|
||||
var expectedStack = [Math.atan(90)];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("handles bitshifting ", function() {
|
||||
it("handles bitshifting ", function () {
|
||||
var stack = evaluate("{ 50 2 bitshift }");
|
||||
var expectedStack = [200];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("calculates the ceiling value", function() {
|
||||
it("calculates the ceiling value", function () {
|
||||
var stack = evaluate("{ 9.9 ceiling }");
|
||||
var expectedStack = [10];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("copies", function() {
|
||||
it("copies", function () {
|
||||
var stack = evaluate("{ 99 98 2 copy }");
|
||||
var expectedStack = [99, 98, 99, 98];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("calculates the cosine of a number", function() {
|
||||
it("calculates the cosine of a number", function () {
|
||||
var stack = evaluate("{ 90 cos }");
|
||||
var expectedStack = [Math.cos(90)];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("converts to int", function() {
|
||||
it("converts to int", function () {
|
||||
var stack = evaluate("{ 9.9 cvi }");
|
||||
var expectedStack = [9];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("converts negatives to int", function() {
|
||||
it("converts negatives to int", function () {
|
||||
var stack = evaluate("{ -9.9 cvi }");
|
||||
var expectedStack = [-9];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("converts to real", function() {
|
||||
it("converts to real", function () {
|
||||
var stack = evaluate("{ 55.34 cvr }");
|
||||
var expectedStack = [55.34];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("divides", function() {
|
||||
it("divides", function () {
|
||||
var stack = evaluate("{ 6 5 div }");
|
||||
var expectedStack = [1.2];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("maps division by zero to infinity", function() {
|
||||
it("maps division by zero to infinity", function () {
|
||||
var stack = evaluate("{ 6 0 div }");
|
||||
var expectedStack = [Infinity];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("duplicates", function() {
|
||||
it("duplicates", function () {
|
||||
var stack = evaluate("{ 99 dup }");
|
||||
var expectedStack = [99, 99];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("accepts an equality", function() {
|
||||
it("accepts an equality", function () {
|
||||
var stack = evaluate("{ 9 9 eq }");
|
||||
var expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("rejects an inequality", function() {
|
||||
it("rejects an inequality", function () {
|
||||
var stack = evaluate("{ 9 8 eq }");
|
||||
var expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("exchanges", function() {
|
||||
it("exchanges", function () {
|
||||
var stack = evaluate("{ 44 99 exch }");
|
||||
var expectedStack = [99, 44];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("handles exponentiation", function() {
|
||||
it("handles exponentiation", function () {
|
||||
var stack = evaluate("{ 10 2 exp }");
|
||||
var expectedStack = [100];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("pushes false onto the stack", function() {
|
||||
it("pushes false onto the stack", function () {
|
||||
var stack = evaluate("{ false }");
|
||||
var expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("calculates the floor value", function() {
|
||||
it("calculates the floor value", function () {
|
||||
var stack = evaluate("{ 9.9 floor }");
|
||||
var expectedStack = [9];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("handles greater than or equal to", function() {
|
||||
it("handles greater than or equal to", function () {
|
||||
var stack = evaluate("{ 10 9 ge }");
|
||||
var expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("rejects less than for greater than or equal to", function() {
|
||||
it("rejects less than for greater than or equal to", function () {
|
||||
var stack = evaluate("{ 8 9 ge }");
|
||||
var expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("handles greater than", function() {
|
||||
it("handles greater than", function () {
|
||||
var stack = evaluate("{ 10 9 gt }");
|
||||
var expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("rejects less than or equal for greater than", function() {
|
||||
it("rejects less than or equal for greater than", function () {
|
||||
var stack = evaluate("{ 9 9 gt }");
|
||||
var expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("divides to integer", function() {
|
||||
it("divides to integer", function () {
|
||||
var stack = evaluate("{ 2 3 idiv }");
|
||||
var expectedStack = [0];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("divides to negative integer", function() {
|
||||
it("divides to negative integer", function () {
|
||||
var stack = evaluate("{ -2 3 idiv }");
|
||||
var expectedStack = [0];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("duplicates index", function() {
|
||||
it("duplicates index", function () {
|
||||
var stack = evaluate("{ 4 3 2 1 2 index }");
|
||||
var expectedStack = [4, 3, 2, 1, 3];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("handles less than or equal to", function() {
|
||||
it("handles less than or equal to", function () {
|
||||
var stack = evaluate("{ 9 10 le }");
|
||||
var expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("rejects greater than for less than or equal to", function() {
|
||||
it("rejects greater than for less than or equal to", function () {
|
||||
var stack = evaluate("{ 10 9 le }");
|
||||
var expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("calculates the natural logarithm", function() {
|
||||
it("calculates the natural logarithm", function () {
|
||||
var stack = evaluate("{ 10 ln }");
|
||||
var expectedStack = [Math.log(10)];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("calculates the base 10 logarithm", function() {
|
||||
it("calculates the base 10 logarithm", function () {
|
||||
var stack = evaluate("{ 100 log }");
|
||||
var expectedStack = [2];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("handles less than", function() {
|
||||
it("handles less than", function () {
|
||||
var stack = evaluate("{ 9 10 lt }");
|
||||
var expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("rejects greater than or equal to for less than", function() {
|
||||
it("rejects greater than or equal to for less than", function () {
|
||||
var stack = evaluate("{ 10 9 lt }");
|
||||
var expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("performs the modulo operation", function() {
|
||||
it("performs the modulo operation", function () {
|
||||
var stack = evaluate("{ 4 3 mod }");
|
||||
var expectedStack = [1];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("multiplies two numbers (positive result)", function() {
|
||||
it("multiplies two numbers (positive result)", function () {
|
||||
var stack = evaluate("{ 9 8 mul }");
|
||||
var expectedStack = [72];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("multiplies two numbers (negative result)", function() {
|
||||
it("multiplies two numbers (negative result)", function () {
|
||||
var stack = evaluate("{ 9 -8 mul }");
|
||||
var expectedStack = [-72];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("accepts an inequality", function() {
|
||||
it("accepts an inequality", function () {
|
||||
var stack = evaluate("{ 9 8 ne }");
|
||||
var expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("rejects an equality", function() {
|
||||
it("rejects an equality", function () {
|
||||
var stack = evaluate("{ 9 9 ne }");
|
||||
var expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("negates", function() {
|
||||
it("negates", function () {
|
||||
var stack = evaluate("{ 4.5 neg }");
|
||||
var expectedStack = [-4.5];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("boolean not", function() {
|
||||
it("boolean not", function () {
|
||||
var stack = evaluate("{ true not }");
|
||||
var expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("bitwise not", function() {
|
||||
it("bitwise not", function () {
|
||||
var stack = evaluate("{ 12 not }");
|
||||
var expectedStack = [-13];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("boolean or", function() {
|
||||
it("boolean or", function () {
|
||||
var stack = evaluate("{ true false or }");
|
||||
var expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("bitwise or", function() {
|
||||
it("bitwise or", function () {
|
||||
var stack = evaluate("{ 254 1 or }");
|
||||
var expectedStack = [254 | 1];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("pops stack", function() {
|
||||
it("pops stack", function () {
|
||||
var stack = evaluate("{ 1 2 pop }");
|
||||
var expectedStack = [1];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("rolls stack right", function() {
|
||||
it("rolls stack right", function () {
|
||||
var stack = evaluate("{ 1 3 2 2 4 1 roll }");
|
||||
var expectedStack = [2, 1, 3, 2];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("rolls stack left", function() {
|
||||
it("rolls stack left", function () {
|
||||
var stack = evaluate("{ 1 3 2 2 4 -1 roll }");
|
||||
var expectedStack = [3, 2, 2, 1];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("rounds a number", function() {
|
||||
it("rounds a number", function () {
|
||||
var stack = evaluate("{ 9.52 round }");
|
||||
var expectedStack = [10];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("calculates the sine of a number", function() {
|
||||
it("calculates the sine of a number", function () {
|
||||
var stack = evaluate("{ 90 sin }");
|
||||
var expectedStack = [Math.sin(90)];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("calculates a square root (integer)", function() {
|
||||
it("calculates a square root (integer)", function () {
|
||||
var stack = evaluate("{ 100 sqrt }");
|
||||
var expectedStack = [10];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("calculates a square root (float)", function() {
|
||||
it("calculates a square root (float)", function () {
|
||||
var stack = evaluate("{ 99 sqrt }");
|
||||
var expectedStack = [Math.sqrt(99)];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("subtracts (positive result)", function() {
|
||||
it("subtracts (positive result)", function () {
|
||||
var stack = evaluate("{ 6 4 sub }");
|
||||
var expectedStack = [2];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("subtracts (negative result)", function() {
|
||||
it("subtracts (negative result)", function () {
|
||||
var stack = evaluate("{ 4 6 sub }");
|
||||
var expectedStack = [-2];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("pushes true onto the stack", function() {
|
||||
it("pushes true onto the stack", function () {
|
||||
var stack = evaluate("{ true }");
|
||||
var expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("truncates a number", function() {
|
||||
it("truncates a number", function () {
|
||||
var stack = evaluate("{ 35.004 truncate }");
|
||||
var expectedStack = [35];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
it("calculates an exclusive or value", function() {
|
||||
it("calculates an exclusive or value", function () {
|
||||
var stack = evaluate("{ 3 9 xor }");
|
||||
var expectedStack = [10];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
});
|
||||
});
|
||||
|
||||
describe("PostScriptCompiler", function() {
|
||||
describe("PostScriptCompiler", function () {
|
||||
function check(code, domain, range, samples) {
|
||||
var compiler = new PostScriptCompiler();
|
||||
var compiledCode = compiler.compile(code, domain, range);
|
||||
|
@ -472,7 +472,7 @@ describe("function", function() {
|
|||
}
|
||||
}
|
||||
|
||||
it("check compiled add", function() {
|
||||
it("check compiled add", function () {
|
||||
check([0.25, 0.5, "add"], [], [0, 1], [{ input: [], output: [0.75] }]);
|
||||
check([0, "add"], [0, 1], [0, 1], [{ input: [0.25], output: [0.25] }]);
|
||||
check([0.5, "add"], [0, 1], [0, 1], [{ input: [0.25], output: [0.75] }]);
|
||||
|
@ -496,7 +496,7 @@ describe("function", function() {
|
|||
);
|
||||
check(["add"], [0, 1], [0, 1], null);
|
||||
});
|
||||
it("check compiled sub", function() {
|
||||
it("check compiled sub", function () {
|
||||
check([0.5, 0.25, "sub"], [], [0, 1], [{ input: [], output: [0.25] }]);
|
||||
check([0, "sub"], [0, 1], [0, 1], [{ input: [0.25], output: [0.25] }]);
|
||||
check([0.5, "sub"], [0, 1], [0, 1], [{ input: [0.75], output: [0.25] }]);
|
||||
|
@ -527,7 +527,7 @@ describe("function", function() {
|
|||
[{ input: [0.75], output: [0.75] }]
|
||||
);
|
||||
});
|
||||
it("check compiled mul", function() {
|
||||
it("check compiled mul", function () {
|
||||
check([0.25, 0.5, "mul"], [], [0, 1], [{ input: [], output: [0.125] }]);
|
||||
check([0, "mul"], [0, 1], [0, 1], [{ input: [0.25], output: [0] }]);
|
||||
check([0.5, "mul"], [0, 1], [0, 1], [{ input: [0.25], output: [0.125] }]);
|
||||
|
@ -558,7 +558,7 @@ describe("function", function() {
|
|||
);
|
||||
check(["mul"], [0, 1], [0, 1], null);
|
||||
});
|
||||
it("check compiled max", function() {
|
||||
it("check compiled max", function () {
|
||||
check(
|
||||
["dup", 0.75, "gt", 7, "jz", "pop", 0.75],
|
||||
[0, 1],
|
||||
|
@ -573,7 +573,7 @@ describe("function", function() {
|
|||
);
|
||||
check(["dup", 0.75, "gt", 5, "jz", "pop", 0.75], [0, 1], [0, 1], null);
|
||||
});
|
||||
it("check pop/roll/index", function() {
|
||||
it("check pop/roll/index", function () {
|
||||
check([1, "pop"], [0, 1], [0, 1], [{ input: [0.5], output: [0.5] }]);
|
||||
check(
|
||||
[1, 3, -1, "roll"],
|
||||
|
@ -597,7 +597,7 @@ describe("function", function() {
|
|||
check([1, 3, "index", "pop"], [0, 1], [0, 1], null);
|
||||
check([1, 0.5, "index", "pop"], [0, 1], [0, 1], null);
|
||||
});
|
||||
it("check input boundaries", function() {
|
||||
it("check input boundaries", function () {
|
||||
check([], [0, 0.5], [0, 1], [{ input: [1], output: [0.5] }]);
|
||||
check([], [0.5, 1], [0, 1], [{ input: [0], output: [0.5] }]);
|
||||
check(
|
||||
|
@ -608,7 +608,7 @@ describe("function", function() {
|
|||
);
|
||||
check([], [100, 1001], [0, 10000], [{ input: [1000], output: [1000] }]);
|
||||
});
|
||||
it("check output boundaries", function() {
|
||||
it("check output boundaries", function () {
|
||||
check([], [0, 1], [0, 0.5], [{ input: [1], output: [0.5] }]);
|
||||
check([], [0, 1], [0.5, 1], [{ input: [0], output: [0.5] }]);
|
||||
check(
|
||||
|
@ -619,7 +619,7 @@ describe("function", function() {
|
|||
);
|
||||
check([], [0, 10000], [100, 1001], [{ input: [1000], output: [1000] }]);
|
||||
});
|
||||
it("compile optimized", function() {
|
||||
it("compile optimized", function () {
|
||||
var compiler = new PostScriptCompiler();
|
||||
var code = [0, "add", 1, 1, 3, -1, "roll", "sub", "sub", 1, "mul"];
|
||||
var compiledCode = compiler.compile(code, [0, 1], [0, 1]);
|
||||
|
|
|
@ -79,11 +79,11 @@ function initializePDFJS(callback) {
|
|||
"pdfjs-test/unit/ui_utils_spec.js",
|
||||
"pdfjs-test/unit/unicode_spec.js",
|
||||
"pdfjs-test/unit/util_spec.js",
|
||||
].map(function(moduleName) {
|
||||
].map(function (moduleName) {
|
||||
// eslint-disable-next-line no-unsanitized/method
|
||||
return SystemJS.import(moduleName);
|
||||
})
|
||||
).then(function(modules) {
|
||||
).then(function (modules) {
|
||||
const displayApi = modules[0];
|
||||
const { GlobalWorkerOptions } = modules[1];
|
||||
const { PDFNetworkStream } = modules[2];
|
||||
|
@ -102,11 +102,11 @@ function initializePDFJS(callback) {
|
|||
"body" in Response.prototype &&
|
||||
typeof ReadableStream !== "undefined"
|
||||
) {
|
||||
displayApi.setPDFNetworkStreamFactory(function(params) {
|
||||
displayApi.setPDFNetworkStreamFactory(function (params) {
|
||||
return new PDFFetchStream(params);
|
||||
});
|
||||
} else {
|
||||
displayApi.setPDFNetworkStreamFactory(function(params) {
|
||||
displayApi.setPDFNetworkStreamFactory(function (params) {
|
||||
return new PDFNetworkStream(params);
|
||||
});
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ function initializePDFJS(callback) {
|
|||
});
|
||||
}
|
||||
|
||||
(function() {
|
||||
(function () {
|
||||
window.jasmine = jasmineRequire.core(jasmineRequire);
|
||||
|
||||
jasmineRequire.html(jasmine);
|
||||
|
@ -190,7 +190,7 @@ function initializePDFJS(callback) {
|
|||
},
|
||||
});
|
||||
|
||||
config.specFilter = function(spec) {
|
||||
config.specFilter = function (spec) {
|
||||
return specFilter.matches(spec.getFullName());
|
||||
};
|
||||
|
||||
|
@ -204,12 +204,12 @@ function initializePDFJS(callback) {
|
|||
// instance and then executing the loaded Jasmine environment.
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
window.onload = function () {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
|
||||
initializePDFJS(function() {
|
||||
initializePDFJS(function () {
|
||||
htmlReporter.initialize();
|
||||
env.execute();
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
import { LoopbackPort } from "../../src/display/api.js";
|
||||
import { MessageHandler } from "../../src/shared/message_handler.js";
|
||||
|
||||
describe("message_handler", function() {
|
||||
describe("message_handler", function () {
|
||||
// Sleep function to wait for sometime, similar to setTimeout but faster.
|
||||
function sleep(ticks) {
|
||||
return Promise.resolve().then(() => {
|
||||
|
@ -29,8 +29,8 @@ describe("message_handler", function() {
|
|||
});
|
||||
}
|
||||
|
||||
describe("sendWithStream", function() {
|
||||
it("should return a ReadableStream", function() {
|
||||
describe("sendWithStream", function () {
|
||||
it("should return a ReadableStream", function () {
|
||||
const port = new LoopbackPort();
|
||||
const messageHandler1 = new MessageHandler("main", "worker", port);
|
||||
const readable = messageHandler1.sendWithStream("fakeHandler");
|
||||
|
@ -39,16 +39,16 @@ describe("message_handler", function() {
|
|||
expect(typeof readable.getReader).toEqual("function");
|
||||
});
|
||||
|
||||
it("should read using a reader", function(done) {
|
||||
it("should read using a reader", function (done) {
|
||||
let log = "";
|
||||
const port = new LoopbackPort();
|
||||
const messageHandler1 = new MessageHandler("main", "worker", port);
|
||||
const messageHandler2 = new MessageHandler("worker", "main", port);
|
||||
messageHandler2.on("fakeHandler", (data, sink) => {
|
||||
sink.onPull = function() {
|
||||
sink.onPull = function () {
|
||||
log += "p";
|
||||
};
|
||||
sink.onCancel = function(reason) {
|
||||
sink.onCancel = function (reason) {
|
||||
log += "c";
|
||||
};
|
||||
sink.ready
|
||||
|
@ -93,15 +93,15 @@ describe("message_handler", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("should not read any data when cancelled", function(done) {
|
||||
it("should not read any data when cancelled", function (done) {
|
||||
let log = "";
|
||||
const port = new LoopbackPort();
|
||||
const messageHandler2 = new MessageHandler("worker", "main", port);
|
||||
messageHandler2.on("fakeHandler", (data, sink) => {
|
||||
sink.onPull = function() {
|
||||
sink.onPull = function () {
|
||||
log += "p";
|
||||
};
|
||||
sink.onCancel = function(reason) {
|
||||
sink.onCancel = function (reason) {
|
||||
log += "c";
|
||||
};
|
||||
log += "0";
|
||||
|
@ -159,15 +159,15 @@ describe("message_handler", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("should not read when errored", function(done) {
|
||||
it("should not read when errored", function (done) {
|
||||
let log = "";
|
||||
const port = new LoopbackPort();
|
||||
const messageHandler2 = new MessageHandler("worker", "main", port);
|
||||
messageHandler2.on("fakeHandler", (data, sink) => {
|
||||
sink.onPull = function() {
|
||||
sink.onPull = function () {
|
||||
log += "p";
|
||||
};
|
||||
sink.onCancel = function(reason) {
|
||||
sink.onCancel = function (reason) {
|
||||
log += "c";
|
||||
};
|
||||
log += "0";
|
||||
|
@ -214,15 +214,15 @@ describe("message_handler", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("should read data with blocking promise", function(done) {
|
||||
it("should read data with blocking promise", function (done) {
|
||||
let log = "";
|
||||
const port = new LoopbackPort();
|
||||
const messageHandler2 = new MessageHandler("worker", "main", port);
|
||||
messageHandler2.on("fakeHandler", (data, sink) => {
|
||||
sink.onPull = function() {
|
||||
sink.onPull = function () {
|
||||
log += "p";
|
||||
};
|
||||
sink.onCancel = function(reason) {
|
||||
sink.onCancel = function (reason) {
|
||||
log += "c";
|
||||
};
|
||||
log += "0";
|
||||
|
@ -290,15 +290,15 @@ describe("message_handler", function() {
|
|||
it(
|
||||
"should read data with blocking promise and buffer whole data" +
|
||||
" into stream",
|
||||
function(done) {
|
||||
function (done) {
|
||||
let log = "";
|
||||
const port = new LoopbackPort();
|
||||
const messageHandler2 = new MessageHandler("worker", "main", port);
|
||||
messageHandler2.on("fakeHandler", (data, sink) => {
|
||||
sink.onPull = function() {
|
||||
sink.onPull = function () {
|
||||
log += "p";
|
||||
};
|
||||
sink.onCancel = function(reason) {
|
||||
sink.onCancel = function (reason) {
|
||||
log += "c";
|
||||
};
|
||||
log += "0";
|
||||
|
@ -364,16 +364,16 @@ describe("message_handler", function() {
|
|||
}
|
||||
);
|
||||
|
||||
it("should ignore any pull after close is called", function(done) {
|
||||
it("should ignore any pull after close is called", function (done) {
|
||||
let log = "";
|
||||
const port = new LoopbackPort();
|
||||
const capability = createPromiseCapability();
|
||||
const messageHandler2 = new MessageHandler("worker", "main", port);
|
||||
messageHandler2.on("fakeHandler", (data, sink) => {
|
||||
sink.onPull = function() {
|
||||
sink.onPull = function () {
|
||||
log += "p";
|
||||
};
|
||||
sink.onCancel = function(reason) {
|
||||
sink.onCancel = function (reason) {
|
||||
log += "c";
|
||||
};
|
||||
log += "0";
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
import { isEmptyObj } from "../../src/shared/util.js";
|
||||
import { Metadata } from "../../src/display/metadata.js";
|
||||
|
||||
describe("metadata", function() {
|
||||
it("should handle valid metadata", function() {
|
||||
describe("metadata", function () {
|
||||
it("should handle valid metadata", function () {
|
||||
const data =
|
||||
"<x:xmpmeta xmlns:x='adobe:ns:meta/'>" +
|
||||
"<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>" +
|
||||
|
@ -35,7 +35,7 @@ describe("metadata", function() {
|
|||
expect(metadata.getAll()).toEqual({ "dc:title": "Foo bar baz" });
|
||||
});
|
||||
|
||||
it("should repair and handle invalid metadata", function() {
|
||||
it("should repair and handle invalid metadata", function () {
|
||||
const data =
|
||||
"<x:xmpmeta xmlns:x='adobe:ns:meta/'>" +
|
||||
"<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>" +
|
||||
|
@ -53,7 +53,7 @@ describe("metadata", function() {
|
|||
expect(metadata.getAll()).toEqual({ "dc:title": "PDF&" });
|
||||
});
|
||||
|
||||
it("should repair and handle invalid metadata (bug 1424938)", function() {
|
||||
it("should repair and handle invalid metadata (bug 1424938)", function () {
|
||||
const data =
|
||||
"<x:xmpmeta xmlns:x='adobe:ns:meta/' " +
|
||||
"x:xmptk='XMP toolkit 2.9.1-13, framework 1.6'>" +
|
||||
|
@ -102,7 +102,7 @@ describe("metadata", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("should gracefully handle incomplete tags (issue 8884)", function() {
|
||||
it("should gracefully handle incomplete tags (issue 8884)", function () {
|
||||
const data =
|
||||
'<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d' +
|
||||
'<x:xmpmeta xmlns:x="adobe:ns:meta/">' +
|
||||
|
@ -133,7 +133,7 @@ describe("metadata", function() {
|
|||
expect(isEmptyObj(metadata.getAll())).toEqual(true);
|
||||
});
|
||||
|
||||
it('should gracefully handle "junk" before the actual metadata (issue 10395)', function() {
|
||||
it('should gracefully handle "junk" before the actual metadata (issue 10395)', function () {
|
||||
const data =
|
||||
'<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>' +
|
||||
'<x:xmpmeta x:xmptk="TallComponents PDFObjects 1.0" ' +
|
||||
|
@ -183,7 +183,7 @@ describe("metadata", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should correctly handle metadata containing "&apos" (issue 10407)', function() {
|
||||
it('should correctly handle metadata containing "&apos" (issue 10407)', function () {
|
||||
const data =
|
||||
"<x:xmpmeta xmlns:x='adobe:ns:meta/'>" +
|
||||
"<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>" +
|
||||
|
@ -202,7 +202,7 @@ describe("metadata", function() {
|
|||
expect(metadata.getAll()).toEqual({ "dc:title": "'Foo bar baz'" });
|
||||
});
|
||||
|
||||
it("should gracefully handle unbalanced end tags (issue 10410)", function() {
|
||||
it("should gracefully handle unbalanced end tags (issue 10410)", function () {
|
||||
const data =
|
||||
'<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>' +
|
||||
'<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' +
|
||||
|
@ -225,7 +225,7 @@ describe("metadata", function() {
|
|||
expect(isEmptyObj(metadata.getAll())).toEqual(true);
|
||||
});
|
||||
|
||||
it("should not be vulnerable to the billion laughs attack", function() {
|
||||
it("should not be vulnerable to the billion laughs attack", function () {
|
||||
const data =
|
||||
'<?xml version="1.0"?>' +
|
||||
"<!DOCTYPE lolz [" +
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
|
||||
import { MurmurHash3_64 } from "../../src/core/murmurhash3.js";
|
||||
|
||||
describe("MurmurHash3_64", function() {
|
||||
it("instantiates without seed", function() {
|
||||
describe("MurmurHash3_64", function () {
|
||||
it("instantiates without seed", function () {
|
||||
var hash = new MurmurHash3_64();
|
||||
expect(hash).toEqual(jasmine.any(MurmurHash3_64));
|
||||
});
|
||||
it("instantiates with seed", function() {
|
||||
it("instantiates with seed", function () {
|
||||
var hash = new MurmurHash3_64(1);
|
||||
expect(hash).toEqual(jasmine.any(MurmurHash3_64));
|
||||
});
|
||||
|
@ -28,23 +28,23 @@ describe("MurmurHash3_64", function() {
|
|||
var hexDigestExpected = "f61cfdbfdae0f65e";
|
||||
var sourceText = "test";
|
||||
var sourceCharCodes = [116, 101, 115, 116]; // 't','e','s','t'
|
||||
it("correctly generates a hash from a string", function() {
|
||||
it("correctly generates a hash from a string", function () {
|
||||
var hash = new MurmurHash3_64();
|
||||
hash.update(sourceText);
|
||||
expect(hash.hexdigest()).toEqual(hexDigestExpected);
|
||||
});
|
||||
it("correctly generates a hash from a Uint8Array", function() {
|
||||
it("correctly generates a hash from a Uint8Array", function () {
|
||||
var hash = new MurmurHash3_64();
|
||||
hash.update(new Uint8Array(sourceCharCodes));
|
||||
expect(hash.hexdigest()).toEqual(hexDigestExpected);
|
||||
});
|
||||
it("correctly generates a hash from a Uint32Array", function() {
|
||||
it("correctly generates a hash from a Uint32Array", function () {
|
||||
var hash = new MurmurHash3_64();
|
||||
hash.update(new Uint32Array(new Uint8Array(sourceCharCodes).buffer));
|
||||
expect(hash.hexdigest()).toEqual(hexDigestExpected);
|
||||
});
|
||||
|
||||
it("changes the hash after update without seed", function() {
|
||||
it("changes the hash after update without seed", function () {
|
||||
var hash = new MurmurHash3_64();
|
||||
var hexdigest1, hexdigest2;
|
||||
hash.update(sourceText);
|
||||
|
@ -53,7 +53,7 @@ describe("MurmurHash3_64", function() {
|
|||
hexdigest2 = hash.hexdigest();
|
||||
expect(hexdigest1).not.toEqual(hexdigest2);
|
||||
});
|
||||
it("changes the hash after update with seed", function() {
|
||||
it("changes the hash after update with seed", function () {
|
||||
var hash = new MurmurHash3_64(1);
|
||||
var hexdigest1, hexdigest2;
|
||||
hash.update(sourceText);
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
import { AbortException } from "../../src/shared/util.js";
|
||||
import { PDFNetworkStream } from "../../src/display/network.js";
|
||||
|
||||
describe("network", function() {
|
||||
describe("network", function () {
|
||||
var pdf1 = new URL("../pdfs/tracemonkey.pdf", window.location).href;
|
||||
var pdf1Length = 1016315;
|
||||
|
||||
it("read without stream and range", function(done) {
|
||||
it("read without stream and range", function (done) {
|
||||
var stream = new PDFNetworkStream({
|
||||
url: pdf1,
|
||||
rangeChunkSize: 65536,
|
||||
|
@ -31,15 +31,15 @@ describe("network", function() {
|
|||
var fullReader = stream.getFullReader();
|
||||
|
||||
var isStreamingSupported, isRangeSupported;
|
||||
var promise = fullReader.headersReady.then(function() {
|
||||
var promise = fullReader.headersReady.then(function () {
|
||||
isStreamingSupported = fullReader.isStreamingSupported;
|
||||
isRangeSupported = fullReader.isRangeSupported;
|
||||
});
|
||||
|
||||
var len = 0,
|
||||
count = 0;
|
||||
var read = function() {
|
||||
return fullReader.read().then(function(result) {
|
||||
var read = function () {
|
||||
return fullReader.read().then(function (result) {
|
||||
if (result.done) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -52,19 +52,19 @@ describe("network", function() {
|
|||
var readPromise = Promise.all([read(), promise]);
|
||||
|
||||
readPromise
|
||||
.then(function(page) {
|
||||
.then(function (page) {
|
||||
expect(len).toEqual(pdf1Length);
|
||||
expect(count).toEqual(1);
|
||||
expect(isStreamingSupported).toEqual(false);
|
||||
expect(isRangeSupported).toEqual(false);
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
|
||||
it("read custom ranges", function(done) {
|
||||
it("read custom ranges", function (done) {
|
||||
// We don't test on browsers that don't support range request, so
|
||||
// requiring this test to pass.
|
||||
var rangeSize = 32768;
|
||||
|
@ -79,7 +79,7 @@ describe("network", function() {
|
|||
var fullReader = stream.getFullReader();
|
||||
|
||||
var isStreamingSupported, isRangeSupported, fullReaderCancelled;
|
||||
var promise = fullReader.headersReady.then(function() {
|
||||
var promise = fullReader.headersReady.then(function () {
|
||||
isStreamingSupported = fullReader.isStreamingSupported;
|
||||
isRangeSupported = fullReader.isRangeSupported;
|
||||
// we shall be able to close the full reader without issues
|
||||
|
@ -98,8 +98,8 @@ describe("network", function() {
|
|||
|
||||
var result1 = { value: 0 },
|
||||
result2 = { value: 0 };
|
||||
var read = function(reader, lenResult) {
|
||||
return reader.read().then(function(result) {
|
||||
var read = function (reader, lenResult) {
|
||||
return reader.read().then(function (result) {
|
||||
if (result.done) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ describe("network", function() {
|
|||
]);
|
||||
|
||||
readPromises
|
||||
.then(function() {
|
||||
.then(function () {
|
||||
expect(result1.value).toEqual(rangeSize);
|
||||
expect(result2.value).toEqual(tailSize);
|
||||
expect(isStreamingSupported).toEqual(false);
|
||||
|
@ -123,7 +123,7 @@ describe("network", function() {
|
|||
expect(fullReaderCancelled).toEqual(true);
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,15 +24,15 @@ import {
|
|||
UnexpectedResponseException,
|
||||
} from "../../src/shared/util.js";
|
||||
|
||||
describe("network_utils", function() {
|
||||
describe("validateRangeRequestCapabilities", function() {
|
||||
it("rejects range chunk sizes that are not larger than zero", function() {
|
||||
expect(function() {
|
||||
describe("network_utils", function () {
|
||||
describe("validateRangeRequestCapabilities", function () {
|
||||
it("rejects range chunk sizes that are not larger than zero", function () {
|
||||
expect(function () {
|
||||
validateRangeRequestCapabilities({ rangeChunkSize: 0 });
|
||||
}).toThrow(new Error("Range chunk size must be larger than zero"));
|
||||
});
|
||||
|
||||
it("rejects disabled or non-HTTP range requests", function() {
|
||||
it("rejects disabled or non-HTTP range requests", function () {
|
||||
expect(
|
||||
validateRangeRequestCapabilities({
|
||||
disableRange: true,
|
||||
|
@ -68,7 +68,7 @@ describe("network_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("rejects invalid Accept-Ranges header values", function() {
|
||||
it("rejects invalid Accept-Ranges header values", function () {
|
||||
expect(
|
||||
validateRangeRequestCapabilities({
|
||||
disableRange: false,
|
||||
|
@ -89,7 +89,7 @@ describe("network_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("rejects invalid Content-Encoding header values", function() {
|
||||
it("rejects invalid Content-Encoding header values", function () {
|
||||
expect(
|
||||
validateRangeRequestCapabilities({
|
||||
disableRange: false,
|
||||
|
@ -112,7 +112,7 @@ describe("network_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("rejects invalid Content-Length header values", function() {
|
||||
it("rejects invalid Content-Length header values", function () {
|
||||
expect(
|
||||
validateRangeRequestCapabilities({
|
||||
disableRange: false,
|
||||
|
@ -135,7 +135,7 @@ describe("network_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("rejects file sizes that are too small for range requests", function() {
|
||||
it("rejects file sizes that are too small for range requests", function () {
|
||||
expect(
|
||||
validateRangeRequestCapabilities({
|
||||
disableRange: false,
|
||||
|
@ -158,7 +158,7 @@ describe("network_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("accepts file sizes large enough for range requests", function() {
|
||||
it("accepts file sizes large enough for range requests", function () {
|
||||
expect(
|
||||
validateRangeRequestCapabilities({
|
||||
disableRange: false,
|
||||
|
@ -182,8 +182,8 @@ describe("network_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("extractFilenameFromHeader", function() {
|
||||
it("returns null when content disposition header is blank", function() {
|
||||
describe("extractFilenameFromHeader", function () {
|
||||
it("returns null when content disposition header is blank", function () {
|
||||
expect(
|
||||
extractFilenameFromHeader(headerName => {
|
||||
if (headerName === "Content-Disposition") {
|
||||
|
@ -212,7 +212,7 @@ describe("network_utils", function() {
|
|||
).toBeNull();
|
||||
});
|
||||
|
||||
it("gets the filename from the response header", function() {
|
||||
it("gets the filename from the response header", function () {
|
||||
expect(
|
||||
extractFilenameFromHeader(headerName => {
|
||||
if (headerName === "Content-Disposition") {
|
||||
|
@ -295,7 +295,7 @@ describe("network_utils", function() {
|
|||
).toEqual("100%.pdf");
|
||||
});
|
||||
|
||||
it("gets the filename from the response header (RFC 6266)", function() {
|
||||
it("gets the filename from the response header (RFC 6266)", function () {
|
||||
expect(
|
||||
extractFilenameFromHeader(headerName => {
|
||||
if (headerName === "Content-Disposition") {
|
||||
|
@ -342,7 +342,7 @@ describe("network_utils", function() {
|
|||
).toEqual("filename.pdf");
|
||||
});
|
||||
|
||||
it("gets the filename from the response header (RFC 2231)", function() {
|
||||
it("gets the filename from the response header (RFC 2231)", function () {
|
||||
// Tests continuations (RFC 2231 section 3, via RFC 5987 section 3.1).
|
||||
expect(
|
||||
extractFilenameFromHeader(headerName => {
|
||||
|
@ -354,7 +354,7 @@ describe("network_utils", function() {
|
|||
).toEqual("filename.pdf");
|
||||
});
|
||||
|
||||
it("only extracts filename with pdf extension", function() {
|
||||
it("only extracts filename with pdf extension", function () {
|
||||
expect(
|
||||
extractFilenameFromHeader(headerName => {
|
||||
if (headerName === "Content-Disposition") {
|
||||
|
@ -365,7 +365,7 @@ describe("network_utils", function() {
|
|||
).toBeNull();
|
||||
});
|
||||
|
||||
it("extension validation is case insensitive", function() {
|
||||
it("extension validation is case insensitive", function () {
|
||||
expect(
|
||||
extractFilenameFromHeader(headerName => {
|
||||
if (headerName === "Content-Disposition") {
|
||||
|
@ -377,8 +377,8 @@ describe("network_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("createResponseStatusError", function() {
|
||||
it("handles missing PDF file responses", function() {
|
||||
describe("createResponseStatusError", function () {
|
||||
it("handles missing PDF file responses", function () {
|
||||
expect(createResponseStatusError(404, "https://foo.com/bar.pdf")).toEqual(
|
||||
new MissingPDFException('Missing PDF "https://foo.com/bar.pdf".')
|
||||
);
|
||||
|
@ -388,7 +388,7 @@ describe("network_utils", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("handles unexpected responses", function() {
|
||||
it("handles unexpected responses", function () {
|
||||
expect(createResponseStatusError(302, "https://foo.com/bar.pdf")).toEqual(
|
||||
new UnexpectedResponseException(
|
||||
"Unexpected server response (302) while retrieving PDF " +
|
||||
|
@ -405,13 +405,13 @@ describe("network_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("validateResponseStatus", function() {
|
||||
it("accepts valid response statuses", function() {
|
||||
describe("validateResponseStatus", function () {
|
||||
it("accepts valid response statuses", function () {
|
||||
expect(validateResponseStatus(200)).toEqual(true);
|
||||
expect(validateResponseStatus(206)).toEqual(true);
|
||||
});
|
||||
|
||||
it("rejects invalid response statuses", function() {
|
||||
it("rejects invalid response statuses", function () {
|
||||
expect(validateResponseStatus(302)).toEqual(false);
|
||||
expect(validateResponseStatus(404)).toEqual(false);
|
||||
expect(validateResponseStatus(null)).toEqual(false);
|
||||
|
|
|
@ -26,7 +26,7 @@ const url = __non_webpack_require__("url");
|
|||
const http = __non_webpack_require__("http");
|
||||
const fs = __non_webpack_require__("fs");
|
||||
|
||||
describe("node_stream", function() {
|
||||
describe("node_stream", function () {
|
||||
let server = null;
|
||||
let port = null;
|
||||
const pdf = url.parse(
|
||||
|
@ -82,7 +82,7 @@ describe("node_stream", function() {
|
|||
done();
|
||||
});
|
||||
|
||||
it("read both http(s) and filesystem pdf files", function(done) {
|
||||
it("read both http(s) and filesystem pdf files", function (done) {
|
||||
const stream1 = new PDFNodeStream({
|
||||
url: `http://127.0.0.1:${port}/tracemonkey.pdf`,
|
||||
rangeChunkSize: 65536,
|
||||
|
@ -114,8 +114,8 @@ describe("node_stream", function() {
|
|||
|
||||
let len1 = 0,
|
||||
len2 = 0;
|
||||
const read1 = function() {
|
||||
return fullReader1.read().then(function(result) {
|
||||
const read1 = function () {
|
||||
return fullReader1.read().then(function (result) {
|
||||
if (result.done) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -123,8 +123,8 @@ describe("node_stream", function() {
|
|||
return read1();
|
||||
});
|
||||
};
|
||||
const read2 = function() {
|
||||
return fullReader2.read().then(function(result) {
|
||||
const read2 = function () {
|
||||
return fullReader2.read().then(function (result) {
|
||||
if (result.done) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ describe("node_stream", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("read custom ranges for both http(s) and filesystem urls", function(done) {
|
||||
it("read custom ranges for both http(s) and filesystem urls", function (done) {
|
||||
const rangeSize = 32768;
|
||||
const stream1 = new PDFNodeStream({
|
||||
url: `http://127.0.0.1:${port}/tracemonkey.pdf`,
|
||||
|
@ -172,7 +172,7 @@ describe("node_stream", function() {
|
|||
let isStreamingSupported1, isRangeSupported1, fullReaderCancelled1;
|
||||
let isStreamingSupported2, isRangeSupported2, fullReaderCancelled2;
|
||||
|
||||
const promise1 = fullReader1.headersReady.then(function() {
|
||||
const promise1 = fullReader1.headersReady.then(function () {
|
||||
isStreamingSupported1 = fullReader1.isStreamingSupported;
|
||||
isRangeSupported1 = fullReader1.isRangeSupported;
|
||||
// we shall be able to close the full reader without issues
|
||||
|
@ -180,7 +180,7 @@ describe("node_stream", function() {
|
|||
fullReaderCancelled1 = true;
|
||||
});
|
||||
|
||||
const promise2 = fullReader2.headersReady.then(function() {
|
||||
const promise2 = fullReader2.headersReady.then(function () {
|
||||
isStreamingSupported2 = fullReader2.isStreamingSupported;
|
||||
isRangeSupported2 = fullReader2.isRangeSupported;
|
||||
fullReader2.cancel(new AbortException("Don't need fullReader2."));
|
||||
|
@ -213,8 +213,8 @@ describe("node_stream", function() {
|
|||
const result21 = { value: 0 },
|
||||
result22 = { value: 0 };
|
||||
|
||||
const read = function(reader, lenResult) {
|
||||
return reader.read().then(function(result) {
|
||||
const read = function (reader, lenResult) {
|
||||
return reader.read().then(function (result) {
|
||||
if (result.done) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ describe("node_stream", function() {
|
|||
]);
|
||||
|
||||
readPromises
|
||||
.then(function() {
|
||||
.then(function () {
|
||||
expect(result11.value).toEqual(rangeSize);
|
||||
expect(result12.value).toEqual(tailSize);
|
||||
expect(result21.value).toEqual(rangeSize);
|
||||
|
@ -246,7 +246,7 @@ describe("node_stream", function() {
|
|||
expect(fullReaderCancelled2).toEqual(true);
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -19,10 +19,10 @@ import { FormatError } from "../../src/shared/util.js";
|
|||
import { Name } from "../../src/core/primitives.js";
|
||||
import { StringStream } from "../../src/core/stream.js";
|
||||
|
||||
describe("parser", function() {
|
||||
describe("Parser", function() {
|
||||
describe("inlineStreamSkipEI", function() {
|
||||
it("should skip over the EI marker if it is found", function() {
|
||||
describe("parser", function () {
|
||||
describe("Parser", function () {
|
||||
describe("inlineStreamSkipEI", function () {
|
||||
it("should skip over the EI marker if it is found", function () {
|
||||
const string =
|
||||
"q 1 0 0 1 0 0 cm BI /W 10 /H 10 /BPC 1 " +
|
||||
"/F /A85 ID abc123~> EI Q";
|
||||
|
@ -38,7 +38,7 @@ describe("parser", function() {
|
|||
expect(input.peekByte()).toEqual(0x51); // 'Q'
|
||||
});
|
||||
|
||||
it("should skip to the end of stream if the EI marker is not found", function() {
|
||||
it("should skip to the end of stream if the EI marker is not found", function () {
|
||||
const string =
|
||||
"q 1 0 0 1 0 0 cm BI /W 10 /H 10 /BPC 1 /F /A85 ID abc123~> Q";
|
||||
const input = new StringStream(string);
|
||||
|
@ -55,16 +55,16 @@ describe("parser", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Lexer", function() {
|
||||
describe("nextChar", function() {
|
||||
it("should return and set -1 when the end of the stream is reached", function() {
|
||||
describe("Lexer", function () {
|
||||
describe("nextChar", function () {
|
||||
it("should return and set -1 when the end of the stream is reached", function () {
|
||||
const input = new StringStream("");
|
||||
const lexer = new Lexer(input);
|
||||
expect(lexer.nextChar()).toEqual(-1);
|
||||
expect(lexer.currentChar).toEqual(-1);
|
||||
});
|
||||
|
||||
it("should return and set the character after the current position", function() {
|
||||
it("should return and set the character after the current position", function () {
|
||||
const input = new StringStream("123");
|
||||
const lexer = new Lexer(input);
|
||||
expect(lexer.nextChar()).toEqual(0x32); // '2'
|
||||
|
@ -72,15 +72,15 @@ describe("parser", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("peekChar", function() {
|
||||
it("should only return -1 when the end of the stream is reached", function() {
|
||||
describe("peekChar", function () {
|
||||
it("should only return -1 when the end of the stream is reached", function () {
|
||||
const input = new StringStream("");
|
||||
const lexer = new Lexer(input);
|
||||
expect(lexer.peekChar()).toEqual(-1);
|
||||
expect(lexer.currentChar).toEqual(-1);
|
||||
});
|
||||
|
||||
it("should only return the character after the current position", function() {
|
||||
it("should only return the character after the current position", function () {
|
||||
const input = new StringStream("123");
|
||||
const lexer = new Lexer(input);
|
||||
expect(lexer.peekChar()).toEqual(0x32); // '2'
|
||||
|
@ -88,14 +88,14 @@ describe("parser", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("getNumber", function() {
|
||||
it("should stop parsing numbers at the end of stream", function() {
|
||||
describe("getNumber", function () {
|
||||
it("should stop parsing numbers at the end of stream", function () {
|
||||
const input = new StringStream("11.234");
|
||||
const lexer = new Lexer(input);
|
||||
expect(lexer.getNumber()).toEqual(11.234);
|
||||
});
|
||||
|
||||
it("should parse PostScript numbers", function() {
|
||||
it("should parse PostScript numbers", function () {
|
||||
const numbers = [
|
||||
"-.002",
|
||||
"34.5",
|
||||
|
@ -130,19 +130,19 @@ describe("parser", function() {
|
|||
}
|
||||
});
|
||||
|
||||
it("should ignore double negative before number", function() {
|
||||
it("should ignore double negative before number", function () {
|
||||
const input = new StringStream("--205.88");
|
||||
const lexer = new Lexer(input);
|
||||
expect(lexer.getNumber()).toEqual(-205.88);
|
||||
});
|
||||
|
||||
it("should ignore minus signs in the middle of number", function() {
|
||||
it("should ignore minus signs in the middle of number", function () {
|
||||
const input = new StringStream("205--.88");
|
||||
const lexer = new Lexer(input);
|
||||
expect(lexer.getNumber()).toEqual(205.88);
|
||||
});
|
||||
|
||||
it("should ignore line-breaks between operator and digit in number", function() {
|
||||
it("should ignore line-breaks between operator and digit in number", function () {
|
||||
const minusInput = new StringStream("-\r\n205.88");
|
||||
const minusLexer = new Lexer(minusInput);
|
||||
expect(minusLexer.getNumber()).toEqual(-205.88);
|
||||
|
@ -152,7 +152,7 @@ describe("parser", function() {
|
|||
expect(plusLexer.getNumber()).toEqual(205.88);
|
||||
});
|
||||
|
||||
it("should treat a single decimal point as zero", function() {
|
||||
it("should treat a single decimal point as zero", function () {
|
||||
const input = new StringStream(".");
|
||||
const lexer = new Lexer(input);
|
||||
expect(lexer.getNumber()).toEqual(0);
|
||||
|
@ -162,13 +162,13 @@ describe("parser", function() {
|
|||
const invalidInput = new StringStream(number);
|
||||
const invalidLexer = new Lexer(invalidInput);
|
||||
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return invalidLexer.getNumber();
|
||||
}).toThrowError(FormatError, /^Invalid number:\s/);
|
||||
}
|
||||
});
|
||||
|
||||
it("should handle glued numbers and operators", function() {
|
||||
it("should handle glued numbers and operators", function () {
|
||||
const input = new StringStream("123ET");
|
||||
const lexer = new Lexer(input);
|
||||
expect(lexer.getNumber()).toEqual(123);
|
||||
|
@ -177,10 +177,10 @@ describe("parser", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("getString", function() {
|
||||
it("should stop parsing strings at the end of stream", function() {
|
||||
describe("getString", function () {
|
||||
it("should stop parsing strings at the end of stream", function () {
|
||||
const input = new StringStream("(1$4)");
|
||||
input.getByte = function(super_getByte) {
|
||||
input.getByte = function (super_getByte) {
|
||||
// Simulating end of file using null (see issue 2766).
|
||||
const ch = super_getByte.call(input);
|
||||
return ch === 0x24 /* '$' */ ? -1 : ch;
|
||||
|
@ -189,7 +189,7 @@ describe("parser", function() {
|
|||
expect(lexer.getString()).toEqual("1");
|
||||
});
|
||||
|
||||
it("should ignore escaped CR and LF", function() {
|
||||
it("should ignore escaped CR and LF", function () {
|
||||
// '(\101\<CR><LF>\102)' should be parsed as 'AB'.
|
||||
const input = new StringStream("(\\101\\\r\n\\102\\\r\\103\\\n\\104)");
|
||||
const lexer = new Lexer(input);
|
||||
|
@ -197,8 +197,8 @@ describe("parser", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("getHexString", function() {
|
||||
it("should not throw exception on bad input", function() {
|
||||
describe("getHexString", function () {
|
||||
it("should not throw exception on bad input", function () {
|
||||
// '7 0 2 15 5 2 2 2 4 3 2 4' should be parsed as '70 21 55 22 24 32'.
|
||||
const input = new StringStream("<7 0 2 15 5 2 2 2 4 3 2 4>");
|
||||
const lexer = new Lexer(input);
|
||||
|
@ -206,8 +206,8 @@ describe("parser", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("getName", function() {
|
||||
it("should handle Names with invalid usage of NUMBER SIGN (#)", function() {
|
||||
describe("getName", function () {
|
||||
it("should handle Names with invalid usage of NUMBER SIGN (#)", function () {
|
||||
const inputNames = ["/# 680 0 R", "/#AQwerty", "/#A<</B"];
|
||||
const expectedNames = ["#", "#AQwerty", "#A"];
|
||||
|
||||
|
@ -220,8 +220,8 @@ describe("parser", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Linearization", function() {
|
||||
it("should not find a linearization dictionary", function() {
|
||||
describe("Linearization", function () {
|
||||
it("should not find a linearization dictionary", function () {
|
||||
// Not an actual linearization dictionary.
|
||||
// prettier-ignore
|
||||
const stream1 = new StringStream(
|
||||
|
@ -246,7 +246,7 @@ describe("parser", function() {
|
|||
expect(Linearization.create(stream2)).toEqual(null);
|
||||
});
|
||||
|
||||
it("should accept a valid linearization dictionary", function() {
|
||||
it("should accept a valid linearization dictionary", function () {
|
||||
// prettier-ignore
|
||||
const stream = new StringStream(
|
||||
"131 0 obj\n" +
|
||||
|
@ -276,7 +276,7 @@ describe("parser", function() {
|
|||
it(
|
||||
"should reject a linearization dictionary with invalid " +
|
||||
"integer parameters",
|
||||
function() {
|
||||
function () {
|
||||
// The /L parameter should be equal to the stream length.
|
||||
// prettier-ignore
|
||||
const stream1 = new StringStream(
|
||||
|
@ -292,7 +292,7 @@ describe("parser", function() {
|
|||
">>\n" +
|
||||
"endobj"
|
||||
);
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return Linearization.create(stream1);
|
||||
}).toThrow(
|
||||
new Error(
|
||||
|
@ -316,7 +316,7 @@ describe("parser", function() {
|
|||
">>\n" +
|
||||
"endobj"
|
||||
);
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return Linearization.create(stream2);
|
||||
}).toThrow(
|
||||
new Error(
|
||||
|
@ -339,7 +339,7 @@ describe("parser", function() {
|
|||
">>\n" +
|
||||
"endobj"
|
||||
);
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return Linearization.create(stream3);
|
||||
}).toThrow(
|
||||
new Error(
|
||||
|
@ -349,7 +349,7 @@ describe("parser", function() {
|
|||
}
|
||||
);
|
||||
|
||||
it("should reject a linearization dictionary with invalid hint parameters", function() {
|
||||
it("should reject a linearization dictionary with invalid hint parameters", function () {
|
||||
// The /H parameter should be an array.
|
||||
// prettier-ignore
|
||||
const stream1 = new StringStream(
|
||||
|
@ -365,7 +365,7 @@ describe("parser", function() {
|
|||
">>\n" +
|
||||
"endobj"
|
||||
);
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return Linearization.create(stream1);
|
||||
}).toThrow(
|
||||
new Error("Hint array in the linearization dictionary is invalid.")
|
||||
|
@ -386,7 +386,7 @@ describe("parser", function() {
|
|||
">>\n" +
|
||||
"endobj"
|
||||
);
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return Linearization.create(stream2);
|
||||
}).toThrow(
|
||||
new Error("Hint array in the linearization dictionary is invalid.")
|
||||
|
@ -407,7 +407,7 @@ describe("parser", function() {
|
|||
">>\n" +
|
||||
"endobj"
|
||||
);
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
return Linearization.create(stream3);
|
||||
}).toThrow(
|
||||
new Error("Hint (2) in the linearization dictionary is invalid.")
|
||||
|
|
|
@ -44,13 +44,13 @@ class MockLinkService extends SimpleLinkService {
|
|||
}
|
||||
}
|
||||
|
||||
describe("pdf_find_controller", function() {
|
||||
describe("pdf_find_controller", function () {
|
||||
let eventBus;
|
||||
let pdfFindController;
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
const loadingTask = getDocument(buildGetDocumentParams("tracemonkey.pdf"));
|
||||
loadingTask.promise.then(function(pdfDocument) {
|
||||
loadingTask.promise.then(function (pdfDocument) {
|
||||
eventBus = new EventBus();
|
||||
|
||||
const linkService = new MockLinkService();
|
||||
|
@ -66,13 +66,13 @@ describe("pdf_find_controller", function() {
|
|||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
eventBus = null;
|
||||
pdfFindController = null;
|
||||
});
|
||||
|
||||
function testSearch({ parameters, matchesPerPage, selectedMatch }) {
|
||||
return new Promise(function(resolve) {
|
||||
return new Promise(function (resolve) {
|
||||
pdfFindController.executeCommand("find", parameters);
|
||||
|
||||
// The `updatefindmatchescount` event is only emitted if the page contains
|
||||
|
@ -124,7 +124,7 @@ describe("pdf_find_controller", function() {
|
|||
});
|
||||
}
|
||||
|
||||
it("performs a normal search", function(done) {
|
||||
it("performs a normal search", function (done) {
|
||||
testSearch({
|
||||
parameters: {
|
||||
query: "Dynamic",
|
||||
|
@ -141,7 +141,7 @@ describe("pdf_find_controller", function() {
|
|||
}).then(done);
|
||||
});
|
||||
|
||||
it("performs a normal search and finds the previous result", function(done) {
|
||||
it("performs a normal search and finds the previous result", function (done) {
|
||||
// Page 14 (with page index 13) contains five results. By default, the
|
||||
// first result (match index 0) is selected, so the previous result
|
||||
// should be the fifth result (match index 4).
|
||||
|
@ -161,7 +161,7 @@ describe("pdf_find_controller", function() {
|
|||
}).then(done);
|
||||
});
|
||||
|
||||
it("performs a case sensitive search", function(done) {
|
||||
it("performs a case sensitive search", function (done) {
|
||||
testSearch({
|
||||
parameters: {
|
||||
query: "Dynamic",
|
||||
|
@ -178,7 +178,7 @@ describe("pdf_find_controller", function() {
|
|||
}).then(done);
|
||||
});
|
||||
|
||||
it("performs an entire word search", function(done) {
|
||||
it("performs an entire word search", function (done) {
|
||||
// Page 13 contains both 'Government' and 'Governmental', so the latter
|
||||
// should not be found with entire word search.
|
||||
testSearch({
|
||||
|
@ -197,7 +197,7 @@ describe("pdf_find_controller", function() {
|
|||
}).then(done);
|
||||
});
|
||||
|
||||
it("performs a multiple term (no phrase) search", function(done) {
|
||||
it("performs a multiple term (no phrase) search", function (done) {
|
||||
// Page 9 contains 'alternate' and pages 6 and 9 contain 'solution'.
|
||||
// Both should be found for multiple term (no phrase) search.
|
||||
testSearch({
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
import { CharacterType, getCharacterType } from "../../web/pdf_find_utils.js";
|
||||
|
||||
describe("pdf_find_utils", function() {
|
||||
describe("getCharacterType", function() {
|
||||
it("gets expected character types", function() {
|
||||
describe("pdf_find_utils", function () {
|
||||
describe("getCharacterType", function () {
|
||||
it("gets expected character types", function () {
|
||||
const characters = {
|
||||
A: CharacterType.ALPHA_LETTER,
|
||||
a: CharacterType.ALPHA_LETTER,
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
import { isDestArraysEqual, isDestHashesEqual } from "../../web/pdf_history.js";
|
||||
|
||||
describe("pdf_history", function() {
|
||||
describe("isDestHashesEqual", function() {
|
||||
it("should reject non-equal destination hashes", function() {
|
||||
describe("pdf_history", function () {
|
||||
describe("isDestHashesEqual", function () {
|
||||
it("should reject non-equal destination hashes", function () {
|
||||
expect(isDestHashesEqual(null, "page.157")).toEqual(false);
|
||||
expect(isDestHashesEqual("title.0", "page.157")).toEqual(false);
|
||||
expect(isDestHashesEqual("page=1&zoom=auto", "page.157")).toEqual(false);
|
||||
|
@ -40,7 +40,7 @@ describe("pdf_history", function() {
|
|||
expect(isDestHashesEqual("page.157", destArrayString)).toEqual(false);
|
||||
});
|
||||
|
||||
it("should accept equal destination hashes", function() {
|
||||
it("should accept equal destination hashes", function () {
|
||||
expect(isDestHashesEqual("page.157", "page.157")).toEqual(true);
|
||||
expect(isDestHashesEqual("nameddest=page.157", "page.157")).toEqual(true);
|
||||
|
||||
|
@ -50,14 +50,14 @@ describe("pdf_history", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isDestArraysEqual", function() {
|
||||
describe("isDestArraysEqual", function () {
|
||||
const firstDest = [{ num: 1, gen: 0 }, { name: "XYZ" }, 0, 375, null];
|
||||
const secondDest = [{ num: 5, gen: 0 }, { name: "XYZ" }, 0, 375, null];
|
||||
const thirdDest = [{ num: 1, gen: 0 }, { name: "XYZ" }, 750, 0, null];
|
||||
const fourthDest = [{ num: 1, gen: 0 }, { name: "XYZ" }, 0, 375, 1.0];
|
||||
const fifthDest = [{ gen: 0, num: 1 }, { name: "XYZ" }, 0, 375, null];
|
||||
|
||||
it("should reject non-equal destination arrays", function() {
|
||||
it("should reject non-equal destination arrays", function () {
|
||||
expect(isDestArraysEqual(firstDest, undefined)).toEqual(false);
|
||||
expect(isDestArraysEqual(firstDest, [1, 2, 3, 4, 5])).toEqual(false);
|
||||
|
||||
|
@ -66,7 +66,7 @@ describe("pdf_history", function() {
|
|||
expect(isDestArraysEqual(firstDest, fourthDest)).toEqual(false);
|
||||
});
|
||||
|
||||
it("should accept equal destination arrays", function() {
|
||||
it("should accept equal destination arrays", function () {
|
||||
expect(isDestArraysEqual(firstDest, firstDest)).toEqual(true);
|
||||
expect(isDestArraysEqual(firstDest, fifthDest)).toEqual(true);
|
||||
|
||||
|
|
|
@ -27,15 +27,15 @@ import {
|
|||
} from "../../src/core/primitives.js";
|
||||
import { XRefMock } from "./test_utils.js";
|
||||
|
||||
describe("primitives", function() {
|
||||
describe("Name", function() {
|
||||
it("should retain the given name", function() {
|
||||
describe("primitives", function () {
|
||||
describe("Name", function () {
|
||||
it("should retain the given name", function () {
|
||||
var givenName = "Font";
|
||||
var name = Name.get(givenName);
|
||||
expect(name.name).toEqual(givenName);
|
||||
});
|
||||
|
||||
it("should create only one object for a name and cache it", function() {
|
||||
it("should create only one object for a name and cache it", function () {
|
||||
var firstFont = Name.get("Font");
|
||||
var secondFont = Name.get("Font");
|
||||
var firstSubtype = Name.get("Subtype");
|
||||
|
@ -47,14 +47,14 @@ describe("primitives", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Cmd", function() {
|
||||
it("should retain the given cmd name", function() {
|
||||
describe("Cmd", function () {
|
||||
it("should retain the given cmd name", function () {
|
||||
var givenCmd = "BT";
|
||||
var cmd = Cmd.get(givenCmd);
|
||||
expect(cmd.cmd).toEqual(givenCmd);
|
||||
});
|
||||
|
||||
it("should create only one object for a command and cache it", function() {
|
||||
it("should create only one object for a command and cache it", function () {
|
||||
var firstBT = Cmd.get("BT");
|
||||
var secondBT = Cmd.get("BT");
|
||||
var firstET = Cmd.get("ET");
|
||||
|
@ -66,13 +66,13 @@ describe("primitives", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Dict", function() {
|
||||
var checkInvalidHasValues = function(dict) {
|
||||
describe("Dict", function () {
|
||||
var checkInvalidHasValues = function (dict) {
|
||||
expect(dict.has()).toBeFalsy();
|
||||
expect(dict.has("Prev")).toBeFalsy();
|
||||
};
|
||||
|
||||
var checkInvalidKeyValues = function(dict) {
|
||||
var checkInvalidKeyValues = function (dict) {
|
||||
expect(dict.get()).toBeUndefined();
|
||||
expect(dict.get("Prev")).toBeUndefined();
|
||||
expect(dict.get("Decode", "D")).toBeUndefined();
|
||||
|
@ -85,7 +85,7 @@ describe("primitives", function() {
|
|||
var testFontFile2 = "file2";
|
||||
var testFontFile3 = "file3";
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
emptyDict = new Dict();
|
||||
|
||||
dictWithSizeKey = new Dict();
|
||||
|
@ -99,16 +99,16 @@ describe("primitives", function() {
|
|||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
emptyDict = dictWithSizeKey = dictWithManyKeys = null;
|
||||
});
|
||||
|
||||
it("should return invalid values for unknown keys", function() {
|
||||
it("should return invalid values for unknown keys", function () {
|
||||
checkInvalidHasValues(emptyDict);
|
||||
checkInvalidKeyValues(emptyDict);
|
||||
});
|
||||
|
||||
it("should return correct value for stored Size key", function() {
|
||||
it("should return correct value for stored Size key", function () {
|
||||
expect(dictWithSizeKey.has("Size")).toBeTruthy();
|
||||
|
||||
expect(dictWithSizeKey.get("Size")).toEqual(storedSize);
|
||||
|
@ -116,14 +116,14 @@ describe("primitives", function() {
|
|||
expect(dictWithSizeKey.get("Prev", "Root", "Size")).toEqual(storedSize);
|
||||
});
|
||||
|
||||
it("should return invalid values for unknown keys when Size key is stored", function() {
|
||||
it("should return invalid values for unknown keys when Size key is stored", function () {
|
||||
checkInvalidHasValues(dictWithSizeKey);
|
||||
checkInvalidKeyValues(dictWithSizeKey);
|
||||
});
|
||||
|
||||
it("should not accept to set a key with an undefined value", function() {
|
||||
it("should not accept to set a key with an undefined value", function () {
|
||||
const dict = new Dict();
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
dict.set("Size");
|
||||
}).toThrow(new Error('Dict.set: The "value" cannot be undefined.'));
|
||||
|
||||
|
@ -132,7 +132,7 @@ describe("primitives", function() {
|
|||
checkInvalidKeyValues(dict);
|
||||
});
|
||||
|
||||
it("should return correct values for multiple stored keys", function() {
|
||||
it("should return correct values for multiple stored keys", function () {
|
||||
expect(dictWithManyKeys.has("FontFile")).toBeTruthy();
|
||||
expect(dictWithManyKeys.has("FontFile2")).toBeTruthy();
|
||||
expect(dictWithManyKeys.has("FontFile3")).toBeTruthy();
|
||||
|
@ -146,24 +146,24 @@ describe("primitives", function() {
|
|||
).toEqual(testFontFile);
|
||||
});
|
||||
|
||||
it("should asynchronously fetch unknown keys", function(done) {
|
||||
it("should asynchronously fetch unknown keys", function (done) {
|
||||
var keyPromises = [
|
||||
dictWithManyKeys.getAsync("Size"),
|
||||
dictWithSizeKey.getAsync("FontFile", "FontFile2", "FontFile3"),
|
||||
];
|
||||
|
||||
Promise.all(keyPromises)
|
||||
.then(function(values) {
|
||||
.then(function (values) {
|
||||
expect(values[0]).toBeUndefined();
|
||||
expect(values[1]).toBeUndefined();
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
|
||||
it("should asynchronously fetch correct values for multiple stored keys", function(done) {
|
||||
it("should asynchronously fetch correct values for multiple stored keys", function (done) {
|
||||
var keyPromises = [
|
||||
dictWithManyKeys.getAsync("FontFile3"),
|
||||
dictWithManyKeys.getAsync("FontFile2", "FontFile3"),
|
||||
|
@ -171,18 +171,18 @@ describe("primitives", function() {
|
|||
];
|
||||
|
||||
Promise.all(keyPromises)
|
||||
.then(function(values) {
|
||||
.then(function (values) {
|
||||
expect(values[0]).toEqual(testFontFile3);
|
||||
expect(values[1]).toEqual(testFontFile2);
|
||||
expect(values[2]).toEqual(testFontFile);
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
|
||||
it("should callback for each stored key", function() {
|
||||
it("should callback for each stored key", function () {
|
||||
var callbackSpy = jasmine.createSpy("spy on callback in dictionary");
|
||||
|
||||
dictWithManyKeys.forEach(callbackSpy);
|
||||
|
@ -195,7 +195,7 @@ describe("primitives", function() {
|
|||
expect(callbackSpyCalls.count()).toEqual(3);
|
||||
});
|
||||
|
||||
it("should handle keys pointing to indirect objects, both sync and async", function(done) {
|
||||
it("should handle keys pointing to indirect objects, both sync and async", function (done) {
|
||||
var fontRef = Ref.get(1, 0);
|
||||
var xref = new XRefMock([{ ref: fontRef, data: testFontFile }]);
|
||||
var fontDict = new Dict(xref);
|
||||
|
@ -208,16 +208,16 @@ describe("primitives", function() {
|
|||
|
||||
fontDict
|
||||
.getAsync("FontFile", "FontFile2", "FontFile3")
|
||||
.then(function(value) {
|
||||
.then(function (value) {
|
||||
expect(value).toEqual(testFontFile);
|
||||
done();
|
||||
})
|
||||
.catch(function(reason) {
|
||||
.catch(function (reason) {
|
||||
done.fail(reason);
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle arrays containing indirect objects", function() {
|
||||
it("should handle arrays containing indirect objects", function () {
|
||||
var minCoordRef = Ref.get(1, 0),
|
||||
maxCoordRef = Ref.get(2, 0);
|
||||
var minCoord = 0,
|
||||
|
@ -243,14 +243,14 @@ describe("primitives", function() {
|
|||
]);
|
||||
});
|
||||
|
||||
it("should get all key names", function() {
|
||||
it("should get all key names", function () {
|
||||
var expectedKeys = ["FontFile", "FontFile2", "FontFile3"];
|
||||
var keys = dictWithManyKeys.getKeys();
|
||||
|
||||
expect(keys.sort()).toEqual(expectedKeys);
|
||||
});
|
||||
|
||||
it("should create only one object for Dict.empty", function() {
|
||||
it("should create only one object for Dict.empty", function () {
|
||||
var firstDictEmpty = Dict.empty;
|
||||
var secondDictEmpty = Dict.empty;
|
||||
|
||||
|
@ -258,7 +258,7 @@ describe("primitives", function() {
|
|||
expect(firstDictEmpty).not.toBe(emptyDict);
|
||||
});
|
||||
|
||||
it("should correctly merge dictionaries", function() {
|
||||
it("should correctly merge dictionaries", function () {
|
||||
var expectedKeys = ["FontFile", "FontFile2", "FontFile3", "Size"];
|
||||
|
||||
var fontFileDict = new Dict();
|
||||
|
@ -275,8 +275,8 @@ describe("primitives", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Ref", function() {
|
||||
it("should retain the stored values", function() {
|
||||
describe("Ref", function () {
|
||||
it("should retain the stored values", function () {
|
||||
var storedNum = 4;
|
||||
var storedGen = 2;
|
||||
var ref = Ref.get(storedNum, storedGen);
|
||||
|
@ -285,14 +285,14 @@ describe("primitives", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("RefSet", function() {
|
||||
it("should have a stored value", function() {
|
||||
describe("RefSet", function () {
|
||||
it("should have a stored value", function () {
|
||||
var ref = Ref.get(4, 2);
|
||||
var refset = new RefSet();
|
||||
refset.put(ref);
|
||||
expect(refset.has(ref)).toBeTruthy();
|
||||
});
|
||||
it("should not have an unknown value", function() {
|
||||
it("should not have an unknown value", function () {
|
||||
var ref = Ref.get(4, 2);
|
||||
var refset = new RefSet();
|
||||
expect(refset.has(ref)).toBeFalsy();
|
||||
|
@ -303,55 +303,55 @@ describe("primitives", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isName", function() {
|
||||
it("handles non-names", function() {
|
||||
describe("isName", function () {
|
||||
it("handles non-names", function () {
|
||||
var nonName = {};
|
||||
expect(isName(nonName)).toEqual(false);
|
||||
});
|
||||
|
||||
it("handles names", function() {
|
||||
it("handles names", function () {
|
||||
var name = Name.get("Font");
|
||||
expect(isName(name)).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles names with name check", function() {
|
||||
it("handles names with name check", function () {
|
||||
var name = Name.get("Font");
|
||||
expect(isName(name, "Font")).toEqual(true);
|
||||
expect(isName(name, "Subtype")).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isCmd", function() {
|
||||
it("handles non-commands", function() {
|
||||
describe("isCmd", function () {
|
||||
it("handles non-commands", function () {
|
||||
var nonCmd = {};
|
||||
expect(isCmd(nonCmd)).toEqual(false);
|
||||
});
|
||||
|
||||
it("handles commands", function() {
|
||||
it("handles commands", function () {
|
||||
var cmd = Cmd.get("BT");
|
||||
expect(isCmd(cmd)).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles commands with cmd check", function() {
|
||||
it("handles commands with cmd check", function () {
|
||||
var cmd = Cmd.get("BT");
|
||||
expect(isCmd(cmd, "BT")).toEqual(true);
|
||||
expect(isCmd(cmd, "ET")).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isDict", function() {
|
||||
it("handles non-dictionaries", function() {
|
||||
describe("isDict", function () {
|
||||
it("handles non-dictionaries", function () {
|
||||
var nonDict = {};
|
||||
expect(isDict(nonDict)).toEqual(false);
|
||||
});
|
||||
|
||||
it("handles empty dictionaries with type check", function() {
|
||||
it("handles empty dictionaries with type check", function () {
|
||||
var dict = Dict.empty;
|
||||
expect(isDict(dict)).toEqual(true);
|
||||
expect(isDict(dict, "Page")).toEqual(false);
|
||||
});
|
||||
|
||||
it("handles dictionaries with type check", function() {
|
||||
it("handles dictionaries with type check", function () {
|
||||
var dict = new Dict();
|
||||
dict.set("Type", Name.get("Page"));
|
||||
expect(isDict(dict, "Page")).toEqual(true);
|
||||
|
@ -359,26 +359,26 @@ describe("primitives", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isRef", function() {
|
||||
it("handles non-refs", function() {
|
||||
describe("isRef", function () {
|
||||
it("handles non-refs", function () {
|
||||
var nonRef = {};
|
||||
expect(isRef(nonRef)).toEqual(false);
|
||||
});
|
||||
|
||||
it("handles refs", function() {
|
||||
it("handles refs", function () {
|
||||
var ref = Ref.get(1, 0);
|
||||
expect(isRef(ref)).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isRefsEqual", function() {
|
||||
it("should handle Refs pointing to the same object", function() {
|
||||
describe("isRefsEqual", function () {
|
||||
it("should handle Refs pointing to the same object", function () {
|
||||
var ref1 = Ref.get(1, 0);
|
||||
var ref2 = Ref.get(1, 0);
|
||||
expect(isRefsEqual(ref1, ref2)).toEqual(true);
|
||||
});
|
||||
|
||||
it("should handle Refs pointing to different objects", function() {
|
||||
it("should handle Refs pointing to different objects", function () {
|
||||
var ref1 = Ref.get(1, 0);
|
||||
var ref2 = Ref.get(2, 0);
|
||||
expect(isRefsEqual(ref1, ref2)).toEqual(false);
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
import { PredictorStream, Stream } from "../../src/core/stream.js";
|
||||
import { Dict } from "../../src/core/primitives.js";
|
||||
|
||||
describe("stream", function() {
|
||||
beforeEach(function() {
|
||||
describe("stream", function () {
|
||||
beforeEach(function () {
|
||||
jasmine.addMatchers({
|
||||
toMatchTypedArray(util, customEqualityTesters) {
|
||||
return {
|
||||
|
@ -47,8 +47,8 @@ describe("stream", function() {
|
|||
},
|
||||
});
|
||||
});
|
||||
describe("PredictorStream", function() {
|
||||
it("should decode simple predictor data", function() {
|
||||
describe("PredictorStream", function () {
|
||||
it("should decode simple predictor data", function () {
|
||||
var dict = new Dict();
|
||||
dict.set("Predictor", 12);
|
||||
dict.set("Colors", 1);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var TestReporter = function(browser, appPath) {
|
||||
var TestReporter = function (browser, appPath) {
|
||||
function send(action, json, cb) {
|
||||
var r = new XMLHttpRequest();
|
||||
// (The POST URI is ignored atm.)
|
||||
|
@ -42,20 +42,20 @@ var TestReporter = function(browser, appPath) {
|
|||
send("/tellMeToQuit?path=" + escape(appPath), {});
|
||||
}
|
||||
|
||||
this.now = function() {
|
||||
this.now = function () {
|
||||
return new Date().getTime();
|
||||
};
|
||||
|
||||
this.jasmineStarted = function(suiteInfo) {
|
||||
this.jasmineStarted = function (suiteInfo) {
|
||||
this.runnerStartTime = this.now();
|
||||
sendInfo("Started tests for " + browser + ".");
|
||||
};
|
||||
|
||||
this.suiteStarted = function(result) {};
|
||||
this.suiteStarted = function (result) {};
|
||||
|
||||
this.specStarted = function(result) {};
|
||||
this.specStarted = function (result) {};
|
||||
|
||||
this.specDone = function(result) {
|
||||
this.specDone = function (result) {
|
||||
if (result.failedExpectations.length === 0) {
|
||||
sendResult("TEST-PASSED", result.description);
|
||||
} else {
|
||||
|
@ -68,9 +68,9 @@ var TestReporter = function(browser, appPath) {
|
|||
}
|
||||
};
|
||||
|
||||
this.suiteDone = function(result) {};
|
||||
this.suiteDone = function (result) {};
|
||||
|
||||
this.jasmineDone = function() {
|
||||
this.jasmineDone = function () {
|
||||
// Give the test.py some time process any queued up requests
|
||||
setTimeout(sendQuitRequest, 500);
|
||||
};
|
||||
|
|
|
@ -17,8 +17,8 @@ import { SEAC_ANALYSIS_ENABLED } from "../../src/core/fonts.js";
|
|||
import { StringStream } from "../../src/core/stream.js";
|
||||
import { Type1Parser } from "../../src/core/type1_parser.js";
|
||||
|
||||
describe("Type1Parser", function() {
|
||||
it("splits tokens", function() {
|
||||
describe("Type1Parser", function () {
|
||||
it("splits tokens", function () {
|
||||
var stream = new StringStream("/BlueValues[-17 0]noaccess def");
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.getToken()).toEqual("/");
|
||||
|
@ -32,7 +32,7 @@ describe("Type1Parser", function() {
|
|||
expect(parser.getToken()).toEqual(null);
|
||||
});
|
||||
|
||||
it("handles glued tokens", function() {
|
||||
it("handles glued tokens", function () {
|
||||
var stream = new StringStream("dup/CharStrings");
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.getToken()).toEqual("dup");
|
||||
|
@ -40,27 +40,27 @@ describe("Type1Parser", function() {
|
|||
expect(parser.getToken()).toEqual("CharStrings");
|
||||
});
|
||||
|
||||
it("ignores whitespace", function() {
|
||||
it("ignores whitespace", function () {
|
||||
var stream = new StringStream("\nab c\t");
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.getToken()).toEqual("ab");
|
||||
expect(parser.getToken()).toEqual("c");
|
||||
});
|
||||
|
||||
it("parses numbers", function() {
|
||||
it("parses numbers", function () {
|
||||
var stream = new StringStream("123");
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.readNumber()).toEqual(123);
|
||||
});
|
||||
|
||||
it("parses booleans", function() {
|
||||
it("parses booleans", function () {
|
||||
var stream = new StringStream("true false");
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.readBoolean()).toEqual(1);
|
||||
expect(parser.readBoolean()).toEqual(0);
|
||||
});
|
||||
|
||||
it("parses number arrays", function() {
|
||||
it("parses number arrays", function () {
|
||||
var stream = new StringStream("[1 2]");
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.readNumberArray()).toEqual([1, 2]);
|
||||
|
@ -70,7 +70,7 @@ describe("Type1Parser", function() {
|
|||
expect(parser.readNumberArray()).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
it("skips comments", function() {
|
||||
it("skips comments", function () {
|
||||
var stream = new StringStream(
|
||||
"%!PS-AdobeFont-1.0: CMSY10 003.002\n" +
|
||||
"%%Title: CMSY10\n" +
|
||||
|
@ -81,7 +81,7 @@ describe("Type1Parser", function() {
|
|||
expect(parser.getToken()).toEqual("FontDirectory");
|
||||
});
|
||||
|
||||
it("parses font program", function() {
|
||||
it("parses font program", function () {
|
||||
var stream = new StringStream(
|
||||
"/ExpansionFactor 99\n" +
|
||||
"/Subrs 1 array\n" +
|
||||
|
@ -97,7 +97,7 @@ describe("Type1Parser", function() {
|
|||
expect(program.properties.privateData.ExpansionFactor).toEqual(99);
|
||||
});
|
||||
|
||||
it("parses font header font matrix", function() {
|
||||
it("parses font header font matrix", function () {
|
||||
var stream = new StringStream(
|
||||
"/FontMatrix [0.001 0 0 0.001 0 0 ]readonly def\n"
|
||||
);
|
||||
|
@ -107,7 +107,7 @@ describe("Type1Parser", function() {
|
|||
expect(props.fontMatrix).toEqual([0.001, 0, 0, 0.001, 0, 0]);
|
||||
});
|
||||
|
||||
it("parses font header encoding", function() {
|
||||
it("parses font header encoding", function () {
|
||||
var stream = new StringStream(
|
||||
"/Encoding 256 array\n" +
|
||||
"0 1 255 {1 index exch /.notdef put} for\n" +
|
||||
|
|
|
@ -29,8 +29,8 @@ import {
|
|||
import { createObjectURL } from "../../src/shared/util.js";
|
||||
import { isNodeJS } from "../../src/shared/is_node.js";
|
||||
|
||||
describe("ui_utils", function() {
|
||||
describe("binary search", function() {
|
||||
describe("ui_utils", function () {
|
||||
describe("binary search", function () {
|
||||
function isTrue(boolean) {
|
||||
return boolean;
|
||||
}
|
||||
|
@ -38,28 +38,28 @@ describe("ui_utils", function() {
|
|||
return number > 3;
|
||||
}
|
||||
|
||||
it("empty array", function() {
|
||||
it("empty array", function () {
|
||||
expect(binarySearchFirstItem([], isTrue)).toEqual(0);
|
||||
});
|
||||
it("single boolean entry", function() {
|
||||
it("single boolean entry", function () {
|
||||
expect(binarySearchFirstItem([false], isTrue)).toEqual(1);
|
||||
expect(binarySearchFirstItem([true], isTrue)).toEqual(0);
|
||||
});
|
||||
it("three boolean entries", function() {
|
||||
it("three boolean entries", function () {
|
||||
expect(binarySearchFirstItem([true, true, true], isTrue)).toEqual(0);
|
||||
expect(binarySearchFirstItem([false, true, true], isTrue)).toEqual(1);
|
||||
expect(binarySearchFirstItem([false, false, true], isTrue)).toEqual(2);
|
||||
expect(binarySearchFirstItem([false, false, false], isTrue)).toEqual(3);
|
||||
});
|
||||
it("three numeric entries", function() {
|
||||
it("three numeric entries", function () {
|
||||
expect(binarySearchFirstItem([0, 1, 2], isGreater3)).toEqual(3);
|
||||
expect(binarySearchFirstItem([2, 3, 4], isGreater3)).toEqual(2);
|
||||
expect(binarySearchFirstItem([4, 5, 6], isGreater3)).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getPDFFileNameFromURL", function() {
|
||||
it("gets PDF filename", function() {
|
||||
describe("getPDFFileNameFromURL", function () {
|
||||
it("gets PDF filename", function () {
|
||||
// Relative URL
|
||||
expect(getPDFFileNameFromURL("/pdfs/file1.pdf")).toEqual("file1.pdf");
|
||||
// Absolute URL
|
||||
|
@ -68,7 +68,7 @@ describe("ui_utils", function() {
|
|||
).toEqual("file2.pdf");
|
||||
});
|
||||
|
||||
it("gets fallback filename", function() {
|
||||
it("gets fallback filename", function () {
|
||||
// Relative URL
|
||||
expect(getPDFFileNameFromURL("/pdfs/file1.txt")).toEqual("document.pdf");
|
||||
// Absolute URL
|
||||
|
@ -77,7 +77,7 @@ describe("ui_utils", function() {
|
|||
).toEqual("document.pdf");
|
||||
});
|
||||
|
||||
it("gets custom fallback filename", function() {
|
||||
it("gets custom fallback filename", function () {
|
||||
// Relative URL
|
||||
expect(getPDFFileNameFromURL("/pdfs/file1.txt", "qwerty1.pdf")).toEqual(
|
||||
"qwerty1.pdf"
|
||||
|
@ -94,13 +94,13 @@ describe("ui_utils", function() {
|
|||
expect(getPDFFileNameFromURL("/pdfs/file3.txt", "")).toEqual("");
|
||||
});
|
||||
|
||||
it("gets fallback filename when url is not a string", function() {
|
||||
it("gets fallback filename when url is not a string", function () {
|
||||
expect(getPDFFileNameFromURL(null)).toEqual("document.pdf");
|
||||
|
||||
expect(getPDFFileNameFromURL(null, "file.pdf")).toEqual("file.pdf");
|
||||
});
|
||||
|
||||
it("gets PDF filename from URL containing leading/trailing whitespace", function() {
|
||||
it("gets PDF filename from URL containing leading/trailing whitespace", function () {
|
||||
// Relative URL
|
||||
expect(getPDFFileNameFromURL(" /pdfs/file1.pdf ")).toEqual(
|
||||
"file1.pdf"
|
||||
|
@ -111,7 +111,7 @@ describe("ui_utils", function() {
|
|||
).toEqual("file2.pdf");
|
||||
});
|
||||
|
||||
it("gets PDF filename from query string", function() {
|
||||
it("gets PDF filename from query string", function () {
|
||||
// Relative URL
|
||||
expect(getPDFFileNameFromURL("/pdfs/pdfs.html?name=file1.pdf")).toEqual(
|
||||
"file1.pdf"
|
||||
|
@ -122,7 +122,7 @@ describe("ui_utils", function() {
|
|||
).toEqual("file2.pdf");
|
||||
});
|
||||
|
||||
it("gets PDF filename from hash string", function() {
|
||||
it("gets PDF filename from hash string", function () {
|
||||
// Relative URL
|
||||
expect(getPDFFileNameFromURL("/pdfs/pdfs.html#name=file1.pdf")).toEqual(
|
||||
"file1.pdf"
|
||||
|
@ -133,7 +133,7 @@ describe("ui_utils", function() {
|
|||
).toEqual("file2.pdf");
|
||||
});
|
||||
|
||||
it("gets correct PDF filename when multiple ones are present", function() {
|
||||
it("gets correct PDF filename when multiple ones are present", function () {
|
||||
// Relative URL
|
||||
expect(getPDFFileNameFromURL("/pdfs/file1.pdf?name=file.pdf")).toEqual(
|
||||
"file1.pdf"
|
||||
|
@ -144,7 +144,7 @@ describe("ui_utils", function() {
|
|||
).toEqual("file2.pdf");
|
||||
});
|
||||
|
||||
it("gets PDF filename from URI-encoded data", function() {
|
||||
it("gets PDF filename from URI-encoded data", function () {
|
||||
var encodedUrl = encodeURIComponent(
|
||||
"http://www.example.com/pdfs/file1.pdf"
|
||||
);
|
||||
|
@ -156,13 +156,13 @@ describe("ui_utils", function() {
|
|||
expect(getPDFFileNameFromURL(encodedUrlWithQuery)).toEqual("file2.pdf");
|
||||
});
|
||||
|
||||
it("gets PDF filename from data mistaken for URI-encoded", function() {
|
||||
it("gets PDF filename from data mistaken for URI-encoded", function () {
|
||||
expect(getPDFFileNameFromURL("/pdfs/%AA.pdf")).toEqual("%AA.pdf");
|
||||
|
||||
expect(getPDFFileNameFromURL("/pdfs/%2F.pdf")).toEqual("%2F.pdf");
|
||||
});
|
||||
|
||||
it("gets PDF filename from (some) standard protocols", function() {
|
||||
it("gets PDF filename from (some) standard protocols", function () {
|
||||
// HTTP
|
||||
expect(getPDFFileNameFromURL("http://www.example.com/file1.pdf")).toEqual(
|
||||
"file1.pdf"
|
||||
|
@ -181,7 +181,7 @@ describe("ui_utils", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it('gets PDF filename from query string appended to "blob:" URL', function() {
|
||||
it('gets PDF filename from query string appended to "blob:" URL', function () {
|
||||
if (isNodeJS) {
|
||||
pending("Blob in not supported in Node.js.");
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ describe("ui_utils", function() {
|
|||
expect(getPDFFileNameFromURL(blobUrl + "?file.pdf")).toEqual("file.pdf");
|
||||
});
|
||||
|
||||
it('gets fallback filename from query string appended to "data:" URL', function() {
|
||||
it('gets fallback filename from query string appended to "data:" URL', function () {
|
||||
var typedArray = new Uint8Array([1, 2, 3, 4, 5]);
|
||||
var dataUrl = createObjectURL(
|
||||
typedArray,
|
||||
|
@ -214,21 +214,21 @@ describe("ui_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("EventBus", function() {
|
||||
it("dispatch event", function() {
|
||||
describe("EventBus", function () {
|
||||
it("dispatch event", function () {
|
||||
var eventBus = new EventBus();
|
||||
var count = 0;
|
||||
eventBus.on("test", function(evt) {
|
||||
eventBus.on("test", function (evt) {
|
||||
expect(evt).toEqual(undefined);
|
||||
count++;
|
||||
});
|
||||
eventBus.dispatch("test");
|
||||
expect(count).toEqual(1);
|
||||
});
|
||||
it("dispatch event with arguments", function() {
|
||||
it("dispatch event with arguments", function () {
|
||||
const eventBus = new EventBus();
|
||||
let count = 0;
|
||||
eventBus.on("test", function(evt) {
|
||||
eventBus.on("test", function (evt) {
|
||||
expect(evt).toEqual({ abc: 123 });
|
||||
count++;
|
||||
});
|
||||
|
@ -237,42 +237,42 @@ describe("ui_utils", function() {
|
|||
});
|
||||
expect(count).toEqual(1);
|
||||
});
|
||||
it("dispatch different event", function() {
|
||||
it("dispatch different event", function () {
|
||||
var eventBus = new EventBus();
|
||||
var count = 0;
|
||||
eventBus.on("test", function() {
|
||||
eventBus.on("test", function () {
|
||||
count++;
|
||||
});
|
||||
eventBus.dispatch("nottest");
|
||||
expect(count).toEqual(0);
|
||||
});
|
||||
it("dispatch event multiple times", function() {
|
||||
it("dispatch event multiple times", function () {
|
||||
var eventBus = new EventBus();
|
||||
var count = 0;
|
||||
eventBus.dispatch("test");
|
||||
eventBus.on("test", function() {
|
||||
eventBus.on("test", function () {
|
||||
count++;
|
||||
});
|
||||
eventBus.dispatch("test");
|
||||
eventBus.dispatch("test");
|
||||
expect(count).toEqual(2);
|
||||
});
|
||||
it("dispatch event to multiple handlers", function() {
|
||||
it("dispatch event to multiple handlers", function () {
|
||||
var eventBus = new EventBus();
|
||||
var count = 0;
|
||||
eventBus.on("test", function() {
|
||||
eventBus.on("test", function () {
|
||||
count++;
|
||||
});
|
||||
eventBus.on("test", function() {
|
||||
eventBus.on("test", function () {
|
||||
count++;
|
||||
});
|
||||
eventBus.dispatch("test");
|
||||
expect(count).toEqual(2);
|
||||
});
|
||||
it("dispatch to detached", function() {
|
||||
it("dispatch to detached", function () {
|
||||
var eventBus = new EventBus();
|
||||
var count = 0;
|
||||
var listener = function() {
|
||||
var listener = function () {
|
||||
count++;
|
||||
};
|
||||
eventBus.on("test", listener);
|
||||
|
@ -281,27 +281,27 @@ describe("ui_utils", function() {
|
|||
eventBus.dispatch("test");
|
||||
expect(count).toEqual(1);
|
||||
});
|
||||
it("dispatch to wrong detached", function() {
|
||||
it("dispatch to wrong detached", function () {
|
||||
var eventBus = new EventBus();
|
||||
var count = 0;
|
||||
eventBus.on("test", function() {
|
||||
eventBus.on("test", function () {
|
||||
count++;
|
||||
});
|
||||
eventBus.dispatch("test");
|
||||
eventBus.off("test", function() {
|
||||
eventBus.off("test", function () {
|
||||
count++;
|
||||
});
|
||||
eventBus.dispatch("test");
|
||||
expect(count).toEqual(2);
|
||||
});
|
||||
it("dispatch to detached during handling", function() {
|
||||
it("dispatch to detached during handling", function () {
|
||||
var eventBus = new EventBus();
|
||||
var count = 0;
|
||||
var listener1 = function() {
|
||||
var listener1 = function () {
|
||||
eventBus.off("test", listener2);
|
||||
count++;
|
||||
};
|
||||
var listener2 = function() {
|
||||
var listener2 = function () {
|
||||
eventBus.off("test", listener1);
|
||||
count++;
|
||||
};
|
||||
|
@ -312,13 +312,13 @@ describe("ui_utils", function() {
|
|||
expect(count).toEqual(2);
|
||||
});
|
||||
|
||||
it("should not re-dispatch to DOM", function(done) {
|
||||
it("should not re-dispatch to DOM", function (done) {
|
||||
if (isNodeJS) {
|
||||
pending("Document in not supported in Node.js.");
|
||||
}
|
||||
const eventBus = new EventBus();
|
||||
let count = 0;
|
||||
eventBus.on("test", function(evt) {
|
||||
eventBus.on("test", function (evt) {
|
||||
expect(evt).toEqual(undefined);
|
||||
count++;
|
||||
});
|
||||
|
@ -338,8 +338,8 @@ describe("ui_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isValidRotation", function() {
|
||||
it("should reject non-integer angles", function() {
|
||||
describe("isValidRotation", function () {
|
||||
it("should reject non-integer angles", function () {
|
||||
expect(isValidRotation()).toEqual(false);
|
||||
expect(isValidRotation(null)).toEqual(false);
|
||||
expect(isValidRotation(NaN)).toEqual(false);
|
||||
|
@ -348,12 +348,12 @@ describe("ui_utils", function() {
|
|||
expect(isValidRotation(90.5)).toEqual(false);
|
||||
});
|
||||
|
||||
it("should reject non-multiple of 90 degree angles", function() {
|
||||
it("should reject non-multiple of 90 degree angles", function () {
|
||||
expect(isValidRotation(45)).toEqual(false);
|
||||
expect(isValidRotation(-123)).toEqual(false);
|
||||
});
|
||||
|
||||
it("should accept valid angles", function() {
|
||||
it("should accept valid angles", function () {
|
||||
expect(isValidRotation(0)).toEqual(true);
|
||||
expect(isValidRotation(90)).toEqual(true);
|
||||
expect(isValidRotation(-270)).toEqual(true);
|
||||
|
@ -361,8 +361,8 @@ describe("ui_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isPortraitOrientation", function() {
|
||||
it("should be portrait orientation", function() {
|
||||
describe("isPortraitOrientation", function () {
|
||||
it("should be portrait orientation", function () {
|
||||
expect(
|
||||
isPortraitOrientation({
|
||||
width: 200,
|
||||
|
@ -378,7 +378,7 @@ describe("ui_utils", function() {
|
|||
).toEqual(true);
|
||||
});
|
||||
|
||||
it("should be landscape orientation", function() {
|
||||
it("should be landscape orientation", function () {
|
||||
expect(
|
||||
isPortraitOrientation({
|
||||
width: 600,
|
||||
|
@ -388,27 +388,27 @@ describe("ui_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("waitOnEventOrTimeout", function() {
|
||||
describe("waitOnEventOrTimeout", function () {
|
||||
let eventBus;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
eventBus = new EventBus();
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
eventBus = null;
|
||||
});
|
||||
|
||||
it("should reject invalid parameters", function(done) {
|
||||
it("should reject invalid parameters", function (done) {
|
||||
const invalidTarget = waitOnEventOrTimeout({
|
||||
target: "window",
|
||||
name: "DOMContentLoaded",
|
||||
}).then(
|
||||
function() {
|
||||
function () {
|
||||
throw new Error("Should reject invalid parameters.");
|
||||
},
|
||||
function(reason) {
|
||||
function (reason) {
|
||||
expect(reason instanceof Error).toEqual(true);
|
||||
}
|
||||
);
|
||||
|
@ -417,10 +417,10 @@ describe("ui_utils", function() {
|
|||
target: eventBus,
|
||||
name: "",
|
||||
}).then(
|
||||
function() {
|
||||
function () {
|
||||
throw new Error("Should reject invalid parameters.");
|
||||
},
|
||||
function(reason) {
|
||||
function (reason) {
|
||||
expect(reason instanceof Error).toEqual(true);
|
||||
}
|
||||
);
|
||||
|
@ -430,10 +430,10 @@ describe("ui_utils", function() {
|
|||
name: "pagerendered",
|
||||
delay: -1000,
|
||||
}).then(
|
||||
function() {
|
||||
function () {
|
||||
throw new Error("Should reject invalid parameters.");
|
||||
},
|
||||
function(reason) {
|
||||
function (reason) {
|
||||
expect(reason instanceof Error).toEqual(true);
|
||||
}
|
||||
);
|
||||
|
@ -444,7 +444,7 @@ describe("ui_utils", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("should resolve on event, using the DOM", function(done) {
|
||||
it("should resolve on event, using the DOM", function (done) {
|
||||
if (isNodeJS) {
|
||||
pending("Document in not supported in Node.js.");
|
||||
}
|
||||
|
@ -458,13 +458,13 @@ describe("ui_utils", function() {
|
|||
// Immediately dispatch the expected event.
|
||||
button.click();
|
||||
|
||||
buttonClicked.then(function(type) {
|
||||
buttonClicked.then(function (type) {
|
||||
expect(type).toEqual(WaitOnType.EVENT);
|
||||
done();
|
||||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should resolve on timeout, using the DOM", function(done) {
|
||||
it("should resolve on timeout, using the DOM", function (done) {
|
||||
if (isNodeJS) {
|
||||
pending("Document in not supported in Node.js.");
|
||||
}
|
||||
|
@ -477,13 +477,13 @@ describe("ui_utils", function() {
|
|||
});
|
||||
// Do *not* dispatch the event, and wait for the timeout.
|
||||
|
||||
buttonClicked.then(function(type) {
|
||||
buttonClicked.then(function (type) {
|
||||
expect(type).toEqual(WaitOnType.TIMEOUT);
|
||||
done();
|
||||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should resolve on event, using the EventBus", function(done) {
|
||||
it("should resolve on event, using the EventBus", function (done) {
|
||||
const pageRendered = waitOnEventOrTimeout({
|
||||
target: eventBus,
|
||||
name: "pagerendered",
|
||||
|
@ -492,13 +492,13 @@ describe("ui_utils", function() {
|
|||
// Immediately dispatch the expected event.
|
||||
eventBus.dispatch("pagerendered");
|
||||
|
||||
pageRendered.then(function(type) {
|
||||
pageRendered.then(function (type) {
|
||||
expect(type).toEqual(WaitOnType.EVENT);
|
||||
done();
|
||||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should resolve on timeout, using the EventBus", function(done) {
|
||||
it("should resolve on timeout, using the EventBus", function (done) {
|
||||
const pageRendered = waitOnEventOrTimeout({
|
||||
target: eventBus,
|
||||
name: "pagerendered",
|
||||
|
@ -506,15 +506,15 @@ describe("ui_utils", function() {
|
|||
});
|
||||
// Do *not* dispatch the event, and wait for the timeout.
|
||||
|
||||
pageRendered.then(function(type) {
|
||||
pageRendered.then(function (type) {
|
||||
expect(type).toEqual(WaitOnType.TIMEOUT);
|
||||
done();
|
||||
}, done.fail);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getPageSizeInches", function() {
|
||||
it("gets page size (in inches)", function() {
|
||||
describe("getPageSizeInches", function () {
|
||||
it("gets page size (in inches)", function () {
|
||||
const page = {
|
||||
view: [0, 0, 595.28, 841.89],
|
||||
userUnit: 1.0,
|
||||
|
@ -526,7 +526,7 @@ describe("ui_utils", function() {
|
|||
expect(+height.toPrecision(4)).toEqual(11.69);
|
||||
});
|
||||
|
||||
it("gets page size (in inches), for non-default /Rotate entry", function() {
|
||||
it("gets page size (in inches), for non-default /Rotate entry", function () {
|
||||
const pdfPage1 = { view: [0, 0, 612, 792], userUnit: 1, rotate: 0 };
|
||||
const { width: width1, height: height1 } = getPageSizeInches(pdfPage1);
|
||||
|
||||
|
@ -541,7 +541,7 @@ describe("ui_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("getVisibleElements", function() {
|
||||
describe("getVisibleElements", function () {
|
||||
// These values are based on margin/border values in the CSS, but there
|
||||
// isn't any real need for them to be; they just need to take *some* value.
|
||||
const BORDER_WIDTH = 9;
|
||||
|
@ -576,7 +576,7 @@ describe("ui_utils", function() {
|
|||
let lineTop = 0,
|
||||
id = 0;
|
||||
for (const line of lines) {
|
||||
const lineHeight = line.reduce(function(maxHeight, pair) {
|
||||
const lineHeight = line.reduce(function (maxHeight, pair) {
|
||||
return Math.max(maxHeight, pair[1]);
|
||||
}, 0);
|
||||
let offsetLeft = -BORDER_WIDTH;
|
||||
|
@ -640,7 +640,7 @@ describe("ui_utils", function() {
|
|||
// test to the slower implementation above, for a range of scroll viewport
|
||||
// sizes and positions.
|
||||
function scrollOverDocument(pages, horizontally = false) {
|
||||
const size = pages.reduce(function(max, { div }) {
|
||||
const size = pages.reduce(function (max, { div }) {
|
||||
return Math.max(
|
||||
max,
|
||||
horizontally
|
||||
|
@ -677,7 +677,7 @@ describe("ui_utils", function() {
|
|||
}
|
||||
}
|
||||
|
||||
it("with pages of varying height", function() {
|
||||
it("with pages of varying height", function () {
|
||||
const pages = makePages([
|
||||
[
|
||||
[50, 20],
|
||||
|
@ -699,7 +699,7 @@ describe("ui_utils", function() {
|
|||
scrollOverDocument(pages);
|
||||
});
|
||||
|
||||
it("widescreen challenge", function() {
|
||||
it("widescreen challenge", function () {
|
||||
const pages = makePages([
|
||||
[
|
||||
[10, 50],
|
||||
|
@ -726,7 +726,7 @@ describe("ui_utils", function() {
|
|||
scrollOverDocument(pages);
|
||||
});
|
||||
|
||||
it("works with horizontal scrolling", function() {
|
||||
it("works with horizontal scrolling", function () {
|
||||
const pages = makePages([
|
||||
[
|
||||
[10, 50],
|
||||
|
@ -737,7 +737,7 @@ describe("ui_utils", function() {
|
|||
scrollOverDocument(pages, true);
|
||||
});
|
||||
|
||||
it("handles `sortByVisibility` correctly", function() {
|
||||
it("handles `sortByVisibility` correctly", function () {
|
||||
const scrollEl = {
|
||||
scrollTop: 75,
|
||||
scrollLeft: 0,
|
||||
|
@ -765,7 +765,7 @@ describe("ui_utils", function() {
|
|||
expect(viewsSortedOrder).toEqual([1, 2, 0]);
|
||||
});
|
||||
|
||||
it("handles views being empty", function() {
|
||||
it("handles views being empty", function () {
|
||||
const scrollEl = {
|
||||
scrollTop: 10,
|
||||
scrollLeft: 0,
|
||||
|
@ -781,7 +781,7 @@ describe("ui_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("handles all views being hidden (without errors)", function() {
|
||||
it("handles all views being hidden (without errors)", function () {
|
||||
const scrollEl = {
|
||||
scrollTop: 100000,
|
||||
scrollLeft: 0,
|
||||
|
@ -799,7 +799,7 @@ describe("ui_utils", function() {
|
|||
|
||||
// This sub-suite is for a notionally internal helper function for
|
||||
// getVisibleElements.
|
||||
describe("backtrackBeforeAllVisibleElements", function() {
|
||||
describe("backtrackBeforeAllVisibleElements", function () {
|
||||
// Layout elements common to all tests
|
||||
const tallPage = [10, 50];
|
||||
const shortPage = [10, 10];
|
||||
|
@ -821,7 +821,7 @@ describe("ui_utils", function() {
|
|||
|
||||
// These tests refer to cases enumerated in the comments of
|
||||
// backtrackBeforeAllVisibleElements.
|
||||
it("handles case 1", function() {
|
||||
it("handles case 1", function () {
|
||||
const pages = makePages([
|
||||
[
|
||||
[10, 20],
|
||||
|
@ -851,7 +851,7 @@ describe("ui_utils", function() {
|
|||
).toEqual(4);
|
||||
});
|
||||
|
||||
it("handles case 2", function() {
|
||||
it("handles case 2", function () {
|
||||
const pages = makePages([
|
||||
[
|
||||
[10, 20],
|
||||
|
@ -880,7 +880,7 @@ describe("ui_utils", function() {
|
|||
).toEqual(4);
|
||||
});
|
||||
|
||||
it("handles case 3", function() {
|
||||
it("handles case 3", function () {
|
||||
const pages = makePages([
|
||||
[
|
||||
[10, 20],
|
||||
|
@ -909,7 +909,7 @@ describe("ui_utils", function() {
|
|||
).toEqual(4);
|
||||
});
|
||||
|
||||
it("handles case 4", function() {
|
||||
it("handles case 4", function () {
|
||||
const pages = makePages([
|
||||
[
|
||||
[10, 20],
|
||||
|
@ -940,40 +940,40 @@ describe("ui_utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("moveToEndOfArray", function() {
|
||||
it("works on empty arrays", function() {
|
||||
describe("moveToEndOfArray", function () {
|
||||
it("works on empty arrays", function () {
|
||||
const data = [];
|
||||
moveToEndOfArray(data, function() {});
|
||||
moveToEndOfArray(data, function () {});
|
||||
expect(data).toEqual([]);
|
||||
});
|
||||
|
||||
it("works when moving everything", function() {
|
||||
it("works when moving everything", function () {
|
||||
const data = [1, 2, 3, 4, 5];
|
||||
moveToEndOfArray(data, function() {
|
||||
moveToEndOfArray(data, function () {
|
||||
return true;
|
||||
});
|
||||
expect(data).toEqual([1, 2, 3, 4, 5]);
|
||||
});
|
||||
|
||||
it("works when moving some things", function() {
|
||||
it("works when moving some things", function () {
|
||||
const data = [1, 2, 3, 4, 5];
|
||||
moveToEndOfArray(data, function(x) {
|
||||
moveToEndOfArray(data, function (x) {
|
||||
return x % 2 === 0;
|
||||
});
|
||||
expect(data).toEqual([1, 3, 5, 2, 4]);
|
||||
});
|
||||
|
||||
it("works when moving one thing", function() {
|
||||
it("works when moving one thing", function () {
|
||||
const data = [1, 2, 3, 4, 5];
|
||||
moveToEndOfArray(data, function(x) {
|
||||
moveToEndOfArray(data, function (x) {
|
||||
return x === 1;
|
||||
});
|
||||
expect(data).toEqual([2, 3, 4, 5, 1]);
|
||||
});
|
||||
|
||||
it("works when moving nothing", function() {
|
||||
it("works when moving nothing", function () {
|
||||
const data = [1, 2, 3, 4, 5];
|
||||
moveToEndOfArray(data, function(x) {
|
||||
moveToEndOfArray(data, function (x) {
|
||||
return x === 0;
|
||||
});
|
||||
expect(data).toEqual([1, 2, 3, 4, 5]);
|
||||
|
|
|
@ -25,16 +25,16 @@ import {
|
|||
reverseIfRtl,
|
||||
} from "../../src/core/unicode.js";
|
||||
|
||||
describe("unicode", function() {
|
||||
describe("mapSpecialUnicodeValues", function() {
|
||||
it("should not re-map normal Unicode values", function() {
|
||||
describe("unicode", function () {
|
||||
describe("mapSpecialUnicodeValues", function () {
|
||||
it("should not re-map normal Unicode values", function () {
|
||||
// A
|
||||
expect(mapSpecialUnicodeValues(0x0041)).toEqual(0x0041);
|
||||
// fi
|
||||
expect(mapSpecialUnicodeValues(0xfb01)).toEqual(0xfb01);
|
||||
});
|
||||
|
||||
it("should re-map special Unicode values", function() {
|
||||
it("should re-map special Unicode values", function () {
|
||||
// copyrightsans => copyright
|
||||
expect(mapSpecialUnicodeValues(0xf8e9)).toEqual(0x00a9);
|
||||
// Private Use Area characters
|
||||
|
@ -42,25 +42,25 @@ describe("unicode", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("getUnicodeForGlyph", function() {
|
||||
describe("getUnicodeForGlyph", function () {
|
||||
var standardMap, dingbatsMap;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
standardMap = getGlyphsUnicode();
|
||||
dingbatsMap = getDingbatsGlyphsUnicode();
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
standardMap = dingbatsMap = null;
|
||||
});
|
||||
|
||||
it("should get Unicode values for valid glyph names", function() {
|
||||
it("should get Unicode values for valid glyph names", function () {
|
||||
expect(getUnicodeForGlyph("A", standardMap)).toEqual(0x0041);
|
||||
expect(getUnicodeForGlyph("a1", dingbatsMap)).toEqual(0x2701);
|
||||
});
|
||||
|
||||
it("should recover Unicode values from uniXXXX/uXXXX{XX} glyph names", function() {
|
||||
it("should recover Unicode values from uniXXXX/uXXXX{XX} glyph names", function () {
|
||||
expect(getUnicodeForGlyph("uni0041", standardMap)).toEqual(0x0041);
|
||||
expect(getUnicodeForGlyph("u0041", standardMap)).toEqual(0x0041);
|
||||
|
||||
|
@ -68,50 +68,50 @@ describe("unicode", function() {
|
|||
expect(getUnicodeForGlyph("u2701", dingbatsMap)).toEqual(0x2701);
|
||||
});
|
||||
|
||||
it("should not get Unicode values for invalid glyph names", function() {
|
||||
it("should not get Unicode values for invalid glyph names", function () {
|
||||
expect(getUnicodeForGlyph("Qwerty", standardMap)).toEqual(-1);
|
||||
expect(getUnicodeForGlyph("Qwerty", dingbatsMap)).toEqual(-1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getUnicodeRangeFor", function() {
|
||||
it("should get correct Unicode range", function() {
|
||||
describe("getUnicodeRangeFor", function () {
|
||||
it("should get correct Unicode range", function () {
|
||||
// A (Basic Latin)
|
||||
expect(getUnicodeRangeFor(0x0041)).toEqual(0);
|
||||
// fi (Alphabetic Presentation Forms)
|
||||
expect(getUnicodeRangeFor(0xfb01)).toEqual(62);
|
||||
});
|
||||
|
||||
it("should not get a Unicode range", function() {
|
||||
it("should not get a Unicode range", function () {
|
||||
expect(getUnicodeRangeFor(0x05ff)).toEqual(-1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getNormalizedUnicodes", function() {
|
||||
describe("getNormalizedUnicodes", function () {
|
||||
var NormalizedUnicodes;
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
NormalizedUnicodes = getNormalizedUnicodes();
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
NormalizedUnicodes = null;
|
||||
});
|
||||
|
||||
it("should get normalized Unicode values for ligatures", function() {
|
||||
it("should get normalized Unicode values for ligatures", function () {
|
||||
// fi => f + i
|
||||
expect(NormalizedUnicodes["\uFB01"]).toEqual("fi");
|
||||
// Arabic
|
||||
expect(NormalizedUnicodes["\u0675"]).toEqual("\u0627\u0674");
|
||||
});
|
||||
|
||||
it("should not normalize standard characters", function() {
|
||||
it("should not normalize standard characters", function () {
|
||||
expect(NormalizedUnicodes["A"]).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe("reverseIfRtl", function() {
|
||||
describe("reverseIfRtl", function () {
|
||||
var NormalizedUnicodes;
|
||||
|
||||
function getGlyphUnicode(char) {
|
||||
|
@ -121,16 +121,16 @@ describe("unicode", function() {
|
|||
return char;
|
||||
}
|
||||
|
||||
beforeAll(function(done) {
|
||||
beforeAll(function (done) {
|
||||
NormalizedUnicodes = getNormalizedUnicodes();
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
afterAll(function () {
|
||||
NormalizedUnicodes = null;
|
||||
});
|
||||
|
||||
it("should not reverse LTR characters", function() {
|
||||
it("should not reverse LTR characters", function () {
|
||||
var A = getGlyphUnicode("A");
|
||||
expect(reverseIfRtl(A)).toEqual("A");
|
||||
|
||||
|
@ -138,7 +138,7 @@ describe("unicode", function() {
|
|||
expect(reverseIfRtl(fi)).toEqual("fi");
|
||||
});
|
||||
|
||||
it("should reverse RTL characters", function() {
|
||||
it("should reverse RTL characters", function () {
|
||||
// Hebrew (no-op, since it's not a combined character)
|
||||
var heAlef = getGlyphUnicode("\u05D0");
|
||||
expect(reverseIfRtl(heAlef)).toEqual("\u05D0");
|
||||
|
|
|
@ -29,20 +29,20 @@ import {
|
|||
stringToPDFString,
|
||||
} from "../../src/shared/util.js";
|
||||
|
||||
describe("util", function() {
|
||||
describe("bytesToString", function() {
|
||||
it("handles non-array arguments", function() {
|
||||
expect(function() {
|
||||
describe("util", function () {
|
||||
describe("bytesToString", function () {
|
||||
it("handles non-array arguments", function () {
|
||||
expect(function () {
|
||||
bytesToString(null);
|
||||
}).toThrow(new Error("Invalid argument for bytesToString"));
|
||||
});
|
||||
|
||||
it("handles array arguments with a length not exceeding the maximum", function() {
|
||||
it("handles array arguments with a length not exceeding the maximum", function () {
|
||||
expect(bytesToString(new Uint8Array([]))).toEqual("");
|
||||
expect(bytesToString(new Uint8Array([102, 111, 111]))).toEqual("foo");
|
||||
});
|
||||
|
||||
it("handles array arguments with a length exceeding the maximum", function() {
|
||||
it("handles array arguments with a length exceeding the maximum", function () {
|
||||
const length = 10000; // Larger than MAX_ARGUMENT_COUNT = 8192.
|
||||
|
||||
// Create an array with `length` 'a' character codes.
|
||||
|
@ -59,13 +59,13 @@ describe("util", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isArrayBuffer", function() {
|
||||
it("handles array buffer values", function() {
|
||||
describe("isArrayBuffer", function () {
|
||||
it("handles array buffer values", function () {
|
||||
expect(isArrayBuffer(new ArrayBuffer(0))).toEqual(true);
|
||||
expect(isArrayBuffer(new Uint8Array(0))).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles non-array buffer values", function() {
|
||||
it("handles non-array buffer values", function () {
|
||||
expect(isArrayBuffer("true")).toEqual(false);
|
||||
expect(isArrayBuffer(1)).toEqual(false);
|
||||
expect(isArrayBuffer(null)).toEqual(false);
|
||||
|
@ -73,13 +73,13 @@ describe("util", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isBool", function() {
|
||||
it("handles boolean values", function() {
|
||||
describe("isBool", function () {
|
||||
it("handles boolean values", function () {
|
||||
expect(isBool(true)).toEqual(true);
|
||||
expect(isBool(false)).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles non-boolean values", function() {
|
||||
it("handles non-boolean values", function () {
|
||||
expect(isBool("true")).toEqual(false);
|
||||
expect(isBool("false")).toEqual(false);
|
||||
expect(isBool(1)).toEqual(false);
|
||||
|
@ -89,18 +89,18 @@ describe("util", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isEmptyObj", function() {
|
||||
it("handles empty objects", function() {
|
||||
describe("isEmptyObj", function () {
|
||||
it("handles empty objects", function () {
|
||||
expect(isEmptyObj({})).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles non-empty objects", function() {
|
||||
it("handles non-empty objects", function () {
|
||||
expect(isEmptyObj({ foo: "bar" })).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isNum", function() {
|
||||
it("handles numeric values", function() {
|
||||
describe("isNum", function () {
|
||||
it("handles numeric values", function () {
|
||||
expect(isNum(1)).toEqual(true);
|
||||
expect(isNum(0)).toEqual(true);
|
||||
expect(isNum(-1)).toEqual(true);
|
||||
|
@ -108,7 +108,7 @@ describe("util", function() {
|
|||
expect(isNum(12.34)).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles non-numeric values", function() {
|
||||
it("handles non-numeric values", function () {
|
||||
expect(isNum("true")).toEqual(false);
|
||||
expect(isNum(true)).toEqual(false);
|
||||
expect(isNum(null)).toEqual(false);
|
||||
|
@ -116,13 +116,13 @@ describe("util", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isString", function() {
|
||||
it("handles string values", function() {
|
||||
describe("isString", function () {
|
||||
it("handles string values", function () {
|
||||
expect(isString("foo")).toEqual(true);
|
||||
expect(isString("")).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles non-string values", function() {
|
||||
it("handles non-string values", function () {
|
||||
expect(isString(true)).toEqual(false);
|
||||
expect(isString(1)).toEqual(false);
|
||||
expect(isString(null)).toEqual(false);
|
||||
|
@ -130,44 +130,44 @@ describe("util", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("string32", function() {
|
||||
it("converts unsigned 32-bit integers to strings", function() {
|
||||
describe("string32", function () {
|
||||
it("converts unsigned 32-bit integers to strings", function () {
|
||||
expect(string32(0x74727565)).toEqual("true");
|
||||
expect(string32(0x74797031)).toEqual("typ1");
|
||||
expect(string32(0x4f54544f)).toEqual("OTTO");
|
||||
});
|
||||
});
|
||||
|
||||
describe("stringToBytes", function() {
|
||||
it("handles non-string arguments", function() {
|
||||
expect(function() {
|
||||
describe("stringToBytes", function () {
|
||||
it("handles non-string arguments", function () {
|
||||
expect(function () {
|
||||
stringToBytes(null);
|
||||
}).toThrow(new Error("Invalid argument for stringToBytes"));
|
||||
});
|
||||
|
||||
it("handles string arguments", function() {
|
||||
it("handles string arguments", function () {
|
||||
expect(stringToBytes("")).toEqual(new Uint8Array([]));
|
||||
expect(stringToBytes("foo")).toEqual(new Uint8Array([102, 111, 111]));
|
||||
});
|
||||
});
|
||||
|
||||
describe("stringToPDFString", function() {
|
||||
it("handles ISO Latin 1 strings", function() {
|
||||
describe("stringToPDFString", function () {
|
||||
it("handles ISO Latin 1 strings", function () {
|
||||
const str = "\x8Dstring\x8E";
|
||||
expect(stringToPDFString(str)).toEqual("\u201Cstring\u201D");
|
||||
});
|
||||
|
||||
it("handles UTF-16 big-endian strings", function() {
|
||||
it("handles UTF-16 big-endian strings", function () {
|
||||
const str = "\xFE\xFF\x00\x73\x00\x74\x00\x72\x00\x69\x00\x6E\x00\x67";
|
||||
expect(stringToPDFString(str)).toEqual("string");
|
||||
});
|
||||
|
||||
it("handles UTF-16 little-endian strings", function() {
|
||||
it("handles UTF-16 little-endian strings", function () {
|
||||
const str = "\xFF\xFE\x73\x00\x74\x00\x72\x00\x69\x00\x6E\x00\x67\x00";
|
||||
expect(stringToPDFString(str)).toEqual("string");
|
||||
});
|
||||
|
||||
it("handles empty strings", function() {
|
||||
it("handles empty strings", function () {
|
||||
// ISO Latin 1
|
||||
const str1 = "";
|
||||
expect(stringToPDFString(str1)).toEqual("");
|
||||
|
@ -182,44 +182,44 @@ describe("util", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("removeNullCharacters", function() {
|
||||
it("should not modify string without null characters", function() {
|
||||
describe("removeNullCharacters", function () {
|
||||
it("should not modify string without null characters", function () {
|
||||
const str = "string without null chars";
|
||||
expect(removeNullCharacters(str)).toEqual("string without null chars");
|
||||
});
|
||||
|
||||
it("should modify string with null characters", function() {
|
||||
it("should modify string with null characters", function () {
|
||||
const str = "string\x00With\x00Null\x00Chars";
|
||||
expect(removeNullCharacters(str)).toEqual("stringWithNullChars");
|
||||
});
|
||||
});
|
||||
|
||||
describe("ReadableStream", function() {
|
||||
it("should return an Object", function() {
|
||||
describe("ReadableStream", function () {
|
||||
it("should return an Object", function () {
|
||||
const readable = new ReadableStream();
|
||||
expect(typeof readable).toEqual("object");
|
||||
});
|
||||
|
||||
it("should have property getReader", function() {
|
||||
it("should have property getReader", function () {
|
||||
const readable = new ReadableStream();
|
||||
expect(typeof readable.getReader).toEqual("function");
|
||||
});
|
||||
});
|
||||
|
||||
describe("URL", function() {
|
||||
it("should return an Object", function() {
|
||||
describe("URL", function () {
|
||||
it("should return an Object", function () {
|
||||
const url = new URL("https://example.com");
|
||||
expect(typeof url).toEqual("object");
|
||||
});
|
||||
|
||||
it("should have property `href`", function() {
|
||||
it("should have property `href`", function () {
|
||||
const url = new URL("https://example.com");
|
||||
expect(typeof url.href).toEqual("string");
|
||||
});
|
||||
});
|
||||
|
||||
describe("isSameOrigin", function() {
|
||||
it("handles invalid base URLs", function() {
|
||||
describe("isSameOrigin", function () {
|
||||
it("handles invalid base URLs", function () {
|
||||
// The base URL is not valid.
|
||||
expect(isSameOrigin("/foo", "/bar")).toEqual(false);
|
||||
|
||||
|
@ -227,7 +227,7 @@ describe("util", function() {
|
|||
expect(isSameOrigin("blob:foo", "/bar")).toEqual(false);
|
||||
});
|
||||
|
||||
it("correctly checks if the origin of both URLs matches", function() {
|
||||
it("correctly checks if the origin of both URLs matches", function () {
|
||||
expect(
|
||||
isSameOrigin(
|
||||
"https://www.mozilla.org/foo",
|
||||
|
@ -243,18 +243,18 @@ describe("util", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("createValidAbsoluteUrl", function() {
|
||||
it("handles invalid URLs", function() {
|
||||
describe("createValidAbsoluteUrl", function () {
|
||||
it("handles invalid URLs", function () {
|
||||
expect(createValidAbsoluteUrl(undefined, undefined)).toEqual(null);
|
||||
expect(createValidAbsoluteUrl(null, null)).toEqual(null);
|
||||
expect(createValidAbsoluteUrl("/foo", "/bar")).toEqual(null);
|
||||
});
|
||||
|
||||
it("handles URLs that do not use a whitelisted protocol", function() {
|
||||
it("handles URLs that do not use a whitelisted protocol", function () {
|
||||
expect(createValidAbsoluteUrl("magnet:?foo", null)).toEqual(null);
|
||||
});
|
||||
|
||||
it("correctly creates a valid URL for whitelisted protocols", function() {
|
||||
it("correctly creates a valid URL for whitelisted protocols", function () {
|
||||
// `http` protocol
|
||||
expect(
|
||||
createValidAbsoluteUrl("http://www.mozilla.org/foo", null)
|
||||
|
@ -295,14 +295,14 @@ describe("util", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("createPromiseCapability", function() {
|
||||
it("should resolve with correct data", function(done) {
|
||||
describe("createPromiseCapability", function () {
|
||||
it("should resolve with correct data", function (done) {
|
||||
const promiseCapability = createPromiseCapability();
|
||||
expect(promiseCapability.settled).toEqual(false);
|
||||
|
||||
promiseCapability.resolve({ test: "abc" });
|
||||
|
||||
promiseCapability.promise.then(function(data) {
|
||||
promiseCapability.promise.then(function (data) {
|
||||
expect(promiseCapability.settled).toEqual(true);
|
||||
|
||||
expect(data).toEqual({ test: "abc" });
|
||||
|
@ -310,13 +310,13 @@ describe("util", function() {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should reject with correct reason", function(done) {
|
||||
it("should reject with correct reason", function (done) {
|
||||
const promiseCapability = createPromiseCapability();
|
||||
expect(promiseCapability.settled).toEqual(false);
|
||||
|
||||
promiseCapability.reject(new Error("reason"));
|
||||
|
||||
promiseCapability.promise.then(done.fail, function(reason) {
|
||||
promiseCapability.promise.then(done.fail, function (reason) {
|
||||
expect(promiseCapability.settled).toEqual(true);
|
||||
|
||||
expect(reason instanceof Error).toEqual(true);
|
||||
|
|
|
@ -41,14 +41,14 @@ function WebBrowser(name, execPath, headless) {
|
|||
this.uniqStringId = "webbrowser" + crypto.randomBytes(32).toString("hex");
|
||||
}
|
||||
WebBrowser.prototype = {
|
||||
start: function(url) {
|
||||
start: function (url) {
|
||||
this.tmpDir = path.join(os.tmpdir(), tempDirPrefix + this.name);
|
||||
if (!fs.existsSync(this.tmpDir)) {
|
||||
fs.mkdirSync(this.tmpDir);
|
||||
}
|
||||
this.startProcess(url);
|
||||
},
|
||||
getProfileDir: function() {
|
||||
getProfileDir: function () {
|
||||
if (!this.profileDir) {
|
||||
var profileDir = path.join(this.tmpDir, "profile");
|
||||
if (fs.existsSync(profileDir)) {
|
||||
|
@ -60,11 +60,11 @@ WebBrowser.prototype = {
|
|||
}
|
||||
return this.profileDir;
|
||||
},
|
||||
buildArguments: function(url) {
|
||||
buildArguments: function (url) {
|
||||
return [url];
|
||||
},
|
||||
setupProfileDir: function(dir) {},
|
||||
startProcess: function(url) {
|
||||
setupProfileDir: function (dir) {},
|
||||
startProcess: function (url) {
|
||||
console.assert(!this.process, "startProcess may be called only once");
|
||||
|
||||
var args = this.buildArguments(url);
|
||||
|
@ -76,7 +76,7 @@ WebBrowser.prototype = {
|
|||
|
||||
this.process.on(
|
||||
"exit",
|
||||
function(code, signal) {
|
||||
function (code, signal) {
|
||||
this.process = null;
|
||||
var exitInfo =
|
||||
code !== null
|
||||
|
@ -93,7 +93,7 @@ WebBrowser.prototype = {
|
|||
}.bind(this)
|
||||
);
|
||||
},
|
||||
cleanup: function() {
|
||||
cleanup: function () {
|
||||
console.assert(
|
||||
this.requestedExit,
|
||||
"cleanup should only be called after an explicit stop() request"
|
||||
|
@ -123,7 +123,7 @@ WebBrowser.prototype = {
|
|||
this.log("Clean-up finished. Going to call callback...");
|
||||
this.callback();
|
||||
},
|
||||
stop: function(callback) {
|
||||
stop: function (callback) {
|
||||
console.assert(this.tmpDir, ".start() must be called before stop()");
|
||||
// Require the callback to ensure that callers do not make any assumptions
|
||||
// on the state of this browser instance until the callback is called.
|
||||
|
@ -145,7 +145,7 @@ WebBrowser.prototype = {
|
|||
this.killProcessUnknownPid(this.cleanup.bind(this));
|
||||
}
|
||||
},
|
||||
killProcessUnknownPid: function(callback) {
|
||||
killProcessUnknownPid: function (callback) {
|
||||
this.log("pid unknown, killing processes matching " + this.uniqStringId);
|
||||
|
||||
var cmdKillAll, cmdCheckAllKilled, isAllKilled;
|
||||
|
@ -168,13 +168,13 @@ WebBrowser.prototype = {
|
|||
file: "wmic",
|
||||
args: wmicPrefix.concat(["get", "CommandLine"]),
|
||||
};
|
||||
isAllKilled = function(exitCode, stdout) {
|
||||
isAllKilled = function (exitCode, stdout) {
|
||||
return !stdout.includes(this.uniqStringId);
|
||||
}.bind(this);
|
||||
} else {
|
||||
cmdKillAll = { file: "pkill", args: ["-f", this.uniqStringId] };
|
||||
cmdCheckAllKilled = { file: "pgrep", args: ["-f", this.uniqStringId] };
|
||||
isAllKilled = function(pgrepStatus) {
|
||||
isAllKilled = function (pgrepStatus) {
|
||||
return pgrepStatus === 1; // "No process matched.", per man pgrep.
|
||||
};
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ WebBrowser.prototype = {
|
|||
function checkAlive(firstExitCode, firstStdout) {
|
||||
execAsyncNoStdin(
|
||||
cmdCheckAllKilled,
|
||||
function(exitCode, stdout) {
|
||||
function (exitCode, stdout) {
|
||||
if (isAllKilled(exitCode, stdout)) {
|
||||
callback();
|
||||
} else if (Date.now() - killDateStart > 10000) {
|
||||
|
@ -220,7 +220,7 @@ WebBrowser.prototype = {
|
|||
}.bind(this)
|
||||
);
|
||||
},
|
||||
log: function(msg) {
|
||||
log: function (msg) {
|
||||
console.log("[" + this.name + "] " + msg);
|
||||
},
|
||||
};
|
||||
|
@ -237,7 +237,7 @@ function FirefoxBrowser(name, execPath, headless) {
|
|||
WebBrowser.call(this, name, execPath, headless);
|
||||
}
|
||||
FirefoxBrowser.prototype = Object.create(WebBrowser.prototype);
|
||||
FirefoxBrowser.prototype.buildArguments = function(url) {
|
||||
FirefoxBrowser.prototype.buildArguments = function (url) {
|
||||
var profileDir = this.getProfileDir();
|
||||
var args = [];
|
||||
if (os.platform() === "darwin") {
|
||||
|
@ -249,7 +249,7 @@ FirefoxBrowser.prototype.buildArguments = function(url) {
|
|||
args.push("-no-remote", "-profile", profileDir, url);
|
||||
return args;
|
||||
};
|
||||
FirefoxBrowser.prototype.setupProfileDir = function(dir) {
|
||||
FirefoxBrowser.prototype.setupProfileDir = function (dir) {
|
||||
testUtils.copySubtreeSync(firefoxResourceDir, dir);
|
||||
};
|
||||
|
||||
|
@ -263,7 +263,7 @@ function ChromiumBrowser(name, execPath, headless) {
|
|||
WebBrowser.call(this, name, execPath, headless);
|
||||
}
|
||||
ChromiumBrowser.prototype = Object.create(WebBrowser.prototype);
|
||||
ChromiumBrowser.prototype.buildArguments = function(url) {
|
||||
ChromiumBrowser.prototype.buildArguments = function (url) {
|
||||
var profileDir = this.getProfileDir();
|
||||
var crashDumpsDir = path.join(this.tmpDir, "crash_dumps");
|
||||
var args = [
|
||||
|
@ -288,7 +288,7 @@ ChromiumBrowser.prototype.buildArguments = function(url) {
|
|||
return args;
|
||||
};
|
||||
|
||||
WebBrowser.create = function(desc) {
|
||||
WebBrowser.create = function (desc) {
|
||||
var name = desc.name;
|
||||
var execPath = fs.realpathSync(desc.path);
|
||||
if (!execPath) {
|
||||
|
|
|
@ -53,7 +53,7 @@ function WebServer() {
|
|||
};
|
||||
}
|
||||
WebServer.prototype = {
|
||||
start: function(callback) {
|
||||
start: function (callback) {
|
||||
this._ensureNonZeroPort();
|
||||
this.server = http.createServer(this._handler.bind(this));
|
||||
this.server.listen(this.port, this.host, callback);
|
||||
|
@ -61,11 +61,11 @@ WebServer.prototype = {
|
|||
"Server running at http://" + this.host + ":" + this.port + "/"
|
||||
);
|
||||
},
|
||||
stop: function(callback) {
|
||||
stop: function (callback) {
|
||||
this.server.close(callback);
|
||||
this.server = null;
|
||||
},
|
||||
_ensureNonZeroPort: function() {
|
||||
_ensureNonZeroPort: function () {
|
||||
if (!this.port) {
|
||||
// If port is 0, a random port will be chosen instead. Do not set a host
|
||||
// name to make sure that the port is synchronously set by .listen().
|
||||
|
@ -78,7 +78,7 @@ WebServer.prototype = {
|
|||
server.close();
|
||||
}
|
||||
},
|
||||
_handler: function(req, res) {
|
||||
_handler: function (req, res) {
|
||||
var url = req.url.replace(/\/\//g, "/");
|
||||
var urlParts = /([^?]*)((?:\?(.*))?)/.exec(url);
|
||||
try {
|
||||
|
@ -107,7 +107,7 @@ WebServer.prototype = {
|
|||
res.end("Unsupported request method", "utf8");
|
||||
return;
|
||||
}
|
||||
var handled = methodHooks.some(function(hook) {
|
||||
var handled = methodHooks.some(function (hook) {
|
||||
return hook(req, res);
|
||||
});
|
||||
if (handled) {
|
||||
|
@ -218,7 +218,7 @@ WebServer.prototype = {
|
|||
return;
|
||||
}
|
||||
var all = queryPart === "all";
|
||||
fs.readdir(dir, function(err, files) {
|
||||
fs.readdir(dir, function (err, files) {
|
||||
if (err) {
|
||||
res.end();
|
||||
return;
|
||||
|
@ -232,7 +232,7 @@ WebServer.prototype = {
|
|||
if (pathPart !== "/") {
|
||||
res.write('<a href="..">..</a><br>\n');
|
||||
}
|
||||
files.forEach(function(file) {
|
||||
files.forEach(function (file) {
|
||||
var stat;
|
||||
var item = pathPart + file;
|
||||
var href = "";
|
||||
|
@ -286,7 +286,7 @@ WebServer.prototype = {
|
|||
function serveRequestedFile(reqFilePath) {
|
||||
var stream = fs.createReadStream(reqFilePath, { flags: "rs" });
|
||||
|
||||
stream.on("error", function(error) {
|
||||
stream.on("error", function (error) {
|
||||
res.writeHead(500);
|
||||
res.end();
|
||||
});
|
||||
|
@ -316,7 +316,7 @@ WebServer.prototype = {
|
|||
end: end - 1,
|
||||
});
|
||||
|
||||
stream.on("error", function(error) {
|
||||
stream.on("error", function (error) {
|
||||
res.writeHead(500);
|
||||
res.end();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue