2012-09-01 07:48:21 +09:00
|
|
|
/* Copyright 2012 Mozilla Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2021-03-13 23:51:44 +09:00
|
|
|
/* eslint-disable no-var */
|
2018-03-16 05:49:28 +09:00
|
|
|
/* globals pdfjsLib, pdfjsViewer */
|
2012-09-01 07:48:21 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
"use strict";
|
2011-07-11 15:21:13 +09:00
|
|
|
|
2018-02-14 22:49:24 +09:00
|
|
|
const WAITING_TIME = 100; // ms
|
|
|
|
const PDF_TO_CSS_UNITS = 96.0 / 72.0;
|
2021-06-08 19:02:26 +09:00
|
|
|
const CMAP_URL = "/build/generic/web/cmaps/";
|
2018-02-18 00:57:24 +09:00
|
|
|
const CMAP_PACKED = true;
|
2020-12-11 10:32:18 +09:00
|
|
|
const STANDARD_FONT_DATA_URL = "/build/generic/web/standard_fonts/";
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const IMAGE_RESOURCES_PATH = "/web/images/";
|
|
|
|
const WORKER_SRC = "../build/generic/build/pdf.worker.js";
|
2020-06-29 03:14:03 +09:00
|
|
|
const RENDER_TASK_ON_CONTINUE_DELAY = 5; // ms
|
2021-06-07 22:20:29 +09:00
|
|
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
2015-05-15 22:54:48 +09:00
|
|
|
|
2021-06-07 22:20:29 +09:00
|
|
|
function loadStyles(styles) {
|
|
|
|
styles = Object.values(styles);
|
|
|
|
if (styles.every(style => style.promise)) {
|
|
|
|
return Promise.all(styles.map(style => style.promise));
|
|
|
|
}
|
2011-11-16 07:43:05 +09:00
|
|
|
|
2021-06-07 22:20:29 +09:00
|
|
|
for (const style of styles) {
|
|
|
|
style.promise = new Promise(function (resolve, reject) {
|
|
|
|
const xhr = new XMLHttpRequest();
|
|
|
|
xhr.open("GET", style.file);
|
2020-04-14 19:28:14 +09:00
|
|
|
xhr.onload = function () {
|
2015-11-20 02:03:52 +09:00
|
|
|
resolve(xhr.responseText);
|
|
|
|
};
|
2021-06-07 22:20:29 +09:00
|
|
|
xhr.onerror = function (e) {
|
|
|
|
reject(new Error(`Error fetching style (${style.file}): ${e}`));
|
|
|
|
};
|
2015-11-20 02:03:52 +09:00
|
|
|
xhr.send(null);
|
|
|
|
});
|
2021-06-07 22:20:29 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
return Promise.all(styles.map(style => style.promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
function writeSVG(svgElement, ctx, resolve, reject) {
|
|
|
|
// We need to have UTF-8 encoded XML.
|
|
|
|
const svg_xml = unescape(
|
|
|
|
encodeURIComponent(new XMLSerializer().serializeToString(svgElement))
|
|
|
|
);
|
|
|
|
const img = new Image();
|
|
|
|
img.src = "data:image/svg+xml;base64," + btoa(svg_xml);
|
|
|
|
img.onload = function () {
|
|
|
|
ctx.drawImage(img, 0, 0);
|
|
|
|
resolve();
|
|
|
|
};
|
|
|
|
img.onerror = function (e) {
|
|
|
|
reject(new Error("Error rasterizing text layer " + e));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class
|
|
|
|
*/
|
|
|
|
var rasterizeTextLayer = (function rasterizeTextLayerClosure() {
|
|
|
|
const styles = {
|
|
|
|
common: {
|
|
|
|
file: "./text_layer_test.css",
|
|
|
|
promise: null,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
function getTextLayerStyle() {
|
|
|
|
return loadStyles(styles);
|
2011-08-17 04:17:46 +09:00
|
|
|
}
|
|
|
|
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
function rasterizeTextLayer(
|
|
|
|
ctx,
|
|
|
|
viewport,
|
|
|
|
textContent,
|
|
|
|
enhanceTextSelection
|
|
|
|
) {
|
2020-04-14 19:28:14 +09:00
|
|
|
return new Promise(function (resolve, reject) {
|
2015-11-20 02:03:52 +09:00
|
|
|
// Building SVG with size of the viewport.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var svg = document.createElementNS(SVG_NS, "svg:svg");
|
|
|
|
svg.setAttribute("width", viewport.width + "px");
|
|
|
|
svg.setAttribute("height", viewport.height + "px");
|
2015-11-20 02:03:52 +09:00
|
|
|
// items are transformed to have 1px font size
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
svg.setAttribute("font-size", 1);
|
2015-11-20 02:03:52 +09:00
|
|
|
|
|
|
|
// Adding element to host our HTML (style + text layer div).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var foreignObject = document.createElementNS(SVG_NS, "svg:foreignObject");
|
|
|
|
foreignObject.setAttribute("x", "0");
|
|
|
|
foreignObject.setAttribute("y", "0");
|
|
|
|
foreignObject.setAttribute("width", viewport.width + "px");
|
|
|
|
foreignObject.setAttribute("height", viewport.height + "px");
|
|
|
|
var style = document.createElement("style");
|
2015-11-20 02:03:52 +09:00
|
|
|
var stylePromise = getTextLayerStyle();
|
|
|
|
foreignObject.appendChild(style);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var div = document.createElement("div");
|
|
|
|
div.className = "textLayer";
|
2015-11-20 02:03:52 +09:00
|
|
|
foreignObject.appendChild(div);
|
|
|
|
|
2021-03-12 22:00:12 +09:00
|
|
|
stylePromise
|
|
|
|
.then(async cssRules => {
|
|
|
|
style.textContent = cssRules;
|
2015-11-20 02:03:52 +09:00
|
|
|
|
2021-03-12 22:00:12 +09:00
|
|
|
// Rendering text layer as HTML.
|
|
|
|
var task = pdfjsLib.renderTextLayer({
|
|
|
|
textContent,
|
|
|
|
container: div,
|
|
|
|
viewport,
|
|
|
|
enhanceTextSelection,
|
|
|
|
});
|
|
|
|
await task.promise;
|
|
|
|
|
|
|
|
task.expandTextDivs(true);
|
|
|
|
svg.appendChild(foreignObject);
|
|
|
|
|
2021-06-07 22:20:29 +09:00
|
|
|
writeSVG(svg, ctx, resolve, reject);
|
2021-03-12 22:00:12 +09:00
|
|
|
})
|
|
|
|
.catch(reason => {
|
|
|
|
reject(new Error(`rasterizeTextLayer: "${reason?.message}".`));
|
|
|
|
});
|
2015-11-20 02:03:52 +09:00
|
|
|
});
|
|
|
|
}
|
2011-08-17 04:17:46 +09:00
|
|
|
|
2015-11-20 02:03:52 +09:00
|
|
|
return rasterizeTextLayer;
|
2015-05-15 22:29:43 +09:00
|
|
|
})();
|
2013-02-07 08:19:29 +09:00
|
|
|
|
2015-12-19 06:29:22 +09:00
|
|
|
/**
|
|
|
|
* @class
|
|
|
|
*/
|
|
|
|
var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {
|
2017-09-11 01:10:43 +09:00
|
|
|
/**
|
|
|
|
* For the reference tests, the entire annotation layer must be visible. To
|
|
|
|
* achieve this, we load the common styles as used by the viewer and extend
|
|
|
|
* them with a set of overrides to make all elements visible.
|
|
|
|
*
|
|
|
|
* Note that we cannot simply use `@import` to import the common styles in
|
|
|
|
* the overrides file because the browser does not resolve that when the
|
|
|
|
* styles are inserted via XHR. Therefore, we load and combine them here.
|
|
|
|
*/
|
2020-01-24 17:48:21 +09:00
|
|
|
const styles = {
|
2017-09-11 01:10:43 +09:00
|
|
|
common: {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
file: "../web/annotation_layer_builder.css",
|
2017-09-11 01:10:43 +09:00
|
|
|
promise: null,
|
|
|
|
},
|
|
|
|
overrides: {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
file: "./annotation_layer_builder_overrides.css",
|
2017-09-11 01:10:43 +09:00
|
|
|
promise: null,
|
|
|
|
},
|
|
|
|
};
|
2015-12-19 06:29:22 +09:00
|
|
|
|
|
|
|
function getAnnotationLayerStyle() {
|
2021-06-07 22:20:29 +09:00
|
|
|
return loadStyles(styles);
|
2015-12-19 06:29:22 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
function inlineAnnotationImages(images) {
|
|
|
|
var imagePromises = [];
|
|
|
|
for (var i = 0, ii = images.length; i < ii; i++) {
|
2020-04-14 19:28:14 +09:00
|
|
|
var imagePromise = new Promise(function (resolve, reject) {
|
2015-12-19 06:29:22 +09:00
|
|
|
var xhr = new XMLHttpRequest();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
xhr.responseType = "blob";
|
2020-04-14 19:28:14 +09:00
|
|
|
xhr.onload = function () {
|
2015-12-19 06:29:22 +09:00
|
|
|
var reader = new FileReader();
|
2020-04-14 19:28:14 +09:00
|
|
|
reader.onloadend = function () {
|
2015-12-19 06:29:22 +09:00
|
|
|
resolve(reader.result);
|
|
|
|
};
|
|
|
|
reader.readAsDataURL(xhr.response);
|
|
|
|
};
|
2020-04-14 19:28:14 +09:00
|
|
|
xhr.onerror = function (e) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
reject(new Error("Error fetching inline annotation image " + e));
|
2015-12-19 06:29:22 +09:00
|
|
|
};
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
xhr.open("GET", images[i].src);
|
2015-12-19 06:29:22 +09:00
|
|
|
xhr.send();
|
|
|
|
});
|
|
|
|
imagePromises.push(imagePromise);
|
|
|
|
}
|
|
|
|
return imagePromises;
|
|
|
|
}
|
|
|
|
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
function rasterizeAnnotationLayer(
|
|
|
|
ctx,
|
|
|
|
viewport,
|
|
|
|
annotations,
|
|
|
|
page,
|
|
|
|
imageResourcesPath,
|
|
|
|
renderInteractiveForms
|
|
|
|
) {
|
2020-04-14 19:28:14 +09:00
|
|
|
return new Promise(function (resolve, reject) {
|
2015-12-19 06:29:22 +09:00
|
|
|
// Building SVG with size of the viewport.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var svg = document.createElementNS(SVG_NS, "svg:svg");
|
|
|
|
svg.setAttribute("width", viewport.width + "px");
|
|
|
|
svg.setAttribute("height", viewport.height + "px");
|
2015-12-19 06:29:22 +09:00
|
|
|
|
|
|
|
// Adding element to host our HTML (style + annotation layer div).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var foreignObject = document.createElementNS(SVG_NS, "svg:foreignObject");
|
|
|
|
foreignObject.setAttribute("x", "0");
|
|
|
|
foreignObject.setAttribute("y", "0");
|
|
|
|
foreignObject.setAttribute("width", viewport.width + "px");
|
|
|
|
foreignObject.setAttribute("height", viewport.height + "px");
|
|
|
|
var style = document.createElement("style");
|
2015-12-19 06:29:22 +09:00
|
|
|
var stylePromise = getAnnotationLayerStyle();
|
|
|
|
foreignObject.appendChild(style);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var div = document.createElement("div");
|
|
|
|
div.className = "annotationLayer";
|
2015-12-19 06:29:22 +09:00
|
|
|
|
|
|
|
// Rendering annotation layer as HTML.
|
2021-03-12 22:00:12 +09:00
|
|
|
stylePromise
|
|
|
|
.then(async (common, overrides) => {
|
|
|
|
style.textContent = common + overrides;
|
2015-12-19 06:29:22 +09:00
|
|
|
|
2021-03-12 22:00:12 +09:00
|
|
|
var annotation_viewport = viewport.clone({ dontFlip: true });
|
|
|
|
var parameters = {
|
|
|
|
viewport: annotation_viewport,
|
|
|
|
div,
|
|
|
|
annotations,
|
|
|
|
page,
|
|
|
|
linkService: new pdfjsViewer.SimpleLinkService(),
|
|
|
|
imageResourcesPath,
|
|
|
|
renderInteractiveForms,
|
|
|
|
};
|
|
|
|
pdfjsLib.AnnotationLayer.render(parameters);
|
2015-12-19 06:29:22 +09:00
|
|
|
|
2021-03-12 22:00:12 +09:00
|
|
|
// Inline SVG images from text annotations.
|
|
|
|
var images = div.getElementsByTagName("img");
|
|
|
|
var imagePromises = inlineAnnotationImages(images);
|
2015-12-19 06:29:22 +09:00
|
|
|
|
2021-03-12 22:00:12 +09:00
|
|
|
await 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) {
|
|
|
|
images[i].onload = resolveImage;
|
|
|
|
images[i].onerror = function (e) {
|
|
|
|
rejectImage(new Error("Error loading image " + e));
|
|
|
|
};
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return loadedPromises;
|
|
|
|
});
|
2015-12-19 06:29:22 +09:00
|
|
|
|
2021-03-12 22:00:12 +09:00
|
|
|
foreignObject.appendChild(div);
|
|
|
|
svg.appendChild(foreignObject);
|
|
|
|
|
2021-06-07 22:20:29 +09:00
|
|
|
writeSVG(svg, ctx, resolve, reject);
|
2021-03-12 22:00:12 +09:00
|
|
|
})
|
|
|
|
.catch(reason => {
|
|
|
|
reject(new Error(`rasterizeAnnotationLayer: "${reason?.message}".`));
|
2015-12-19 06:29:22 +09:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return rasterizeAnnotationLayer;
|
|
|
|
})();
|
|
|
|
|
2021-06-07 22:20:29 +09:00
|
|
|
/**
|
|
|
|
* @class
|
|
|
|
*/
|
|
|
|
var rasterizeXfaLayer = (function rasterizeXfaLayerClosure() {
|
|
|
|
const styles = {
|
|
|
|
common: {
|
|
|
|
file: "../web/xfa_layer_builder.css",
|
|
|
|
promise: null,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
function getXfaLayerStyle() {
|
|
|
|
return loadStyles(styles);
|
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-shadow
|
|
|
|
function rasterizeXfaLayer(ctx, viewport, xfa, fontRules) {
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
// Building SVG with size of the viewport.
|
|
|
|
const svg = document.createElementNS(SVG_NS, "svg:svg");
|
|
|
|
svg.setAttribute("width", viewport.width + "px");
|
|
|
|
svg.setAttribute("height", viewport.height + "px");
|
|
|
|
const foreignObject = document.createElementNS(
|
|
|
|
SVG_NS,
|
|
|
|
"svg:foreignObject"
|
|
|
|
);
|
|
|
|
foreignObject.setAttribute("x", "0");
|
|
|
|
foreignObject.setAttribute("y", "0");
|
|
|
|
foreignObject.setAttribute("width", viewport.width + "px");
|
|
|
|
foreignObject.setAttribute("height", viewport.height + "px");
|
|
|
|
const style = document.createElement("style");
|
|
|
|
const stylePromise = getXfaLayerStyle();
|
|
|
|
foreignObject.appendChild(style);
|
|
|
|
const div = document.createElement("div");
|
|
|
|
foreignObject.appendChild(div);
|
|
|
|
|
|
|
|
stylePromise
|
|
|
|
.then(async cssRules => {
|
|
|
|
style.textContent = fontRules + "\n" + cssRules;
|
|
|
|
|
|
|
|
pdfjsLib.XfaLayer.render({
|
|
|
|
xfa,
|
|
|
|
div,
|
|
|
|
viewport: viewport.clone({ dontFlip: true }),
|
|
|
|
});
|
|
|
|
|
|
|
|
svg.appendChild(foreignObject);
|
|
|
|
|
|
|
|
writeSVG(svg, ctx, resolve, reject);
|
|
|
|
})
|
|
|
|
.catch(reason => {
|
|
|
|
reject(new Error(`rasterizeXfaLayer: "${reason?.message}".`));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return rasterizeXfaLayer;
|
|
|
|
})();
|
|
|
|
|
2015-05-15 22:29:43 +09:00
|
|
|
/**
|
|
|
|
* @typedef {Object} DriverOptions
|
|
|
|
* @property {HTMLSpanElement} inflight - Field displaying the number of
|
|
|
|
* inflight requests.
|
2015-05-16 02:58:34 +09:00
|
|
|
* @property {HTMLInputElement} disableScrolling - Checkbox to disable
|
|
|
|
* automatic scrolling of the output container.
|
|
|
|
* @property {HTMLPreElement} output - Container for all output messages.
|
2015-05-15 22:29:43 +09:00
|
|
|
* @property {HTMLDivElement} end - Container for a completion message.
|
|
|
|
*/
|
2011-07-05 06:17:23 +09:00
|
|
|
|
2015-05-15 22:29:43 +09:00
|
|
|
/**
|
|
|
|
* @class
|
|
|
|
*/
|
2019-12-26 04:03:46 +09:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var Driver = (function DriverClosure() {
|
2015-05-15 22:29:43 +09:00
|
|
|
/**
|
|
|
|
* @constructs Driver
|
|
|
|
* @param {DriverOptions} options
|
|
|
|
*/
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
2015-05-15 22:29:43 +09:00
|
|
|
function Driver(options) {
|
2018-02-14 22:49:24 +09:00
|
|
|
// Configure the global worker options.
|
2018-03-16 05:49:28 +09:00
|
|
|
pdfjsLib.GlobalWorkerOptions.workerSrc = WORKER_SRC;
|
2018-02-14 22:49:24 +09:00
|
|
|
|
2015-05-15 22:29:43 +09:00
|
|
|
// Set the passed options
|
|
|
|
this.inflight = options.inflight;
|
2015-05-16 02:58:34 +09:00
|
|
|
this.disableScrolling = options.disableScrolling;
|
|
|
|
this.output = options.output;
|
2015-05-15 22:29:43 +09:00
|
|
|
this.end = options.end;
|
|
|
|
|
|
|
|
// Set parameters from the query string
|
|
|
|
var parameters = this._getQueryStringParameters();
|
|
|
|
this.browser = parameters.browser;
|
|
|
|
this.manifestFile = parameters.manifestFile;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.delay = parameters.delay | 0 || 0;
|
2015-05-15 22:29:43 +09:00
|
|
|
this.inFlightRequests = 0;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.testFilter = parameters.testFilter
|
|
|
|
? JSON.parse(parameters.testFilter)
|
|
|
|
: [];
|
2015-05-15 22:29:43 +09:00
|
|
|
|
|
|
|
// Create a working canvas
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.canvas = document.createElement("canvas");
|
2013-01-31 04:31:08 +09:00
|
|
|
}
|
2014-04-10 08:44:07 +09:00
|
|
|
|
2015-05-15 22:29:43 +09:00
|
|
|
Driver.prototype = {
|
|
|
|
_getQueryStringParameters: function Driver_getQueryStringParameters() {
|
2015-05-15 22:54:48 +09:00
|
|
|
var queryString = window.location.search.substring(1);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var values = queryString.split("&");
|
2015-05-15 22:54:48 +09:00
|
|
|
var parameters = {};
|
|
|
|
for (var i = 0, ii = values.length; i < ii; i++) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var value = values[i].split("=");
|
2015-05-15 22:54:48 +09:00
|
|
|
parameters[unescape(value[0])] = unescape(value[1]);
|
2015-05-15 22:29:43 +09:00
|
|
|
}
|
2015-05-15 22:54:48 +09:00
|
|
|
return parameters;
|
2015-05-15 22:29:43 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
run: function Driver_run() {
|
2015-05-15 22:54:48 +09:00
|
|
|
var self = this;
|
2020-04-14 19:28:14 +09:00
|
|
|
window.onerror = function (message, source, line, column, error) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
self._info(
|
|
|
|
"Error: " +
|
|
|
|
message +
|
|
|
|
" Script: " +
|
|
|
|
source +
|
|
|
|
" Line: " +
|
|
|
|
line +
|
|
|
|
" Column: " +
|
|
|
|
column +
|
|
|
|
" StackTrace: " +
|
|
|
|
error
|
|
|
|
);
|
2016-03-23 07:49:32 +09:00
|
|
|
};
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this._info("User agent: " + navigator.userAgent);
|
2020-04-18 23:12:50 +09:00
|
|
|
this._log(`Harness thinks this browser is ${this.browser}\n`);
|
2015-05-15 22:29:43 +09:00
|
|
|
this._log('Fetching manifest "' + this.manifestFile + '"... ');
|
|
|
|
|
|
|
|
var r = new XMLHttpRequest();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
r.open("GET", this.manifestFile, false);
|
2020-04-14 19:28:14 +09:00
|
|
|
r.onreadystatechange = function () {
|
2015-05-15 22:29:43 +09:00
|
|
|
if (r.readyState === 4) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
self._log("done\n");
|
2015-05-15 22:29:43 +09:00
|
|
|
self.manifest = JSON.parse(r.responseText);
|
2015-07-11 18:26:53 +09:00
|
|
|
if (self.testFilter && self.testFilter.length) {
|
2020-04-14 19:28:14 +09:00
|
|
|
self.manifest = self.manifest.filter(function (item) {
|
2018-02-11 01:06:03 +09:00
|
|
|
return self.testFilter.includes(item.id);
|
2015-07-11 18:26:53 +09:00
|
|
|
});
|
|
|
|
}
|
2015-05-15 22:29:43 +09:00
|
|
|
self.currentTask = 0;
|
|
|
|
self._nextTask();
|
|
|
|
}
|
|
|
|
};
|
2015-05-15 22:54:48 +09:00
|
|
|
if (this.delay > 0) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this._log("\nDelaying for " + this.delay + " ms...\n");
|
2015-05-15 22:29:43 +09:00
|
|
|
}
|
|
|
|
// When gathering the stats the numbers seem to be more reliable
|
2015-05-15 22:54:48 +09:00
|
|
|
// if the browser is given more time to start.
|
2020-04-14 19:28:14 +09:00
|
|
|
setTimeout(function () {
|
2015-05-15 22:29:43 +09:00
|
|
|
r.send(null);
|
|
|
|
}, this.delay);
|
|
|
|
},
|
|
|
|
|
2017-05-11 19:54:48 +09:00
|
|
|
_nextTask() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
let failure = "";
|
2015-05-15 22:29:43 +09:00
|
|
|
|
2017-05-11 19:54:48 +09:00
|
|
|
this._cleanup().then(() => {
|
|
|
|
if (this.currentTask === this.manifest.length) {
|
|
|
|
this._done();
|
|
|
|
return;
|
|
|
|
}
|
2020-01-24 17:48:21 +09:00
|
|
|
const task = this.manifest[this.currentTask];
|
2017-05-11 19:54:48 +09:00
|
|
|
task.round = 0;
|
|
|
|
task.pageNum = task.firstPage || 1;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
task.stats = { times: [] };
|
2021-06-07 22:20:29 +09:00
|
|
|
task.enableXfa = task.enableXfa === true;
|
2017-05-11 19:54:48 +09:00
|
|
|
|
2021-03-30 20:24:04 +09:00
|
|
|
// Support *linked* test-cases for the other suites, e.g. unit- and
|
|
|
|
// integration-tests, without needing to run them as reference-tests.
|
|
|
|
if (task.type === "other") {
|
|
|
|
this._log(`Skipping file "${task.file}"\n`);
|
|
|
|
|
|
|
|
if (!task.link) {
|
|
|
|
this._nextPage(task, 'Expected "other" test-case to be linked.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.currentTask++;
|
|
|
|
this._nextTask();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-11 19:54:48 +09:00
|
|
|
this._log('Loading file "' + task.file + '"\n');
|
|
|
|
|
2020-01-24 17:48:21 +09:00
|
|
|
const absoluteUrl = new URL(task.file, window.location).href;
|
2017-05-11 19:54:48 +09:00
|
|
|
try {
|
2021-06-07 22:20:29 +09:00
|
|
|
let xfaStyleElement = null;
|
|
|
|
if (task.enableXfa) {
|
|
|
|
// Need to get the font definitions to inject them in the SVG.
|
|
|
|
// So we create this element and those definitions will be
|
|
|
|
// appended in font_loader.js.
|
|
|
|
xfaStyleElement = document.createElement("style");
|
|
|
|
document.documentElement
|
|
|
|
.getElementsByTagName("head")[0]
|
|
|
|
.appendChild(xfaStyleElement);
|
|
|
|
}
|
|
|
|
|
2018-11-08 21:40:06 +09:00
|
|
|
const loadingTask = pdfjsLib.getDocument({
|
2017-05-11 19:54:48 +09:00
|
|
|
url: absoluteUrl,
|
|
|
|
password: task.password,
|
2018-02-18 00:57:24 +09:00
|
|
|
cMapUrl: CMAP_URL,
|
|
|
|
cMapPacked: CMAP_PACKED,
|
2020-12-11 10:32:18 +09:00
|
|
|
standardFontDataUrl: STANDARD_FONT_DATA_URL,
|
2018-02-18 06:22:10 +09:00
|
|
|
disableRange: task.disableRange,
|
2018-02-18 06:08:45 +09:00
|
|
|
disableAutoFetch: !task.enableAutoFetch,
|
2018-02-18 07:13:49 +09:00
|
|
|
pdfBug: true,
|
2020-12-11 10:32:18 +09:00
|
|
|
useSystemFonts: task.useSystemFonts,
|
|
|
|
useWorkerFetch: task.useWorkerFetch,
|
2021-06-07 22:20:29 +09:00
|
|
|
enableXfa: task.enableXfa,
|
|
|
|
styleElement: xfaStyleElement,
|
2018-11-08 21:40:06 +09:00
|
|
|
});
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
loadingTask.promise.then(
|
|
|
|
doc => {
|
2021-06-07 22:20:29 +09:00
|
|
|
if (task.enableXfa) {
|
|
|
|
task.fontRules = "";
|
|
|
|
for (const rule of xfaStyleElement.sheet.cssRules) {
|
|
|
|
task.fontRules += rule.cssText + "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
task.pdfDoc = doc;
|
2021-05-16 17:58:34 +09:00
|
|
|
task.optionalContentConfigPromise =
|
|
|
|
doc.getOptionalContentConfig();
|
2020-08-07 03:51:57 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this._nextPage(task, failure);
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
failure = "Loading PDF document: " + err;
|
|
|
|
this._nextPage(task, failure);
|
|
|
|
}
|
|
|
|
);
|
2017-05-11 19:54:48 +09:00
|
|
|
return;
|
|
|
|
} catch (e) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
failure = "Loading PDF document: " + this._exceptionToString(e);
|
2017-05-11 19:54:48 +09:00
|
|
|
}
|
|
|
|
this._nextPage(task, failure);
|
|
|
|
});
|
2015-05-15 22:29:43 +09:00
|
|
|
},
|
|
|
|
|
2017-05-11 19:54:48 +09:00
|
|
|
_cleanup() {
|
2015-05-15 22:29:43 +09:00
|
|
|
// Clear out all the stylesheets since a new one is created for each font.
|
|
|
|
while (document.styleSheets.length > 0) {
|
2020-01-24 17:48:21 +09:00
|
|
|
const styleSheet = document.styleSheets[0];
|
2015-05-15 22:29:43 +09:00
|
|
|
while (styleSheet.cssRules.length > 0) {
|
|
|
|
styleSheet.deleteRule(0);
|
|
|
|
}
|
2018-02-11 00:19:45 +09:00
|
|
|
styleSheet.ownerNode.remove();
|
2015-05-15 22:29:43 +09:00
|
|
|
}
|
2020-01-24 17:48:21 +09:00
|
|
|
const body = document.body;
|
2015-05-15 22:29:43 +09:00
|
|
|
while (body.lastChild !== this.end) {
|
|
|
|
body.removeChild(body.lastChild);
|
|
|
|
}
|
2011-07-05 06:17:23 +09:00
|
|
|
|
2020-01-24 17:48:21 +09:00
|
|
|
const destroyedPromises = [];
|
2015-05-15 22:29:43 +09:00
|
|
|
// Wipe out the link to the pdfdoc so it can be GC'ed.
|
2017-05-11 19:54:48 +09:00
|
|
|
for (let i = 0; i < this.manifest.length; i++) {
|
2015-05-15 22:29:43 +09:00
|
|
|
if (this.manifest[i].pdfDoc) {
|
2017-05-11 19:54:48 +09:00
|
|
|
destroyedPromises.push(this.manifest[i].pdfDoc.destroy());
|
2015-05-15 22:29:43 +09:00
|
|
|
delete this.manifest[i].pdfDoc;
|
|
|
|
}
|
|
|
|
}
|
2017-05-11 19:54:48 +09:00
|
|
|
return Promise.all(destroyedPromises);
|
2015-05-15 22:29:43 +09:00
|
|
|
},
|
2011-12-08 13:07:34 +09:00
|
|
|
|
2015-05-15 22:29:43 +09:00
|
|
|
_exceptionToString: function Driver_exceptionToString(e) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (typeof e !== "object") {
|
2015-05-15 22:29:43 +09:00
|
|
|
return String(e);
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (!("message" in e)) {
|
2015-05-15 22:29:43 +09:00
|
|
|
return JSON.stringify(e);
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return e.message + ("stack" in e ? " at " + e.stack.split("\n")[0] : "");
|
2015-05-15 22:29:43 +09:00
|
|
|
},
|
2011-09-24 23:44:50 +09:00
|
|
|
|
2015-05-15 22:54:48 +09:00
|
|
|
_getLastPageNumber: function Driver_getLastPageNumber(task) {
|
2015-05-15 22:29:43 +09:00
|
|
|
if (!task.pdfDoc) {
|
|
|
|
return task.firstPage || 1;
|
|
|
|
}
|
2015-05-15 22:54:48 +09:00
|
|
|
var lastPageNumber = task.lastPage || 0;
|
|
|
|
if (!lastPageNumber || lastPageNumber > task.pdfDoc.numPages) {
|
|
|
|
lastPageNumber = task.pdfDoc.numPages;
|
2015-05-15 22:29:43 +09:00
|
|
|
}
|
2015-05-15 22:54:48 +09:00
|
|
|
return lastPageNumber;
|
2015-05-15 22:29:43 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
_nextPage: function Driver_nextPage(task, loadError) {
|
|
|
|
var self = this;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var failure = loadError || "";
|
2015-11-17 01:50:02 +09:00
|
|
|
var ctx;
|
2015-05-15 22:29:43 +09:00
|
|
|
|
|
|
|
if (!task.pdfDoc) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var dataUrl = this.canvas.toDataURL("image/png");
|
2020-04-14 19:28:14 +09:00
|
|
|
this._sendResult(dataUrl, task, failure, function () {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
self._log(
|
|
|
|
"done" + (failure ? " (failed !: " + failure + ")" : "") + "\n"
|
|
|
|
);
|
2015-05-15 22:29:43 +09:00
|
|
|
self.currentTask++;
|
|
|
|
self._nextTask();
|
2014-01-04 09:17:05 +09:00
|
|
|
});
|
2015-05-15 22:29:43 +09:00
|
|
|
return;
|
|
|
|
}
|
2012-09-16 23:46:29 +09:00
|
|
|
|
2015-05-15 22:54:48 +09:00
|
|
|
if (task.pageNum > this._getLastPageNumber(task)) {
|
2015-05-15 22:29:43 +09:00
|
|
|
if (++task.round < task.rounds) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this._log(" Round " + (1 + task.round) + "\n");
|
2015-05-15 22:29:43 +09:00
|
|
|
task.pageNum = task.firstPage || 1;
|
2012-09-12 08:04:01 +09:00
|
|
|
} else {
|
2015-05-15 22:29:43 +09:00
|
|
|
this.currentTask++;
|
|
|
|
this._nextTask();
|
|
|
|
return;
|
2012-09-12 08:04:01 +09:00
|
|
|
}
|
2015-05-15 22:29:43 +09:00
|
|
|
}
|
|
|
|
|
2018-02-11 01:06:03 +09:00
|
|
|
if (task.skipPages && task.skipPages.includes(task.pageNum)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this._log(
|
|
|
|
" Skipping page " +
|
|
|
|
task.pageNum +
|
|
|
|
"/" +
|
|
|
|
task.pdfDoc.numPages +
|
|
|
|
"...\n"
|
|
|
|
);
|
2017-04-06 20:17:52 +09:00
|
|
|
task.pageNum++;
|
|
|
|
this._nextPage(task);
|
2015-05-15 22:29:43 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!failure) {
|
|
|
|
try {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this._log(
|
|
|
|
" Loading page " +
|
|
|
|
task.pageNum +
|
|
|
|
"/" +
|
|
|
|
task.pdfDoc.numPages +
|
|
|
|
"... "
|
|
|
|
);
|
2015-11-17 01:50:02 +09:00
|
|
|
this.canvas.mozOpaque = true;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
ctx = this.canvas.getContext("2d", { alpha: false });
|
|
|
|
task.pdfDoc.getPage(task.pageNum).then(
|
2020-04-14 19:28:14 +09:00
|
|
|
function (page) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var viewport = page.getViewport({ scale: PDF_TO_CSS_UNITS });
|
|
|
|
self.canvas.width = viewport.width;
|
|
|
|
self.canvas.height = viewport.height;
|
|
|
|
self._clearCanvas();
|
|
|
|
|
|
|
|
// Initialize various `eq` test subtypes, see comment below.
|
|
|
|
var renderAnnotations = false,
|
2020-08-18 05:03:01 +09:00
|
|
|
renderForms = false,
|
2021-06-07 22:20:29 +09:00
|
|
|
renderPrint = false,
|
|
|
|
renderXfa = false;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
|
|
|
var textLayerCanvas, annotationLayerCanvas;
|
|
|
|
var initPromise;
|
|
|
|
if (task.type === "text") {
|
|
|
|
// Using a dummy canvas for PDF context drawing operations
|
|
|
|
textLayerCanvas = self.textLayerCanvas;
|
|
|
|
if (!textLayerCanvas) {
|
|
|
|
textLayerCanvas = document.createElement("canvas");
|
|
|
|
self.textLayerCanvas = textLayerCanvas;
|
2015-12-19 06:29:22 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
textLayerCanvas.width = viewport.width;
|
|
|
|
textLayerCanvas.height = viewport.height;
|
|
|
|
var textLayerContext = textLayerCanvas.getContext("2d");
|
|
|
|
textLayerContext.clearRect(
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
textLayerCanvas.width,
|
|
|
|
textLayerCanvas.height
|
|
|
|
);
|
|
|
|
var enhanceText = !!task.enhance;
|
|
|
|
// The text builder will draw its content on the test canvas
|
|
|
|
initPromise = page
|
|
|
|
.getTextContent({
|
|
|
|
normalizeWhitespace: true,
|
2021-04-01 07:07:02 +09:00
|
|
|
includeMarkedContent: true,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
})
|
2020-04-14 19:28:14 +09:00
|
|
|
.then(function (textContent) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return rasterizeTextLayer(
|
|
|
|
textLayerContext,
|
|
|
|
viewport,
|
|
|
|
textContent,
|
|
|
|
enhanceText
|
|
|
|
);
|
2015-12-19 06:29:22 +09:00
|
|
|
});
|
|
|
|
} else {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
textLayerCanvas = null;
|
|
|
|
// We fetch the `eq` specific test subtypes here, to avoid
|
|
|
|
// accidentally changing the behaviour for other types of tests.
|
|
|
|
renderAnnotations = !!task.annotations;
|
|
|
|
renderForms = !!task.forms;
|
2020-08-18 05:03:01 +09:00
|
|
|
renderPrint = !!task.print;
|
2021-06-07 22:20:29 +09:00
|
|
|
renderXfa = !!task.enableXfa;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
|
|
|
// Render the annotation layer if necessary.
|
2021-06-07 22:20:29 +09:00
|
|
|
if (renderAnnotations || renderForms || renderXfa) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
// Create a dummy canvas for the drawing operations.
|
|
|
|
annotationLayerCanvas = self.annotationLayerCanvas;
|
|
|
|
if (!annotationLayerCanvas) {
|
|
|
|
annotationLayerCanvas = document.createElement("canvas");
|
|
|
|
self.annotationLayerCanvas = annotationLayerCanvas;
|
|
|
|
}
|
|
|
|
annotationLayerCanvas.width = viewport.width;
|
|
|
|
annotationLayerCanvas.height = viewport.height;
|
2021-05-16 17:58:34 +09:00
|
|
|
var annotationLayerContext =
|
|
|
|
annotationLayerCanvas.getContext("2d");
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
annotationLayerContext.clearRect(
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
annotationLayerCanvas.width,
|
|
|
|
annotationLayerCanvas.height
|
|
|
|
);
|
|
|
|
|
2021-06-07 22:20:29 +09:00
|
|
|
if (!renderXfa) {
|
|
|
|
// The annotation builder will draw its content
|
|
|
|
// on the canvas.
|
|
|
|
initPromise = page
|
|
|
|
.getAnnotations({ intent: "display" })
|
|
|
|
.then(function (annotations) {
|
|
|
|
return rasterizeAnnotationLayer(
|
|
|
|
annotationLayerContext,
|
|
|
|
viewport,
|
|
|
|
annotations,
|
|
|
|
page,
|
|
|
|
IMAGE_RESOURCES_PATH,
|
|
|
|
renderForms
|
|
|
|
);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
initPromise = page.getXfa().then(function (xfa) {
|
|
|
|
return rasterizeXfaLayer(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
annotationLayerContext,
|
|
|
|
viewport,
|
2021-06-07 22:20:29 +09:00
|
|
|
xfa,
|
|
|
|
task.fontRules
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
);
|
|
|
|
});
|
2021-06-07 22:20:29 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
} else {
|
|
|
|
annotationLayerCanvas = null;
|
|
|
|
initPromise = Promise.resolve();
|
|
|
|
}
|
2015-12-19 06:29:22 +09:00
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var renderContext = {
|
|
|
|
canvasContext: ctx,
|
|
|
|
viewport,
|
|
|
|
renderInteractiveForms: renderForms,
|
2020-08-07 03:51:57 +09:00
|
|
|
optionalContentConfigPromise: task.optionalContentConfigPromise,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
};
|
2020-08-18 05:03:01 +09:00
|
|
|
if (renderPrint) {
|
[api-minor] Remove the manual passing of an `AnnotationStorage`-instance when calling various API-method
Note how we purposely don't expose the `AnnotationStorage`-class directly in the official API (see `src/pdf.js`), since trying to use *multiple* ones simultaneously doesn't really make sense (e.g. in the viewer).
Instead we lazily initialize, and cache, just *one* instance via `PDFDocumentProxy.annotationStorage` which should thus be available internally in the API itself without having to be manually passed to various methods.
To support these changes, the `AnnotationStorage`-instance initialization is moved into the `WorkerTransport`-class to allow both `PDFDocumentProxy` and `PDFPageProxy` to access it.
This patch implements the following simplifications:
- Remove the `annotationStorage`-parameter from `PDFDocumentProxy.saveDocument`, since it's already available internally.
Furthermore, while it's currently possible to call that method without an `AnnotationStorage`-instance, that really does *not* make any sense at all. In this case you're effectively reducing `PDFDocumentProxy.saveDocument` to a "regular" `PDFDocumentProxy.getData` call, but with *a lot* more overhead, which was obviously not the intention of the `PDFDocumentProxy.saveDocument`-method.
- Try to discourage third-party users from calling `PDFDocumentProxy.saveDocument` unconditionally, as a replacement for `PDFDocumentProxy.getData` (note the previous point).
- Replace the `annotationStorage`-parameter, in `PDFPageProxy.render`, with a boolean `includeAnnotationStorage`-parameter which simply indicates if the (internally available) `AnnotationStorage`-instance should be used during rendering (e.g. for printing).
- By removing the need to *manually* provide `annotationStorage`-parameters to various API-methods, using the API should become simpler (e.g. for third-parties) since you no longer need to worry about manually fetching and passing around this data.
2021-04-04 23:49:06 +09:00
|
|
|
if (task.annotationStorage) {
|
|
|
|
const entries = Object.entries(task.annotationStorage),
|
|
|
|
docAnnotationStorage = task.pdfDoc.annotationStorage;
|
2020-08-18 05:03:01 +09:00
|
|
|
for (const [key, value] of entries) {
|
|
|
|
docAnnotationStorage.setValue(key, value);
|
|
|
|
}
|
[api-minor] Remove the manual passing of an `AnnotationStorage`-instance when calling various API-method
Note how we purposely don't expose the `AnnotationStorage`-class directly in the official API (see `src/pdf.js`), since trying to use *multiple* ones simultaneously doesn't really make sense (e.g. in the viewer).
Instead we lazily initialize, and cache, just *one* instance via `PDFDocumentProxy.annotationStorage` which should thus be available internally in the API itself without having to be manually passed to various methods.
To support these changes, the `AnnotationStorage`-instance initialization is moved into the `WorkerTransport`-class to allow both `PDFDocumentProxy` and `PDFPageProxy` to access it.
This patch implements the following simplifications:
- Remove the `annotationStorage`-parameter from `PDFDocumentProxy.saveDocument`, since it's already available internally.
Furthermore, while it's currently possible to call that method without an `AnnotationStorage`-instance, that really does *not* make any sense at all. In this case you're effectively reducing `PDFDocumentProxy.saveDocument` to a "regular" `PDFDocumentProxy.getData` call, but with *a lot* more overhead, which was obviously not the intention of the `PDFDocumentProxy.saveDocument`-method.
- Try to discourage third-party users from calling `PDFDocumentProxy.saveDocument` unconditionally, as a replacement for `PDFDocumentProxy.getData` (note the previous point).
- Replace the `annotationStorage`-parameter, in `PDFPageProxy.render`, with a boolean `includeAnnotationStorage`-parameter which simply indicates if the (internally available) `AnnotationStorage`-instance should be used during rendering (e.g. for printing).
- By removing the need to *manually* provide `annotationStorage`-parameters to various API-methods, using the API should become simpler (e.g. for third-parties) since you no longer need to worry about manually fetching and passing around this data.
2021-04-04 23:49:06 +09:00
|
|
|
renderContext.includeAnnotationStorage = true;
|
2020-08-18 05:03:01 +09:00
|
|
|
}
|
|
|
|
renderContext.intent = "print";
|
|
|
|
}
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
var completeRender = function (error) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
// if text layer is present, compose it on top of the page
|
|
|
|
if (textLayerCanvas) {
|
|
|
|
ctx.save();
|
|
|
|
ctx.globalCompositeOperation = "screen";
|
|
|
|
ctx.fillStyle = "rgb(128, 255, 128)"; // making it green
|
|
|
|
ctx.fillRect(0, 0, viewport.width, viewport.height);
|
|
|
|
ctx.restore();
|
|
|
|
ctx.drawImage(textLayerCanvas, 0, 0);
|
|
|
|
}
|
|
|
|
// If we have annotation layer, compose it on top of the page.
|
|
|
|
if (annotationLayerCanvas) {
|
|
|
|
ctx.drawImage(annotationLayerCanvas, 0, 0);
|
|
|
|
}
|
|
|
|
if (page.stats) {
|
|
|
|
// Get the page stats *before* running cleanup.
|
|
|
|
task.stats = page.stats;
|
|
|
|
}
|
|
|
|
page.cleanup(/* resetStats = */ true);
|
|
|
|
self._snapshot(task, error);
|
|
|
|
};
|
|
|
|
initPromise
|
2020-04-14 19:28:14 +09:00
|
|
|
.then(function () {
|
2020-06-29 03:14:03 +09:00
|
|
|
const renderTask = page.render(renderContext);
|
|
|
|
|
|
|
|
if (task.renderTaskOnContinue) {
|
|
|
|
renderTask.onContinue = function (cont) {
|
|
|
|
// Slightly delay the continued rendering.
|
|
|
|
setTimeout(cont, RENDER_TASK_ON_CONTINUE_DELAY);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return renderTask.promise.then(function () {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
completeRender(false);
|
|
|
|
});
|
|
|
|
})
|
2020-04-14 19:28:14 +09:00
|
|
|
.catch(function (error) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
completeRender("render : " + error);
|
|
|
|
});
|
|
|
|
},
|
2020-04-14 19:28:14 +09:00
|
|
|
function (error) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
self._snapshot(task, "render : " + error);
|
|
|
|
}
|
|
|
|
);
|
2015-05-15 22:29:43 +09:00
|
|
|
} catch (e) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
failure = "page setup : " + this._exceptionToString(e);
|
2015-05-15 22:29:43 +09:00
|
|
|
this._snapshot(task, failure);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_clearCanvas: function Driver_clearCanvas() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var ctx = this.canvas.getContext("2d", { alpha: false });
|
2015-05-15 22:29:43 +09:00
|
|
|
ctx.beginPath();
|
|
|
|
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
|
|
},
|
|
|
|
|
|
|
|
_snapshot: function Driver_snapshot(task, failure) {
|
|
|
|
var self = this;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this._log("Snapshotting... ");
|
2015-05-15 22:29:43 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var dataUrl = this.canvas.toDataURL("image/png");
|
2020-04-14 19:28:14 +09:00
|
|
|
this._sendResult(dataUrl, task, failure, function () {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
self._log(
|
|
|
|
"done" + (failure ? " (failed !: " + failure + ")" : "") + "\n"
|
|
|
|
);
|
2015-05-15 22:29:43 +09:00
|
|
|
task.pageNum++;
|
|
|
|
self._nextPage(task);
|
2012-04-12 10:05:43 +09:00
|
|
|
});
|
2015-05-15 22:29:43 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
_quit: function Driver_quit() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this._log("Done !");
|
|
|
|
this.end.textContent = "Tests finished. Close this window!";
|
2015-05-15 22:29:43 +09:00
|
|
|
|
2015-05-15 22:54:48 +09:00
|
|
|
// Send the quit request
|
2015-05-15 22:29:43 +09:00
|
|
|
var r = new XMLHttpRequest();
|
2020-04-18 23:12:50 +09:00
|
|
|
r.open("POST", `/tellMeToQuit?browser=${escape(this.browser)}`, false);
|
2020-04-14 19:28:14 +09:00
|
|
|
r.onreadystatechange = function (e) {
|
2015-05-15 22:29:43 +09:00
|
|
|
if (r.readyState === 4) {
|
2015-05-15 22:54:48 +09:00
|
|
|
window.close();
|
2015-05-15 22:29:43 +09:00
|
|
|
}
|
|
|
|
};
|
|
|
|
r.send(null);
|
|
|
|
},
|
|
|
|
|
|
|
|
_info: function Driver_info(message) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this._send(
|
|
|
|
"/info",
|
|
|
|
JSON.stringify({
|
|
|
|
browser: this.browser,
|
|
|
|
message,
|
|
|
|
})
|
|
|
|
);
|
2015-05-15 22:29:43 +09:00
|
|
|
},
|
|
|
|
|
2015-05-15 22:54:48 +09:00
|
|
|
_log: function Driver_log(message) {
|
|
|
|
// Using insertAdjacentHTML yields a large performance gain and
|
|
|
|
// reduces runtime significantly.
|
|
|
|
if (this.output.insertAdjacentHTML) {
|
2019-06-23 20:37:51 +09:00
|
|
|
// eslint-disable-next-line no-unsanitized/method
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.output.insertAdjacentHTML("BeforeEnd", message);
|
2015-05-15 22:29:43 +09:00
|
|
|
} else {
|
2015-05-15 22:54:48 +09:00
|
|
|
this.output.textContent += message;
|
2014-04-12 03:02:03 +09:00
|
|
|
}
|
2015-05-15 22:29:43 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (message.lastIndexOf("\n") >= 0 && !this.disableScrolling.checked) {
|
2015-05-15 22:29:43 +09:00
|
|
|
// Scroll to the bottom of the page
|
2015-05-16 02:58:34 +09:00
|
|
|
this.output.scrollTop = this.output.scrollHeight;
|
2012-12-05 03:28:25 +09:00
|
|
|
}
|
2015-05-15 22:29:43 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
_done: function Driver_done() {
|
|
|
|
if (this.inFlightRequests > 0) {
|
2015-05-15 22:54:48 +09:00
|
|
|
this.inflight.textContent = this.inFlightRequests;
|
2015-07-11 18:26:53 +09:00
|
|
|
setTimeout(this._done.bind(this), WAITING_TIME);
|
2015-05-15 22:29:43 +09:00
|
|
|
} else {
|
2015-07-11 18:26:53 +09:00
|
|
|
setTimeout(this._quit.bind(this), WAITING_TIME);
|
2014-03-25 21:29:53 +09:00
|
|
|
}
|
2015-05-15 22:29:43 +09:00
|
|
|
},
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
_sendResult: function Driver_sendResult(snapshot, task, failure, callback) {
|
2015-05-15 22:29:43 +09:00
|
|
|
var result = JSON.stringify({
|
|
|
|
browser: this.browser,
|
|
|
|
id: task.id,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
numPages: task.pdfDoc ? task.lastPage || task.pdfDoc.numPages : 0,
|
2015-05-15 22:54:48 +09:00
|
|
|
lastPageNum: this._getLastPageNumber(task),
|
2017-04-28 20:40:47 +09:00
|
|
|
failure,
|
2015-05-15 22:29:43 +09:00
|
|
|
file: task.file,
|
|
|
|
round: task.round,
|
|
|
|
page: task.pageNum,
|
2017-04-28 20:40:47 +09:00
|
|
|
snapshot,
|
Fix inconsistent spacing and trailing commas in objects in `test/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/test/chromium/test-telemetry.js b/test/chromium/test-telemetry.js
index cc412a31..2e5bdfa1 100755
--- a/test/chromium/test-telemetry.js
+++ b/test/chromium/test-telemetry.js
@@ -324,7 +324,7 @@ var tests = [
var window = createExtensionGlobal();
telemetryScript.runInNewContext(window);
window.chrome.runtime.getManifest = function() {
- return { version: '1.0.1', };
+ return { version: '1.0.1', };
};
window.Date.test_now_value += 12 * 36E5;
telemetryScript.runInNewContext(window);
diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js
index 1f00747a..f22988e7 100644
--- a/test/unit/api_spec.js
+++ b/test/unit/api_spec.js
@@ -503,8 +503,9 @@ describe('api', function() {
it('gets destinations, from /Dests dictionary', function(done) {
var promise = doc.getDestinations();
promise.then(function(data) {
- expect(data).toEqual({ chapter1: [{ gen: 0, num: 17, }, { name: 'XYZ', },
- 0, 841.89, null], });
+ expect(data).toEqual({
+ chapter1: [{ gen: 0, num: 17, }, { name: 'XYZ', }, 0, 841.89, null],
+ });
done();
}).catch(function (reason) {
done.fail(reason);
diff --git a/test/unit/function_spec.js b/test/unit/function_spec.js
index 66441212..62127eb9 100644
--- a/test/unit/function_spec.js
+++ b/test/unit/function_spec.js
@@ -492,9 +492,11 @@ describe('function', 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], }]);
+ check([0.5, 'mul'], [0, 1], [0, 1],
+ [{ input: [0.25], output: [0.125], }]);
check([1, 'mul'], [0, 1], [0, 1], [{ input: [0.25], output: [0.25], }]);
- check([0, 'exch', 'mul'], [0, 1], [0, 1], [{ input: [0.25], output: [0], }]);
+ check([0, 'exch', 'mul'], [0, 1], [0, 1],
+ [{ input: [0.25], output: [0], }]);
check([0.5, 'exch', 'mul'], [0, 1], [0, 1],
[{ input: [0.25], output: [0.125], }]);
check([1, 'exch', 'mul'], [0, 1], [0, 1],
```
2017-06-02 19:55:01 +09:00
|
|
|
stats: task.stats.times,
|
2015-05-15 22:29:43 +09:00
|
|
|
});
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this._send("/submit_task_results", result, callback);
|
2015-05-15 22:29:43 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
_send: function Driver_send(url, message, callback) {
|
|
|
|
var self = this;
|
|
|
|
var r = new XMLHttpRequest();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
r.open("POST", url, true);
|
|
|
|
r.setRequestHeader("Content-Type", "application/json");
|
2020-04-14 19:28:14 +09:00
|
|
|
r.onreadystatechange = function (e) {
|
2015-05-15 22:29:43 +09:00
|
|
|
if (r.readyState === 4) {
|
|
|
|
self.inFlightRequests--;
|
|
|
|
|
|
|
|
// Retry until successful
|
|
|
|
if (r.status !== 200) {
|
2020-04-14 19:28:14 +09:00
|
|
|
setTimeout(function () {
|
2015-05-15 22:29:43 +09:00
|
|
|
self._send(url, message);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (callback) {
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-05-15 22:54:48 +09:00
|
|
|
this.inflight.textContent = this.inFlightRequests++;
|
2015-05-15 22:29:43 +09:00
|
|
|
r.send(message);
|
Fix inconsistent spacing and trailing commas in objects in `test/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/test/chromium/test-telemetry.js b/test/chromium/test-telemetry.js
index cc412a31..2e5bdfa1 100755
--- a/test/chromium/test-telemetry.js
+++ b/test/chromium/test-telemetry.js
@@ -324,7 +324,7 @@ var tests = [
var window = createExtensionGlobal();
telemetryScript.runInNewContext(window);
window.chrome.runtime.getManifest = function() {
- return { version: '1.0.1', };
+ return { version: '1.0.1', };
};
window.Date.test_now_value += 12 * 36E5;
telemetryScript.runInNewContext(window);
diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js
index 1f00747a..f22988e7 100644
--- a/test/unit/api_spec.js
+++ b/test/unit/api_spec.js
@@ -503,8 +503,9 @@ describe('api', function() {
it('gets destinations, from /Dests dictionary', function(done) {
var promise = doc.getDestinations();
promise.then(function(data) {
- expect(data).toEqual({ chapter1: [{ gen: 0, num: 17, }, { name: 'XYZ', },
- 0, 841.89, null], });
+ expect(data).toEqual({
+ chapter1: [{ gen: 0, num: 17, }, { name: 'XYZ', }, 0, 841.89, null],
+ });
done();
}).catch(function (reason) {
done.fail(reason);
diff --git a/test/unit/function_spec.js b/test/unit/function_spec.js
index 66441212..62127eb9 100644
--- a/test/unit/function_spec.js
+++ b/test/unit/function_spec.js
@@ -492,9 +492,11 @@ describe('function', 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], }]);
+ check([0.5, 'mul'], [0, 1], [0, 1],
+ [{ input: [0.25], output: [0.125], }]);
check([1, 'mul'], [0, 1], [0, 1], [{ input: [0.25], output: [0.25], }]);
- check([0, 'exch', 'mul'], [0, 1], [0, 1], [{ input: [0.25], output: [0], }]);
+ check([0, 'exch', 'mul'], [0, 1], [0, 1],
+ [{ input: [0.25], output: [0], }]);
check([0.5, 'exch', 'mul'], [0, 1], [0, 1],
[{ input: [0.25], output: [0.125], }]);
check([1, 'exch', 'mul'], [0, 1], [0, 1],
```
2017-06-02 19:55:01 +09:00
|
|
|
},
|
2011-09-16 05:32:44 +09:00
|
|
|
};
|
2013-05-31 08:33:05 +09:00
|
|
|
|
2015-05-15 22:29:43 +09:00
|
|
|
return Driver;
|
|
|
|
})();
|