2017-01-10 01:40:57 +09:00
|
|
|
|
/* Copyright 2017 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.
|
|
|
|
|
*/
|
2017-04-17 05:30:27 +09:00
|
|
|
|
|
|
|
|
|
import {
|
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
|
|
|
|
Annotation,
|
|
|
|
|
AnnotationBorderStyle,
|
|
|
|
|
AnnotationFactory,
|
|
|
|
|
getQuadPoints,
|
|
|
|
|
MarkupAnnotation,
|
2020-01-02 20:00:16 +09:00
|
|
|
|
} from "../../src/core/annotation.js";
|
2017-04-17 05:30:27 +09:00
|
|
|
|
import {
|
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
|
|
|
|
AnnotationBorderStyleType,
|
|
|
|
|
AnnotationFieldFlag,
|
|
|
|
|
AnnotationFlag,
|
|
|
|
|
AnnotationType,
|
2020-07-23 00:10:59 +09:00
|
|
|
|
OPS,
|
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
|
|
|
|
stringToBytes,
|
|
|
|
|
stringToUTF8String,
|
2020-01-02 20:00:16 +09:00
|
|
|
|
} from "../../src/shared/util.js";
|
|
|
|
|
import { createIdFactory, XRefMock } from "./test_utils.js";
|
2020-08-05 21:40:31 +09:00
|
|
|
|
import { Dict, Name, Ref, RefSetCache } from "../../src/core/primitives.js";
|
2020-01-02 20:00:16 +09:00
|
|
|
|
import { Lexer, Parser } from "../../src/core/parser.js";
|
2020-07-23 00:10:59 +09:00
|
|
|
|
import { PartialEvaluator } from "../../src/core/evaluator.js";
|
2020-01-02 20:00:16 +09:00
|
|
|
|
import { StringStream } from "../../src/core/stream.js";
|
2020-07-23 00:10:59 +09:00
|
|
|
|
import { WorkerTask } from "../../src/core/worker.js";
|
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
|
|
|
|
describe("annotation", function () {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
class PDFManagerMock {
|
|
|
|
|
constructor(params) {
|
|
|
|
|
this.docBaseUrl = params.docBaseUrl || null;
|
2020-07-23 00:10:59 +09:00
|
|
|
|
this.pdfDocument = {
|
2020-08-23 06:33:19 +09:00
|
|
|
|
catalog: {
|
|
|
|
|
acroForm: new Dict(),
|
|
|
|
|
},
|
2020-07-23 00:10:59 +09:00
|
|
|
|
};
|
2018-03-21 09:43:40 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ensure(obj, prop, args) {
|
2020-04-14 19:28:14 +09:00
|
|
|
|
return new Promise(function (resolve) {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
const value = obj[prop];
|
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 value === "function") {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
resolve(value.apply(obj, args));
|
|
|
|
|
} else {
|
|
|
|
|
resolve(value);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-07-23 00:10:59 +09:00
|
|
|
|
|
2020-08-23 06:33:19 +09:00
|
|
|
|
ensureCatalog(prop, args) {
|
|
|
|
|
return this.ensure(this.pdfDocument.catalog, prop, args);
|
2020-07-23 00:10:59 +09:00
|
|
|
|
}
|
2020-10-29 03:16:56 +09:00
|
|
|
|
|
|
|
|
|
ensureDoc(prop, args) {
|
|
|
|
|
return this.ensure(this.pdfDocument, prop, args);
|
|
|
|
|
}
|
2020-07-23 00:10:59 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function HandlerMock() {
|
|
|
|
|
this.inputs = [];
|
2016-10-01 19:05:07 +09:00
|
|
|
|
}
|
2020-07-23 00:10:59 +09:00
|
|
|
|
HandlerMock.prototype = {
|
|
|
|
|
send(name, data) {
|
|
|
|
|
this.inputs.push({ name, data });
|
|
|
|
|
},
|
|
|
|
|
};
|
2016-10-01 19:05:07 +09:00
|
|
|
|
|
2020-07-23 00:10:59 +09:00
|
|
|
|
let pdfManagerMock, idFactoryMock, partialEvaluator;
|
2016-05-25 00:35:45 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
beforeAll(function (done) {
|
2016-10-01 19:05:07 +09:00
|
|
|
|
pdfManagerMock = new PDFManagerMock({
|
|
|
|
|
docBaseUrl: null,
|
|
|
|
|
});
|
2019-04-20 19:36:49 +09:00
|
|
|
|
idFactoryMock = createIdFactory(/* pageIndex = */ 0);
|
2020-07-23 00:10:59 +09:00
|
|
|
|
partialEvaluator = new PartialEvaluator({
|
|
|
|
|
xref: new XRefMock(),
|
|
|
|
|
handler: new HandlerMock(),
|
|
|
|
|
pageIndex: 0,
|
|
|
|
|
idFactory: createIdFactory(/* pageIndex = */ 0),
|
2020-08-05 21:40:31 +09:00
|
|
|
|
fontCache: new RefSetCache(),
|
2020-07-23 00:10:59 +09:00
|
|
|
|
});
|
2016-05-25 00:35:45 +09:00
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
afterAll(function () {
|
2016-10-01 19:05:07 +09:00
|
|
|
|
pdfManagerMock = null;
|
2017-01-09 00:51:30 +09:00
|
|
|
|
idFactoryMock = null;
|
2020-07-23 00:10:59 +09:00
|
|
|
|
partialEvaluator = null;
|
2016-05-25 00:35:45 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("AnnotationFactory", function () {
|
|
|
|
|
it("should get id for annotation", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
2016-08-26 23:01:25 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const annotationRef = Ref.get(10, 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
|
|
|
|
const xref = new XRefMock([{ ref: annotationRef, data: annotationDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
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
|
|
|
|
expect(data.id).toEqual("10R");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-08-26 23:01:25 +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
|
|
|
|
it(
|
|
|
|
|
"should handle, and get fallback IDs for, annotations that are not " +
|
|
|
|
|
"indirect objects (issue 7569)",
|
2020-04-14 19:28:14 +09:00
|
|
|
|
function (done) {
|
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 annotationDict = new Dict();
|
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
|
|
|
|
|
const xref = new XRefMock();
|
|
|
|
|
const idFactory = createIdFactory(/* pageIndex = */ 0);
|
|
|
|
|
|
|
|
|
|
const annotation1 = AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationDict,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactory
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.id).toEqual("annot_p0_1");
|
|
|
|
|
});
|
2016-08-26 23:01:25 +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
|
|
|
|
const annotation2 = AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationDict,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactory
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.id).toEqual("annot_p0_2");
|
|
|
|
|
});
|
2018-03-21 09:43:40 +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
|
|
|
|
Promise.all([annotation1, annotation2]).then(done, done.fail);
|
|
|
|
|
}
|
|
|
|
|
);
|
2016-08-26 23:01:25 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle missing /Subtype", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
2016-07-24 21:32:48 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const annotationRef = Ref.get(1, 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
|
|
|
|
const xref = new XRefMock([{ ref: annotationRef, data: annotationDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toBeUndefined();
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-07-24 21:32:48 +09:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("getQuadPoints", function () {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
let dict, rect;
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
beforeEach(function (done) {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
dict = new Dict();
|
|
|
|
|
rect = [];
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
afterEach(function () {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
dict = null;
|
|
|
|
|
rect = null;
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should ignore missing quadpoints", function () {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(getQuadPoints(dict, rect)).toEqual(null);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should ignore non-array values", 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
|
|
|
|
dict.set("QuadPoints", "foo");
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(getQuadPoints(dict, rect)).toEqual(null);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should ignore arrays where the length is not a multiple of eight", 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
|
|
|
|
dict.set("QuadPoints", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(getQuadPoints(dict, rect)).toEqual(null);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should ignore quadpoints if one coordinate lies outside the rectangle", function () {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
rect = [10, 10, 20, 20];
|
|
|
|
|
const inputs = [
|
|
|
|
|
[11, 11, 12, 12, 9, 13, 14, 14], // Smaller than lower x coordinate.
|
|
|
|
|
[11, 11, 12, 12, 13, 9, 14, 14], // Smaller than lower y coordinate.
|
|
|
|
|
[11, 11, 12, 12, 21, 13, 14, 14], // Larger than upper x coordinate.
|
|
|
|
|
[11, 11, 12, 12, 13, 21, 14, 14], // Larger than upper y coordinate.
|
|
|
|
|
];
|
|
|
|
|
for (const input of inputs) {
|
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
|
|
|
|
dict.set("QuadPoints", input);
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(getQuadPoints(dict, rect)).toEqual(null);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2020-12-06 05:27:38 +09:00
|
|
|
|
it("should process quadpoints in the standard order", function () {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
rect = [10, 10, 20, 20];
|
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
|
|
|
|
dict.set("QuadPoints", [
|
2020-12-06 05:27:38 +09:00
|
|
|
|
10,
|
|
|
|
|
20,
|
|
|
|
|
20,
|
|
|
|
|
20,
|
|
|
|
|
10,
|
|
|
|
|
10,
|
|
|
|
|
20,
|
|
|
|
|
10,
|
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
|
|
|
|
11,
|
2020-12-06 05:27:38 +09:00
|
|
|
|
19,
|
|
|
|
|
19,
|
|
|
|
|
19,
|
|
|
|
|
11,
|
|
|
|
|
11,
|
|
|
|
|
19,
|
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
|
|
|
|
11,
|
2019-07-28 03:57:52 +09:00
|
|
|
|
]);
|
|
|
|
|
expect(getQuadPoints(dict, rect)).toEqual([
|
|
|
|
|
[
|
2020-12-06 05:27:38 +09:00
|
|
|
|
{ x: 10, y: 20 },
|
|
|
|
|
{ x: 20, y: 20 },
|
|
|
|
|
{ x: 10, y: 10 },
|
|
|
|
|
{ x: 20, y: 10 },
|
2019-07-28 03:57:52 +09:00
|
|
|
|
],
|
|
|
|
|
[
|
2020-12-06 05:27:38 +09:00
|
|
|
|
{ x: 11, y: 19 },
|
|
|
|
|
{ x: 19, y: 19 },
|
|
|
|
|
{ x: 11, y: 11 },
|
|
|
|
|
{ x: 19, y: 11 },
|
2019-07-28 03:57:52 +09:00
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
});
|
2020-12-06 05:27:38 +09:00
|
|
|
|
|
|
|
|
|
it("should normalize and process quadpoints in non-standard orders", function () {
|
|
|
|
|
rect = [10, 10, 20, 20];
|
|
|
|
|
const nonStandardOrders = [
|
|
|
|
|
// Bottom left, bottom right, top right and top left.
|
|
|
|
|
[10, 20, 20, 20, 20, 10, 10, 10],
|
|
|
|
|
|
|
|
|
|
// Top left, top right, bottom left and bottom right.
|
|
|
|
|
[10, 10, 20, 10, 10, 20, 20, 20],
|
|
|
|
|
|
|
|
|
|
// Top left, top right, bottom right and bottom left.
|
|
|
|
|
[10, 10, 20, 10, 20, 20, 10, 20],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
for (const nonStandardOrder of nonStandardOrders) {
|
|
|
|
|
dict.set("QuadPoints", nonStandardOrder);
|
|
|
|
|
expect(getQuadPoints(dict, rect)).toEqual([
|
|
|
|
|
[
|
|
|
|
|
{ x: 10, y: 20 },
|
|
|
|
|
{ x: 20, y: 20 },
|
|
|
|
|
{ x: 10, y: 10 },
|
|
|
|
|
{ x: 20, y: 10 },
|
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
});
|
2019-07-28 03:57:52 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("Annotation", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
let dict, ref;
|
2016-07-24 21:32:48 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
beforeAll(function (done) {
|
2016-07-24 21:32:48 +09:00
|
|
|
|
dict = new Dict();
|
2019-05-26 00:40:14 +09:00
|
|
|
|
ref = Ref.get(1, 0);
|
2016-07-24 21:32:48 +09:00
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
afterAll(function () {
|
2016-07-24 21:32:48 +09:00
|
|
|
|
dict = ref = null;
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get valid contents", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
|
|
|
|
annotation.setContents("Foo bar baz");
|
2019-05-18 22:52:17 +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
|
|
|
|
expect(annotation.contents).toEqual("Foo bar baz");
|
2019-05-18 22:52:17 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set and get invalid contents", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
2019-05-18 22:52:17 +09:00
|
|
|
|
annotation.setContents(undefined);
|
|
|
|
|
|
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
|
|
|
|
expect(annotation.contents).toEqual("");
|
2019-05-18 22:52:17 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get a valid modification date", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
|
|
|
|
annotation.setModificationDate("D:20190422");
|
2019-04-22 04:21:01 +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
|
|
|
|
expect(annotation.modificationDate).toEqual("D:20190422");
|
2019-04-22 04:21:01 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set and get an invalid modification date", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
2019-04-22 04:21:01 +09:00
|
|
|
|
annotation.setModificationDate(undefined);
|
|
|
|
|
|
|
|
|
|
expect(annotation.modificationDate).toEqual(null);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get flags", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
2015-11-22 07:25:17 +09:00
|
|
|
|
annotation.setFlags(13);
|
|
|
|
|
|
|
|
|
|
expect(annotation.hasFlag(AnnotationFlag.INVISIBLE)).toEqual(true);
|
|
|
|
|
expect(annotation.hasFlag(AnnotationFlag.NOZOOM)).toEqual(true);
|
|
|
|
|
expect(annotation.hasFlag(AnnotationFlag.PRINT)).toEqual(true);
|
|
|
|
|
expect(annotation.hasFlag(AnnotationFlag.READONLY)).toEqual(false);
|
2020-10-01 03:58:45 +09:00
|
|
|
|
expect(annotation.hasFlag(AnnotationFlag.HIDDEN)).toEqual(false);
|
2015-11-22 07:25:17 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should be viewable and not printable by default", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
2015-11-22 07:25:17 +09:00
|
|
|
|
|
|
|
|
|
expect(annotation.viewable).toEqual(true);
|
|
|
|
|
expect(annotation.printable).toEqual(false);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get a valid rectangle", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
2015-07-21 05:01:47 +09:00
|
|
|
|
annotation.setRectangle([117, 694, 164.298, 720]);
|
|
|
|
|
|
|
|
|
|
expect(annotation.rectangle).toEqual([117, 694, 164.298, 720]);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set and get an invalid rectangle", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
2015-07-21 05:01:47 +09:00
|
|
|
|
annotation.setRectangle([117, 694, 164.298]);
|
|
|
|
|
|
|
|
|
|
expect(annotation.rectangle).toEqual([0, 0, 0, 0]);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should reject a color if it is not an array", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
|
|
|
|
annotation.setColor("red");
|
2015-07-15 23:59:25 +09:00
|
|
|
|
|
2018-06-12 00:25:40 +09:00
|
|
|
|
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
|
2015-07-15 23:59:25 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get a transparent color", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
2015-07-15 23:59:25 +09:00
|
|
|
|
annotation.setColor([]);
|
|
|
|
|
|
|
|
|
|
expect(annotation.color).toEqual(null);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get a grayscale color", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
2015-07-15 23:59:25 +09:00
|
|
|
|
annotation.setColor([0.4]);
|
|
|
|
|
|
2018-06-12 00:25:40 +09:00
|
|
|
|
expect(annotation.color).toEqual(new Uint8ClampedArray([102, 102, 102]));
|
2015-07-15 23:59:25 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get an RGB color", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
2015-07-15 23:59:25 +09:00
|
|
|
|
annotation.setColor([0, 0, 1]);
|
|
|
|
|
|
2018-06-12 00:25:40 +09:00
|
|
|
|
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
2015-07-15 23:59:25 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get a CMYK color", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
2015-07-15 23:59:25 +09:00
|
|
|
|
annotation.setColor([0.1, 0.92, 0.84, 0.02]);
|
|
|
|
|
|
2018-06-12 00:25:40 +09:00
|
|
|
|
expect(annotation.color).toEqual(new Uint8ClampedArray([234, 59, 48]));
|
2015-07-15 23:59:25 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set and get an invalid color", 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
|
|
|
|
const annotation = new Annotation({ dict, ref });
|
2015-07-15 23:59:25 +09:00
|
|
|
|
annotation.setColor([0.4, 0.6]);
|
|
|
|
|
|
2018-06-12 00:25:40 +09:00
|
|
|
|
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
|
2015-07-15 23:59:25 +09:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("AnnotationBorderStyle", function () {
|
|
|
|
|
it("should set and get a valid width", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const borderStyle = new AnnotationBorderStyle();
|
2014-12-26 05:04:01 +09:00
|
|
|
|
borderStyle.setWidth(3);
|
|
|
|
|
|
|
|
|
|
expect(borderStyle.width).toEqual(3);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set and get an invalid width", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const borderStyle = new AnnotationBorderStyle();
|
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
|
|
|
|
borderStyle.setWidth("three");
|
2014-12-26 05:04:01 +09:00
|
|
|
|
|
|
|
|
|
expect(borderStyle.width).toEqual(1);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set the width to zero, when the input is a `Name` (issue 10385)", function () {
|
2019-01-04 18:33:15 +09:00
|
|
|
|
const borderStyleZero = new AnnotationBorderStyle();
|
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
|
|
|
|
borderStyleZero.setWidth(Name.get("0"));
|
2019-01-04 18:33:15 +09:00
|
|
|
|
const borderStyleFive = new AnnotationBorderStyle();
|
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
|
|
|
|
borderStyleFive.setWidth(Name.get("5"));
|
2018-12-31 20:21:28 +09:00
|
|
|
|
|
2019-01-04 18:33:15 +09:00
|
|
|
|
expect(borderStyleZero.width).toEqual(0);
|
|
|
|
|
expect(borderStyleFive.width).toEqual(0);
|
2018-12-31 20:21:28 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get a valid style", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const borderStyle = new AnnotationBorderStyle();
|
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
|
|
|
|
borderStyle.setStyle(Name.get("D"));
|
2014-12-26 05:04:01 +09:00
|
|
|
|
|
|
|
|
|
expect(borderStyle.style).toEqual(AnnotationBorderStyleType.DASHED);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set and get an invalid style", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const borderStyle = new AnnotationBorderStyle();
|
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
|
|
|
|
borderStyle.setStyle("Dashed");
|
2014-12-26 05:04:01 +09:00
|
|
|
|
|
|
|
|
|
expect(borderStyle.style).toEqual(AnnotationBorderStyleType.SOLID);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get a valid dash array", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const borderStyle = new AnnotationBorderStyle();
|
2014-12-26 05:04:01 +09:00
|
|
|
|
borderStyle.setDashArray([1, 2, 3]);
|
|
|
|
|
|
|
|
|
|
expect(borderStyle.dashArray).toEqual([1, 2, 3]);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set and get an invalid dash array", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const borderStyle = new AnnotationBorderStyle();
|
2014-12-26 05:04:01 +09:00
|
|
|
|
borderStyle.setDashArray([0, 0]);
|
|
|
|
|
|
|
|
|
|
expect(borderStyle.dashArray).toEqual([3]);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get a valid horizontal corner radius", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const borderStyle = new AnnotationBorderStyle();
|
2014-12-26 05:04:01 +09:00
|
|
|
|
borderStyle.setHorizontalCornerRadius(3);
|
|
|
|
|
|
|
|
|
|
expect(borderStyle.horizontalCornerRadius).toEqual(3);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set and get an invalid horizontal corner radius", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const borderStyle = new AnnotationBorderStyle();
|
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
|
|
|
|
borderStyle.setHorizontalCornerRadius("three");
|
2014-12-26 05:04:01 +09:00
|
|
|
|
|
|
|
|
|
expect(borderStyle.horizontalCornerRadius).toEqual(0);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get a valid vertical corner radius", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const borderStyle = new AnnotationBorderStyle();
|
2014-12-26 05:04:01 +09:00
|
|
|
|
borderStyle.setVerticalCornerRadius(3);
|
|
|
|
|
|
|
|
|
|
expect(borderStyle.verticalCornerRadius).toEqual(3);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set and get an invalid vertical corner radius", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const borderStyle = new AnnotationBorderStyle();
|
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
|
|
|
|
borderStyle.setVerticalCornerRadius("three");
|
2014-12-26 05:04:01 +09:00
|
|
|
|
|
|
|
|
|
expect(borderStyle.verticalCornerRadius).toEqual(0);
|
|
|
|
|
});
|
|
|
|
|
});
|
2016-02-15 05:27:53 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("MarkupAnnotation", function () {
|
2019-05-25 22:25:52 +09:00
|
|
|
|
let dict, ref;
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
beforeAll(function (done) {
|
2019-05-25 22:25:52 +09:00
|
|
|
|
dict = new Dict();
|
2019-05-26 00:40:14 +09:00
|
|
|
|
ref = Ref.get(1, 0);
|
2019-05-25 22:25:52 +09:00
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
afterAll(function () {
|
2019-05-25 22:25:52 +09:00
|
|
|
|
dict = ref = null;
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set and get a valid creation date", 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
|
|
|
|
const markupAnnotation = new MarkupAnnotation({ dict, ref });
|
|
|
|
|
markupAnnotation.setCreationDate("D:20190422");
|
2019-05-25 22:25:52 +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
|
|
|
|
expect(markupAnnotation.creationDate).toEqual("D:20190422");
|
2019-05-25 22:25:52 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set and get an invalid creation date", 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
|
|
|
|
const markupAnnotation = new MarkupAnnotation({ dict, ref });
|
2019-05-25 22:25:52 +09:00
|
|
|
|
markupAnnotation.setCreationDate(undefined);
|
|
|
|
|
|
|
|
|
|
expect(markupAnnotation.creationDate).toEqual(null);
|
|
|
|
|
});
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not parse IRT/RT when not defined", function (done) {
|
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
|
|
|
|
dict.set("Type", Name.get("Annot"));
|
|
|
|
|
dict.set("Subtype", Name.get("Text"));
|
2019-05-15 04:14:35 +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
|
|
|
|
const xref = new XRefMock([{ ref, data: dict }]);
|
2019-05-15 04:14:35 +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
|
|
|
|
AnnotationFactory.create(xref, ref, pdfManagerMock, idFactoryMock).then(
|
|
|
|
|
({ data }) => {
|
|
|
|
|
expect(data.inReplyTo).toBeUndefined();
|
|
|
|
|
expect(data.replyType).toBeUndefined();
|
|
|
|
|
done();
|
|
|
|
|
},
|
|
|
|
|
done.fail
|
|
|
|
|
);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should parse IRT and set default RT when not defined.", function (done) {
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const annotationRef = Ref.get(819, 0);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Text"));
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const replyRef = Ref.get(820, 0);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
const replyDict = new Dict();
|
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
|
|
|
|
replyDict.set("Type", Name.get("Annot"));
|
|
|
|
|
replyDict.set("Subtype", Name.get("Text"));
|
|
|
|
|
replyDict.set("IRT", annotationRef);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
|
|
|
|
{ ref: replyRef, data: replyDict },
|
2019-05-15 04:14:35 +09:00
|
|
|
|
]);
|
|
|
|
|
annotationDict.assignXref(xref);
|
|
|
|
|
replyDict.assignXref(xref);
|
|
|
|
|
|
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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
replyRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-05-15 04:14:35 +09:00
|
|
|
|
expect(data.inReplyTo).toEqual(annotationRef.toString());
|
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
|
|
|
|
expect(data.replyType).toEqual("R");
|
2019-05-15 04:14:35 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should parse IRT/RT for a group type", function (done) {
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const annotationRef = Ref.get(819, 0);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Text"));
|
|
|
|
|
annotationDict.set("T", "ParentTitle");
|
|
|
|
|
annotationDict.set("Contents", "ParentText");
|
|
|
|
|
annotationDict.set("CreationDate", "D:20180423");
|
|
|
|
|
annotationDict.set("M", "D:20190423");
|
|
|
|
|
annotationDict.set("C", [0, 0, 1]);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const popupRef = Ref.get(820, 0);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
const popupDict = new Dict();
|
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
|
|
|
|
popupDict.set("Type", Name.get("Annot"));
|
|
|
|
|
popupDict.set("Subtype", Name.get("Popup"));
|
|
|
|
|
popupDict.set("Parent", annotationRef);
|
|
|
|
|
annotationDict.set("Popup", popupRef);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const replyRef = Ref.get(821, 0);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
const replyDict = new Dict();
|
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
|
|
|
|
replyDict.set("Type", Name.get("Annot"));
|
|
|
|
|
replyDict.set("Subtype", Name.get("Text"));
|
|
|
|
|
replyDict.set("IRT", annotationRef);
|
|
|
|
|
replyDict.set("RT", Name.get("Group"));
|
|
|
|
|
replyDict.set("T", "ReplyTitle");
|
|
|
|
|
replyDict.set("Contents", "ReplyText");
|
|
|
|
|
replyDict.set("CreationDate", "D:20180523");
|
|
|
|
|
replyDict.set("M", "D:20190523");
|
|
|
|
|
replyDict.set("C", [0.4]);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
|
|
|
|
{ ref: popupRef, data: popupDict },
|
|
|
|
|
{ ref: replyRef, data: replyDict },
|
2019-05-15 04:14:35 +09:00
|
|
|
|
]);
|
|
|
|
|
annotationDict.assignXref(xref);
|
|
|
|
|
popupDict.assignXref(xref);
|
|
|
|
|
replyDict.assignXref(xref);
|
|
|
|
|
|
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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
replyRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-05-15 04:14:35 +09:00
|
|
|
|
expect(data.inReplyTo).toEqual(annotationRef.toString());
|
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
|
|
|
|
expect(data.replyType).toEqual("Group");
|
|
|
|
|
expect(data.title).toEqual("ParentTitle");
|
|
|
|
|
expect(data.contents).toEqual("ParentText");
|
|
|
|
|
expect(data.creationDate).toEqual("D:20180423");
|
|
|
|
|
expect(data.modificationDate).toEqual("D:20190423");
|
2019-05-15 04:14:35 +09:00
|
|
|
|
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
|
|
|
|
expect(data.hasPopup).toEqual(true);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should parse IRT/RT for a reply type", function (done) {
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const annotationRef = Ref.get(819, 0);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Text"));
|
|
|
|
|
annotationDict.set("T", "ParentTitle");
|
|
|
|
|
annotationDict.set("Contents", "ParentText");
|
|
|
|
|
annotationDict.set("CreationDate", "D:20180423");
|
|
|
|
|
annotationDict.set("M", "D:20190423");
|
|
|
|
|
annotationDict.set("C", [0, 0, 1]);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const popupRef = Ref.get(820, 0);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
const popupDict = new Dict();
|
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
|
|
|
|
popupDict.set("Type", Name.get("Annot"));
|
|
|
|
|
popupDict.set("Subtype", Name.get("Popup"));
|
|
|
|
|
popupDict.set("Parent", annotationRef);
|
|
|
|
|
annotationDict.set("Popup", popupRef);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const replyRef = Ref.get(821, 0);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
const replyDict = new Dict();
|
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
|
|
|
|
replyDict.set("Type", Name.get("Annot"));
|
|
|
|
|
replyDict.set("Subtype", Name.get("Text"));
|
|
|
|
|
replyDict.set("IRT", annotationRef);
|
|
|
|
|
replyDict.set("RT", Name.get("R"));
|
|
|
|
|
replyDict.set("T", "ReplyTitle");
|
|
|
|
|
replyDict.set("Contents", "ReplyText");
|
|
|
|
|
replyDict.set("CreationDate", "D:20180523");
|
|
|
|
|
replyDict.set("M", "D:20190523");
|
|
|
|
|
replyDict.set("C", [0.4]);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
|
|
|
|
{ ref: popupRef, data: popupDict },
|
|
|
|
|
{ ref: replyRef, data: replyDict },
|
2019-05-15 04:14:35 +09:00
|
|
|
|
]);
|
|
|
|
|
annotationDict.assignXref(xref);
|
|
|
|
|
popupDict.assignXref(xref);
|
|
|
|
|
replyDict.assignXref(xref);
|
|
|
|
|
|
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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
replyRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-05-15 04:14:35 +09:00
|
|
|
|
expect(data.inReplyTo).toEqual(annotationRef.toString());
|
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
|
|
|
|
expect(data.replyType).toEqual("R");
|
|
|
|
|
expect(data.title).toEqual("ReplyTitle");
|
|
|
|
|
expect(data.contents).toEqual("ReplyText");
|
|
|
|
|
expect(data.creationDate).toEqual("D:20180523");
|
|
|
|
|
expect(data.modificationDate).toEqual("D:20190523");
|
2019-05-15 04:14:35 +09:00
|
|
|
|
expect(data.color).toEqual(new Uint8ClampedArray([102, 102, 102]));
|
|
|
|
|
expect(data.hasPopup).toEqual(false);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("TextAnnotation", function () {
|
|
|
|
|
it("should not parse state model and state when not defined", function (done) {
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const annotationRef = Ref.get(819, 0);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Text"));
|
|
|
|
|
annotationDict.set("Contents", "TestText");
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const replyRef = Ref.get(820, 0);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
const replyDict = new Dict();
|
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
|
|
|
|
replyDict.set("Type", Name.get("Annot"));
|
|
|
|
|
replyDict.set("Subtype", Name.get("Text"));
|
|
|
|
|
replyDict.set("IRT", annotationRef);
|
|
|
|
|
replyDict.set("RT", Name.get("R"));
|
|
|
|
|
replyDict.set("Contents", "ReplyText");
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
|
|
|
|
{ ref: replyRef, data: replyDict },
|
2019-05-15 04:14:35 +09:00
|
|
|
|
]);
|
|
|
|
|
annotationDict.assignXref(xref);
|
|
|
|
|
replyDict.assignXref(xref);
|
|
|
|
|
|
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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
replyRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-05-15 04:14:35 +09:00
|
|
|
|
expect(data.stateModel).toBeNull();
|
|
|
|
|
expect(data.state).toBeNull();
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should correctly parse state model and state when defined", function (done) {
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const annotationRef = Ref.get(819, 0);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Text"));
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const replyRef = Ref.get(820, 0);
|
2019-05-15 04:14:35 +09:00
|
|
|
|
const replyDict = new Dict();
|
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
|
|
|
|
replyDict.set("Type", Name.get("Annot"));
|
|
|
|
|
replyDict.set("Subtype", Name.get("Text"));
|
|
|
|
|
replyDict.set("IRT", annotationRef);
|
|
|
|
|
replyDict.set("RT", Name.get("R"));
|
|
|
|
|
replyDict.set("StateModel", "Review");
|
|
|
|
|
replyDict.set("State", "Rejected");
|
2019-05-15 04:14:35 +09:00
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
|
|
|
|
{ ref: replyRef, data: replyDict },
|
2019-05-15 04:14:35 +09:00
|
|
|
|
]);
|
|
|
|
|
annotationDict.assignXref(xref);
|
|
|
|
|
replyDict.assignXref(xref);
|
|
|
|
|
|
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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
replyRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.stateModel).toEqual("Review");
|
|
|
|
|
expect(data.state).toEqual("Rejected");
|
2019-05-15 04:14:35 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2019-05-25 22:25:52 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("LinkAnnotation", function () {
|
|
|
|
|
it("should correctly parse a URI action", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const actionDict = new Dict();
|
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
|
|
|
|
actionDict.set("Type", Name.get("Action"));
|
|
|
|
|
actionDict.set("S", Name.get("URI"));
|
|
|
|
|
actionDict.set("URI", "http://www.ctan.org/tex-archive/info/lshort");
|
2016-03-26 18:00:25 +09:00
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("A", actionDict);
|
2016-03-26 18:00:25 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const annotationRef = Ref.get(820, 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
|
|
|
|
const xref = new XRefMock([{ ref: annotationRef, data: annotationDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
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
|
|
|
|
expect(data.url).toEqual("http://www.ctan.org/tex-archive/info/lshort");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.unsafeUrl).toEqual(
|
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
|
|
|
|
"http://www.ctan.org/tex-archive/info/lshort"
|
|
|
|
|
);
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.dest).toBeUndefined();
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-03-26 18:00:25 +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
|
|
|
|
it(
|
|
|
|
|
"should correctly parse a URI action, where the URI entry " +
|
|
|
|
|
"is missing a protocol",
|
2020-04-14 19:28:14 +09:00
|
|
|
|
function (done) {
|
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 actionDict = new Dict();
|
|
|
|
|
actionDict.set("Type", Name.get("Action"));
|
|
|
|
|
actionDict.set("S", Name.get("URI"));
|
|
|
|
|
actionDict.set("URI", "www.hmrc.gov.uk");
|
2016-03-26 18:00:25 +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
|
|
|
|
const annotationDict = new Dict();
|
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("A", actionDict);
|
2016-03-26 18:00:25 +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
|
|
|
|
const annotationRef = Ref.get(353, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
|
|
|
|
]);
|
2016-03-26 18:00:25 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.url).toEqual("http://www.hmrc.gov.uk/");
|
|
|
|
|
expect(data.unsafeUrl).toEqual("http://www.hmrc.gov.uk");
|
|
|
|
|
expect(data.dest).toBeUndefined();
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
it(
|
|
|
|
|
"should correctly parse a URI action, where the URI entry " +
|
|
|
|
|
"has an incorrect encoding (bug 1122280)",
|
2020-04-14 19:28:14 +09:00
|
|
|
|
function (done) {
|
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 actionStream = new StringStream(
|
|
|
|
|
"<<\n" +
|
|
|
|
|
"/Type /Action\n" +
|
|
|
|
|
"/S /URI\n" +
|
|
|
|
|
"/URI (http://www.example.com/\\303\\274\\303\\266\\303\\244)\n" +
|
|
|
|
|
">>\n"
|
|
|
|
|
);
|
|
|
|
|
const parser = new Parser({
|
|
|
|
|
lexer: new Lexer(actionStream),
|
|
|
|
|
xref: null,
|
|
|
|
|
});
|
|
|
|
|
const actionDict = parser.getObj();
|
2016-09-30 18:44:24 +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
|
|
|
|
const annotationDict = new Dict();
|
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("A", actionDict);
|
2016-09-30 18:44:24 +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
|
|
|
|
const annotationRef = Ref.get(8, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
|
|
|
|
]);
|
2016-09-30 18:44:24 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.url).toEqual(
|
|
|
|
|
new URL(
|
|
|
|
|
stringToUTF8String(
|
|
|
|
|
"http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4"
|
|
|
|
|
)
|
|
|
|
|
).href
|
|
|
|
|
);
|
|
|
|
|
expect(data.unsafeUrl).toEqual(
|
|
|
|
|
stringToUTF8String(
|
|
|
|
|
"http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4"
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
expect(data.dest).toBeUndefined();
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
}
|
|
|
|
|
);
|
2016-09-30 18:44:24 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should correctly parse a GoTo action", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const actionDict = new Dict();
|
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
|
|
|
|
actionDict.set("Type", Name.get("Action"));
|
|
|
|
|
actionDict.set("S", Name.get("GoTo"));
|
|
|
|
|
actionDict.set("D", "page.157");
|
2016-03-26 18:00:25 +09:00
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("A", actionDict);
|
2016-03-26 18:00:25 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const annotationRef = Ref.get(798, 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
|
|
|
|
const xref = new XRefMock([{ ref: annotationRef, data: annotationDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.url).toBeUndefined();
|
|
|
|
|
expect(data.unsafeUrl).toBeUndefined();
|
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
|
|
|
|
expect(data.dest).toEqual("page.157");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-03-26 18:00:25 +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
|
|
|
|
it(
|
|
|
|
|
"should correctly parse a GoToR action, where the FileSpec entry " +
|
|
|
|
|
"is a string containing a relative URL",
|
2020-04-14 19:28:14 +09:00
|
|
|
|
function (done) {
|
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 actionDict = new Dict();
|
|
|
|
|
actionDict.set("Type", Name.get("Action"));
|
|
|
|
|
actionDict.set("S", Name.get("GoToR"));
|
|
|
|
|
actionDict.set("F", "../../0013/001346/134685E.pdf");
|
|
|
|
|
actionDict.set("D", "4.3");
|
|
|
|
|
actionDict.set("NewWindow", true);
|
[api-minor] Let `LinkAnnotation`/`PDFLinkService_getDestinationHash` return a stringified version of the destination array for explicit destinations
Currently for explicit destinations, compared to named destinations, we manually try to build a hash that often times is a quite poor representation of the *actual* destination. (Currently this only, kind of, works for `\XYZ` destinations.)
For PDF files using explicit destinations, this can make it difficult/impossible to obtain a link to a specific section of the document through the URL.
Note that in practice most PDF files, especially newer ones, use named destinations and these are thus unnaffected by this patch.
This patch also fixes an existing issue in `PDFLinkService_getDestinationHash`, where a named destination consisting of only a number would not be handled correctly.
With the added, and already existing, type checks in place for destinations, I really don't think that this patch exposes any "sensitive" internal destination code not already accessible through normal hash parameters.
*Please note:* Just trying to improve the algorithm that generates the hash is unfortunately not possible in general, since there are a number of cases where it will simply never work well.
- First of all, note that `getDestinationHash` currently relies on the `_pagesRefCache`, hence it's possible that the hash returned is empty during e.g. ranged/streamed loading of a PDF file.
- Second of all, the currently computed hash is actually dependent on the document rotation. With named destinations, the fetched internal destination array is rotational invariant (as it should be), but this will not hold in general for the hash. We can easily avoid this issue by using a stringified destination array.
- Third of all, note that according to the PDF specification[1], `GoToR` destinations may actually contain explicit destination arrays. Since we cannot really construct a hash in `annotation.js`, we currently have no good way to support those. Even though this case seems *very* rare in practice (I've not actually seen such a PDF file), it's in the specification, and this patch allows us to support that for "free".
---
[1] http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.1951685
2016-05-15 19:12:47 +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
|
|
|
|
const annotationDict = new Dict();
|
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("A", actionDict);
|
[api-minor] Let `LinkAnnotation`/`PDFLinkService_getDestinationHash` return a stringified version of the destination array for explicit destinations
Currently for explicit destinations, compared to named destinations, we manually try to build a hash that often times is a quite poor representation of the *actual* destination. (Currently this only, kind of, works for `\XYZ` destinations.)
For PDF files using explicit destinations, this can make it difficult/impossible to obtain a link to a specific section of the document through the URL.
Note that in practice most PDF files, especially newer ones, use named destinations and these are thus unnaffected by this patch.
This patch also fixes an existing issue in `PDFLinkService_getDestinationHash`, where a named destination consisting of only a number would not be handled correctly.
With the added, and already existing, type checks in place for destinations, I really don't think that this patch exposes any "sensitive" internal destination code not already accessible through normal hash parameters.
*Please note:* Just trying to improve the algorithm that generates the hash is unfortunately not possible in general, since there are a number of cases where it will simply never work well.
- First of all, note that `getDestinationHash` currently relies on the `_pagesRefCache`, hence it's possible that the hash returned is empty during e.g. ranged/streamed loading of a PDF file.
- Second of all, the currently computed hash is actually dependent on the document rotation. With named destinations, the fetched internal destination array is rotational invariant (as it should be), but this will not hold in general for the hash. We can easily avoid this issue by using a stringified destination array.
- Third of all, note that according to the PDF specification[1], `GoToR` destinations may actually contain explicit destination arrays. Since we cannot really construct a hash in `annotation.js`, we currently have no good way to support those. Even though this case seems *very* rare in practice (I've not actually seen such a PDF file), it's in the specification, and this patch allows us to support that for "free".
---
[1] http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.1951685
2016-05-15 19:12:47 +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
|
|
|
|
const annotationRef = Ref.get(489, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
|
|
|
|
]);
|
[api-minor] Let `LinkAnnotation`/`PDFLinkService_getDestinationHash` return a stringified version of the destination array for explicit destinations
Currently for explicit destinations, compared to named destinations, we manually try to build a hash that often times is a quite poor representation of the *actual* destination. (Currently this only, kind of, works for `\XYZ` destinations.)
For PDF files using explicit destinations, this can make it difficult/impossible to obtain a link to a specific section of the document through the URL.
Note that in practice most PDF files, especially newer ones, use named destinations and these are thus unnaffected by this patch.
This patch also fixes an existing issue in `PDFLinkService_getDestinationHash`, where a named destination consisting of only a number would not be handled correctly.
With the added, and already existing, type checks in place for destinations, I really don't think that this patch exposes any "sensitive" internal destination code not already accessible through normal hash parameters.
*Please note:* Just trying to improve the algorithm that generates the hash is unfortunately not possible in general, since there are a number of cases where it will simply never work well.
- First of all, note that `getDestinationHash` currently relies on the `_pagesRefCache`, hence it's possible that the hash returned is empty during e.g. ranged/streamed loading of a PDF file.
- Second of all, the currently computed hash is actually dependent on the document rotation. With named destinations, the fetched internal destination array is rotational invariant (as it should be), but this will not hold in general for the hash. We can easily avoid this issue by using a stringified destination array.
- Third of all, note that according to the PDF specification[1], `GoToR` destinations may actually contain explicit destination arrays. Since we cannot really construct a hash in `annotation.js`, we currently have no good way to support those. Even though this case seems *very* rare in practice (I've not actually seen such a PDF file), it's in the specification, and this patch allows us to support that for "free".
---
[1] http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.1951685
2016-05-15 19:12:47 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.url).toBeUndefined();
|
|
|
|
|
expect(data.unsafeUrl).toEqual("../../0013/001346/134685E.pdf#4.3");
|
|
|
|
|
expect(data.dest).toBeUndefined();
|
|
|
|
|
expect(data.newWindow).toEqual(true);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
}
|
|
|
|
|
);
|
[api-minor] Let `LinkAnnotation`/`PDFLinkService_getDestinationHash` return a stringified version of the destination array for explicit destinations
Currently for explicit destinations, compared to named destinations, we manually try to build a hash that often times is a quite poor representation of the *actual* destination. (Currently this only, kind of, works for `\XYZ` destinations.)
For PDF files using explicit destinations, this can make it difficult/impossible to obtain a link to a specific section of the document through the URL.
Note that in practice most PDF files, especially newer ones, use named destinations and these are thus unnaffected by this patch.
This patch also fixes an existing issue in `PDFLinkService_getDestinationHash`, where a named destination consisting of only a number would not be handled correctly.
With the added, and already existing, type checks in place for destinations, I really don't think that this patch exposes any "sensitive" internal destination code not already accessible through normal hash parameters.
*Please note:* Just trying to improve the algorithm that generates the hash is unfortunately not possible in general, since there are a number of cases where it will simply never work well.
- First of all, note that `getDestinationHash` currently relies on the `_pagesRefCache`, hence it's possible that the hash returned is empty during e.g. ranged/streamed loading of a PDF file.
- Second of all, the currently computed hash is actually dependent on the document rotation. With named destinations, the fetched internal destination array is rotational invariant (as it should be), but this will not hold in general for the hash. We can easily avoid this issue by using a stringified destination array.
- Third of all, note that according to the PDF specification[1], `GoToR` destinations may actually contain explicit destination arrays. Since we cannot really construct a hash in `annotation.js`, we currently have no good way to support those. Even though this case seems *very* rare in practice (I've not actually seen such a PDF file), it's in the specification, and this patch allows us to support that for "free".
---
[1] http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.1951685
2016-05-15 19:12:47 +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
|
|
|
|
it(
|
|
|
|
|
"should correctly parse a GoToR action, containing a relative URL, " +
|
|
|
|
|
'with the "docBaseUrl" parameter specified',
|
2020-04-14 19:28:14 +09:00
|
|
|
|
function (done) {
|
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 actionDict = new Dict();
|
|
|
|
|
actionDict.set("Type", Name.get("Action"));
|
|
|
|
|
actionDict.set("S", Name.get("GoToR"));
|
|
|
|
|
actionDict.set("F", "../../0013/001346/134685E.pdf");
|
|
|
|
|
actionDict.set("D", "4.3");
|
2016-10-01 19:05:07 +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
|
|
|
|
const annotationDict = new Dict();
|
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("A", actionDict);
|
2016-10-01 19:05:07 +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
|
|
|
|
const annotationRef = Ref.get(489, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
|
|
|
|
]);
|
|
|
|
|
const pdfManager = new PDFManagerMock({
|
|
|
|
|
docBaseUrl: "http://www.example.com/test/pdfs/qwerty.pdf",
|
|
|
|
|
});
|
2016-10-01 19:05:07 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManager,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.url).toEqual(
|
|
|
|
|
"http://www.example.com/0013/001346/134685E.pdf#4.3"
|
|
|
|
|
);
|
|
|
|
|
expect(data.unsafeUrl).toEqual("../../0013/001346/134685E.pdf#4.3");
|
|
|
|
|
expect(data.dest).toBeUndefined();
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
}
|
|
|
|
|
);
|
2016-10-01 19:05:07 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should correctly parse a GoToR action, with named destination", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const actionDict = new Dict();
|
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
|
|
|
|
actionDict.set("Type", Name.get("Action"));
|
|
|
|
|
actionDict.set("S", Name.get("GoToR"));
|
|
|
|
|
actionDict.set("F", "http://www.example.com/test.pdf");
|
|
|
|
|
actionDict.set("D", "15");
|
2016-03-26 18:00:25 +09:00
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("A", actionDict);
|
2016-03-26 18:00:25 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const annotationRef = Ref.get(495, 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
|
|
|
|
const xref = new XRefMock([{ ref: annotationRef, data: annotationDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
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
|
|
|
|
expect(data.url).toEqual("http://www.example.com/test.pdf#15");
|
|
|
|
|
expect(data.unsafeUrl).toEqual("http://www.example.com/test.pdf#15");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.dest).toBeUndefined();
|
|
|
|
|
expect(data.newWindow).toBeFalsy();
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
[api-minor] Let `LinkAnnotation`/`PDFLinkService_getDestinationHash` return a stringified version of the destination array for explicit destinations
Currently for explicit destinations, compared to named destinations, we manually try to build a hash that often times is a quite poor representation of the *actual* destination. (Currently this only, kind of, works for `\XYZ` destinations.)
For PDF files using explicit destinations, this can make it difficult/impossible to obtain a link to a specific section of the document through the URL.
Note that in practice most PDF files, especially newer ones, use named destinations and these are thus unnaffected by this patch.
This patch also fixes an existing issue in `PDFLinkService_getDestinationHash`, where a named destination consisting of only a number would not be handled correctly.
With the added, and already existing, type checks in place for destinations, I really don't think that this patch exposes any "sensitive" internal destination code not already accessible through normal hash parameters.
*Please note:* Just trying to improve the algorithm that generates the hash is unfortunately not possible in general, since there are a number of cases where it will simply never work well.
- First of all, note that `getDestinationHash` currently relies on the `_pagesRefCache`, hence it's possible that the hash returned is empty during e.g. ranged/streamed loading of a PDF file.
- Second of all, the currently computed hash is actually dependent on the document rotation. With named destinations, the fetched internal destination array is rotational invariant (as it should be), but this will not hold in general for the hash. We can easily avoid this issue by using a stringified destination array.
- Third of all, note that according to the PDF specification[1], `GoToR` destinations may actually contain explicit destination arrays. Since we cannot really construct a hash in `annotation.js`, we currently have no good way to support those. Even though this case seems *very* rare in practice (I've not actually seen such a PDF file), it's in the specification, and this patch allows us to support that for "free".
---
[1] http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.1951685
2016-05-15 19:12:47 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should correctly parse a GoToR action, with explicit destination array", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const actionDict = new Dict();
|
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
|
|
|
|
actionDict.set("Type", Name.get("Action"));
|
|
|
|
|
actionDict.set("S", Name.get("GoToR"));
|
|
|
|
|
actionDict.set("F", "http://www.example.com/test.pdf");
|
|
|
|
|
actionDict.set("D", [14, Name.get("XYZ"), null, 298.043, null]);
|
[api-minor] Let `LinkAnnotation`/`PDFLinkService_getDestinationHash` return a stringified version of the destination array for explicit destinations
Currently for explicit destinations, compared to named destinations, we manually try to build a hash that often times is a quite poor representation of the *actual* destination. (Currently this only, kind of, works for `\XYZ` destinations.)
For PDF files using explicit destinations, this can make it difficult/impossible to obtain a link to a specific section of the document through the URL.
Note that in practice most PDF files, especially newer ones, use named destinations and these are thus unnaffected by this patch.
This patch also fixes an existing issue in `PDFLinkService_getDestinationHash`, where a named destination consisting of only a number would not be handled correctly.
With the added, and already existing, type checks in place for destinations, I really don't think that this patch exposes any "sensitive" internal destination code not already accessible through normal hash parameters.
*Please note:* Just trying to improve the algorithm that generates the hash is unfortunately not possible in general, since there are a number of cases where it will simply never work well.
- First of all, note that `getDestinationHash` currently relies on the `_pagesRefCache`, hence it's possible that the hash returned is empty during e.g. ranged/streamed loading of a PDF file.
- Second of all, the currently computed hash is actually dependent on the document rotation. With named destinations, the fetched internal destination array is rotational invariant (as it should be), but this will not hold in general for the hash. We can easily avoid this issue by using a stringified destination array.
- Third of all, note that according to the PDF specification[1], `GoToR` destinations may actually contain explicit destination arrays. Since we cannot really construct a hash in `annotation.js`, we currently have no good way to support those. Even though this case seems *very* rare in practice (I've not actually seen such a PDF file), it's in the specification, and this patch allows us to support that for "free".
---
[1] http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.1951685
2016-05-15 19:12:47 +09:00
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("A", actionDict);
|
[api-minor] Let `LinkAnnotation`/`PDFLinkService_getDestinationHash` return a stringified version of the destination array for explicit destinations
Currently for explicit destinations, compared to named destinations, we manually try to build a hash that often times is a quite poor representation of the *actual* destination. (Currently this only, kind of, works for `\XYZ` destinations.)
For PDF files using explicit destinations, this can make it difficult/impossible to obtain a link to a specific section of the document through the URL.
Note that in practice most PDF files, especially newer ones, use named destinations and these are thus unnaffected by this patch.
This patch also fixes an existing issue in `PDFLinkService_getDestinationHash`, where a named destination consisting of only a number would not be handled correctly.
With the added, and already existing, type checks in place for destinations, I really don't think that this patch exposes any "sensitive" internal destination code not already accessible through normal hash parameters.
*Please note:* Just trying to improve the algorithm that generates the hash is unfortunately not possible in general, since there are a number of cases where it will simply never work well.
- First of all, note that `getDestinationHash` currently relies on the `_pagesRefCache`, hence it's possible that the hash returned is empty during e.g. ranged/streamed loading of a PDF file.
- Second of all, the currently computed hash is actually dependent on the document rotation. With named destinations, the fetched internal destination array is rotational invariant (as it should be), but this will not hold in general for the hash. We can easily avoid this issue by using a stringified destination array.
- Third of all, note that according to the PDF specification[1], `GoToR` destinations may actually contain explicit destination arrays. Since we cannot really construct a hash in `annotation.js`, we currently have no good way to support those. Even though this case seems *very* rare in practice (I've not actually seen such a PDF file), it's in the specification, and this patch allows us to support that for "free".
---
[1] http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.1951685
2016-05-15 19:12:47 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const annotationRef = Ref.get(489, 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
|
|
|
|
const xref = new XRefMock([{ ref: annotationRef, data: annotationDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.url).toEqual(
|
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
|
|
|
|
new URL(
|
|
|
|
|
"http://www.example.com/test.pdf#" +
|
|
|
|
|
'[14,{"name":"XYZ"},null,298.043,null]'
|
|
|
|
|
).href
|
|
|
|
|
);
|
|
|
|
|
expect(data.unsafeUrl).toEqual(
|
|
|
|
|
"http://www.example.com/test.pdf#" +
|
|
|
|
|
'[14,{"name":"XYZ"},null,298.043,null]'
|
|
|
|
|
);
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.dest).toBeUndefined();
|
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
|
|
|
|
expect(data.newWindow).toBeFalsy();
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-10-21 20:29:15 +09:00
|
|
|
|
});
|
2016-03-26 18:00:25 +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
|
|
|
|
it(
|
|
|
|
|
"should correctly parse a Launch action, where the FileSpec dict " +
|
|
|
|
|
'contains a relative URL, with the "docBaseUrl" parameter specified',
|
2020-04-14 19:28:14 +09:00
|
|
|
|
function (done) {
|
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 fileSpecDict = new Dict();
|
|
|
|
|
fileSpecDict.set("Type", Name.get("FileSpec"));
|
|
|
|
|
fileSpecDict.set("F", "Part II/Part II.pdf");
|
|
|
|
|
fileSpecDict.set("UF", "Part II/Part II.pdf");
|
2016-11-09 00:38:22 +09:00
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const actionDict = new Dict();
|
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
|
|
|
|
actionDict.set("Type", Name.get("Action"));
|
|
|
|
|
actionDict.set("S", Name.get("Launch"));
|
|
|
|
|
actionDict.set("F", fileSpecDict);
|
|
|
|
|
actionDict.set("NewWindow", true);
|
2016-11-09 00:38:22 +09:00
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("A", actionDict);
|
2016-11-09 00:38: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
|
|
|
|
const annotationRef = Ref.get(88, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
2016-11-09 00:38: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
|
|
|
|
const pdfManager = new PDFManagerMock({
|
|
|
|
|
docBaseUrl: "http://www.example.com/test/pdfs/qwerty.pdf",
|
|
|
|
|
});
|
2016-11-09 00:38: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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManager,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
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
|
|
|
|
expect(data.url).toEqual(
|
|
|
|
|
new URL("http://www.example.com/test/pdfs/Part II/Part II.pdf").href
|
|
|
|
|
);
|
|
|
|
|
expect(data.unsafeUrl).toEqual("Part II/Part II.pdf");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.dest).toBeUndefined();
|
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
|
|
|
|
expect(data.newWindow).toEqual(true);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-11-09 00:38: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
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
it(
|
|
|
|
|
"should recover valid URLs from JavaScript actions having certain " +
|
|
|
|
|
"white-listed formats",
|
2020-04-14 19:28:14 +09:00
|
|
|
|
function (done) {
|
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 checkJsAction(params) {
|
|
|
|
|
const jsEntry = params.jsEntry;
|
|
|
|
|
const expectedUrl = params.expectedUrl;
|
|
|
|
|
const expectedUnsafeUrl = params.expectedUnsafeUrl;
|
|
|
|
|
const expectedNewWindow = params.expectedNewWindow;
|
|
|
|
|
|
|
|
|
|
const actionDict = new Dict();
|
|
|
|
|
actionDict.set("Type", Name.get("Action"));
|
|
|
|
|
actionDict.set("S", Name.get("JavaScript"));
|
|
|
|
|
actionDict.set("JS", jsEntry);
|
|
|
|
|
|
|
|
|
|
const annotationDict = new Dict();
|
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("A", actionDict);
|
|
|
|
|
|
|
|
|
|
const annotationRef = Ref.get(46, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
|
|
|
|
]);
|
2016-11-09 00:38: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
|
|
|
|
return AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.url).toEqual(expectedUrl);
|
|
|
|
|
expect(data.unsafeUrl).toEqual(expectedUnsafeUrl);
|
|
|
|
|
expect(data.dest).toBeUndefined();
|
|
|
|
|
expect(data.newWindow).toEqual(expectedNewWindow);
|
|
|
|
|
});
|
|
|
|
|
}
|
2018-03-21 09:43:40 +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
|
|
|
|
// Check that we reject a 'JS' entry containing arbitrary JavaScript.
|
|
|
|
|
const annotation1 = checkJsAction({
|
|
|
|
|
jsEntry: 'function someFun() { return "qwerty"; } someFun();',
|
|
|
|
|
expectedUrl: undefined,
|
|
|
|
|
expectedUnsafeUrl: undefined,
|
|
|
|
|
expectedNewWindow: undefined,
|
|
|
|
|
});
|
2018-03-21 09:43:40 +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
|
|
|
|
// Check that we accept a white-listed {string} 'JS' entry.
|
|
|
|
|
const annotation2 = checkJsAction({
|
|
|
|
|
jsEntry: "window.open('http://www.example.com/test.pdf')",
|
|
|
|
|
expectedUrl: new URL("http://www.example.com/test.pdf").href,
|
|
|
|
|
expectedUnsafeUrl: "http://www.example.com/test.pdf",
|
|
|
|
|
expectedNewWindow: undefined,
|
|
|
|
|
});
|
2018-03-21 09:43:40 +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
|
|
|
|
// Check that we accept a white-listed {Stream} 'JS' entry.
|
|
|
|
|
const annotation3 = checkJsAction({
|
|
|
|
|
jsEntry: new StringStream(
|
|
|
|
|
'app.launchURL("http://www.example.com/test.pdf", true)'
|
|
|
|
|
),
|
|
|
|
|
expectedUrl: new URL("http://www.example.com/test.pdf").href,
|
|
|
|
|
expectedUnsafeUrl: "http://www.example.com/test.pdf",
|
|
|
|
|
expectedNewWindow: true,
|
|
|
|
|
});
|
2016-11-09 00:38: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
|
|
|
|
Promise.all([annotation1, annotation2, annotation3]).then(
|
|
|
|
|
done,
|
|
|
|
|
done.fail
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should correctly parse a Named action", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const actionDict = new Dict();
|
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
|
|
|
|
actionDict.set("Type", Name.get("Action"));
|
|
|
|
|
actionDict.set("S", Name.get("Named"));
|
|
|
|
|
actionDict.set("N", Name.get("GoToPage"));
|
2016-03-26 18:00:25 +09:00
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("A", actionDict);
|
2016-03-26 18:00:25 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const annotationRef = Ref.get(12, 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
|
|
|
|
const xref = new XRefMock([{ ref: annotationRef, data: annotationDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.url).toBeUndefined();
|
|
|
|
|
expect(data.unsafeUrl).toBeUndefined();
|
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
|
|
|
|
expect(data.action).toEqual("GoToPage");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-03-26 18:00:25 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should correctly parse a simple Dest", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("Dest", Name.get("LI0"));
|
2016-03-26 18:00:25 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const annotationRef = Ref.get(583, 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
|
|
|
|
const xref = new XRefMock([{ ref: annotationRef, data: annotationDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.url).toBeUndefined();
|
|
|
|
|
expect(data.unsafeUrl).toBeUndefined();
|
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
|
|
|
|
expect(data.dest).toEqual("LI0");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-03-26 18:00:25 +09:00
|
|
|
|
});
|
2016-09-30 23:32:22 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should correctly parse a simple Dest, with explicit destination array", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("Dest", [
|
|
|
|
|
Ref.get(17, 0),
|
|
|
|
|
Name.get("XYZ"),
|
|
|
|
|
0,
|
|
|
|
|
841.89,
|
|
|
|
|
null,
|
2016-09-30 23:32: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
|
|
|
|
const annotationRef = Ref.get(10, 0);
|
|
|
|
|
const xref = new XRefMock([{ ref: annotationRef, data: annotationDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.url).toBeUndefined();
|
|
|
|
|
expect(data.unsafeUrl).toBeUndefined();
|
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
|
|
|
|
expect(data.dest).toEqual([
|
|
|
|
|
{ num: 17, gen: 0 },
|
|
|
|
|
{ name: "XYZ" },
|
|
|
|
|
0,
|
|
|
|
|
841.89,
|
|
|
|
|
null,
|
|
|
|
|
]);
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-09-30 23:32:22 +09:00
|
|
|
|
});
|
2017-08-25 20:40:50 +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
|
|
|
|
it(
|
|
|
|
|
"should correctly parse a Dest, which violates the specification " +
|
|
|
|
|
"by containing a dictionary",
|
2020-04-14 19:28:14 +09:00
|
|
|
|
function (done) {
|
2020-01-24 17:48:21 +09:00
|
|
|
|
const destDict = new Dict();
|
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
|
|
|
|
destDict.set("Type", Name.get("Action"));
|
|
|
|
|
destDict.set("S", Name.get("GoTo"));
|
|
|
|
|
destDict.set("D", "page.157");
|
|
|
|
|
|
2020-01-24 17:48:21 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
// The /Dest must be a Name or an Array, refer to ISO 32000-1:2008
|
|
|
|
|
// section 12.3.3, but there are PDF files where it's a dictionary.
|
|
|
|
|
annotationDict.set("Dest", destDict);
|
|
|
|
|
|
2020-01-24 17:48:21 +09:00
|
|
|
|
const annotationRef = Ref.get(798, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
|
|
|
|
]);
|
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
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.url).toBeUndefined();
|
|
|
|
|
expect(data.unsafeUrl).toBeUndefined();
|
|
|
|
|
expect(data.dest).toEqual("page.157");
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
}
|
|
|
|
|
);
|
2019-07-28 03:57:52 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set quadpoints if not defined", function (done) {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
2019-07-28 03:57:52 +09:00
|
|
|
|
|
|
|
|
|
const annotationRef = Ref.get(121, 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
|
|
|
|
const xref = new XRefMock([{ ref: annotationRef, data: annotationDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.quadPoints).toBeUndefined();
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set quadpoints if defined", function (done) {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
const annotationDict = new Dict();
|
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
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Link"));
|
|
|
|
|
annotationDict.set("Rect", [10, 10, 20, 20]);
|
2020-12-06 05:27:38 +09:00
|
|
|
|
annotationDict.set("QuadPoints", [10, 20, 20, 20, 10, 10, 20, 10]);
|
2019-07-28 03:57:52 +09:00
|
|
|
|
|
|
|
|
|
const annotationRef = Ref.get(121, 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
|
|
|
|
const xref = new XRefMock([{ ref: annotationRef, data: annotationDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
annotationRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
|
|
|
|
expect(data.quadPoints).toEqual([
|
|
|
|
|
[
|
2020-12-06 05:27:38 +09:00
|
|
|
|
{ x: 10, y: 20 },
|
|
|
|
|
{ x: 20, y: 20 },
|
|
|
|
|
{ x: 10, y: 10 },
|
|
|
|
|
{ x: 20, y: 10 },
|
2019-07-28 03:57:52 +09:00
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2016-03-26 18:00:25 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("WidgetAnnotation", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
let widgetDict;
|
2016-11-02 08:07:31 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
beforeEach(function (done) {
|
2016-11-02 08:07:31 +09:00
|
|
|
|
widgetDict = new Dict();
|
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
|
|
|
|
widgetDict.set("Type", Name.get("Annot"));
|
|
|
|
|
widgetDict.set("Subtype", Name.get("Widget"));
|
2016-11-02 08:07:31 +09:00
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
afterEach(function () {
|
2016-11-02 08:07:31 +09:00
|
|
|
|
widgetDict = null;
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle unknown field names", function (done) {
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const widgetRef = Ref.get(20, 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
|
|
|
|
const xref = new XRefMock([{ ref: widgetRef, data: widgetDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
widgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
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
|
|
|
|
expect(data.fieldName).toEqual("");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-11-02 08:07:31 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should construct the field name when there are no ancestors", function (done) {
|
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
|
|
|
|
widgetDict.set("T", "foo");
|
2016-11-02 08:07:31 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const widgetRef = Ref.get(21, 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
|
|
|
|
const xref = new XRefMock([{ ref: widgetRef, data: widgetDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
widgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
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
|
|
|
|
expect(data.fieldName).toEqual("foo");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-11-02 08:07:31 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should construct the field name when there are ancestors", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const firstParent = new Dict();
|
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
|
|
|
|
firstParent.set("T", "foo");
|
2016-11-02 08:07:31 +09:00
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const secondParent = new Dict();
|
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
|
|
|
|
secondParent.set("Parent", firstParent);
|
|
|
|
|
secondParent.set("T", "bar");
|
2016-11-02 08:07:31 +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
|
|
|
|
widgetDict.set("Parent", secondParent);
|
|
|
|
|
widgetDict.set("T", "baz");
|
2016-11-02 08:07:31 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const widgetRef = Ref.get(22, 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
|
|
|
|
const xref = new XRefMock([{ ref: widgetRef, data: widgetDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
widgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
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
|
|
|
|
expect(data.fieldName).toEqual("foo.bar.baz");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-11-02 08:07:31 +09:00
|
|
|
|
});
|
2017-03-10 07:51:52 +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
|
|
|
|
it(
|
|
|
|
|
"should construct the field name if a parent is not a dictionary " +
|
|
|
|
|
"(issue 8143)",
|
2020-04-14 19:28:14 +09:00
|
|
|
|
function (done) {
|
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 parentDict = new Dict();
|
|
|
|
|
parentDict.set("Parent", null);
|
|
|
|
|
parentDict.set("T", "foo");
|
|
|
|
|
|
|
|
|
|
widgetDict.set("Parent", parentDict);
|
|
|
|
|
widgetDict.set("T", "bar");
|
|
|
|
|
|
|
|
|
|
const widgetRef = Ref.get(22, 0);
|
|
|
|
|
const xref = new XRefMock([{ ref: widgetRef, data: widgetDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
widgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.fieldName).toEqual("foo.bar");
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
}
|
|
|
|
|
);
|
2016-11-02 08:07:31 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("TextWidgetAnnotation", function () {
|
2020-08-05 21:40:31 +09:00
|
|
|
|
let textWidgetDict, fontRefObj;
|
2016-09-13 21:57:11 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
beforeEach(function (done) {
|
2016-09-13 21:57:11 +09:00
|
|
|
|
textWidgetDict = new Dict();
|
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
|
|
|
|
textWidgetDict.set("Type", Name.get("Annot"));
|
|
|
|
|
textWidgetDict.set("Subtype", Name.get("Widget"));
|
|
|
|
|
textWidgetDict.set("FT", Name.get("Tx"));
|
2020-08-05 21:40:31 +09:00
|
|
|
|
|
|
|
|
|
const helvDict = new Dict();
|
|
|
|
|
helvDict.set("BaseFont", Name.get("Helvetica"));
|
|
|
|
|
helvDict.set("Type", Name.get("Font"));
|
|
|
|
|
helvDict.set("Subtype", Name.get("Type1"));
|
|
|
|
|
|
|
|
|
|
const fontRef = Ref.get(314, 0);
|
|
|
|
|
fontRefObj = { ref: fontRef, data: helvDict };
|
|
|
|
|
const resourceDict = new Dict();
|
|
|
|
|
const fontDict = new Dict();
|
|
|
|
|
fontDict.set("Helv", fontRef);
|
|
|
|
|
resourceDict.set("Font", fontDict);
|
|
|
|
|
|
|
|
|
|
textWidgetDict.set("DA", "/Helv 5 Tf");
|
|
|
|
|
textWidgetDict.set("DR", resourceDict);
|
|
|
|
|
textWidgetDict.set("Rect", [0, 0, 32, 10]);
|
|
|
|
|
|
2016-09-13 21:57:11 +09:00
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
afterEach(function () {
|
2020-08-05 21:40:31 +09:00
|
|
|
|
textWidgetDict = fontRefObj = null;
|
2016-09-13 21:57:11 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle unknown text alignment, maximum length and flags", function (done) {
|
2020-11-04 00:53:21 +09:00
|
|
|
|
textWidgetDict.set("DV", "foo");
|
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const textWidgetRef = Ref.get(124, 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
|
|
|
|
const xref = new XRefMock([{ ref: textWidgetRef, data: textWidgetDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.textAlignment).toEqual(null);
|
|
|
|
|
expect(data.maxLen).toEqual(null);
|
|
|
|
|
expect(data.readOnly).toEqual(false);
|
2020-10-01 03:58:45 +09:00
|
|
|
|
expect(data.hidden).toEqual(false);
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.multiLine).toEqual(false);
|
|
|
|
|
expect(data.comb).toEqual(false);
|
2020-11-04 00:53:21 +09:00
|
|
|
|
expect(data.defaultFieldValue).toEqual("foo");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-09-13 21:57:11 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set invalid text alignment, maximum length and flags", function (done) {
|
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
|
|
|
|
textWidgetDict.set("Q", "center");
|
|
|
|
|
textWidgetDict.set("MaxLen", "five");
|
|
|
|
|
textWidgetDict.set("Ff", "readonly");
|
2016-09-13 21:57:11 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const textWidgetRef = Ref.get(43, 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
|
|
|
|
const xref = new XRefMock([{ ref: textWidgetRef, data: textWidgetDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.textAlignment).toEqual(null);
|
|
|
|
|
expect(data.maxLen).toEqual(null);
|
|
|
|
|
expect(data.readOnly).toEqual(false);
|
2020-10-01 03:58:45 +09:00
|
|
|
|
expect(data.hidden).toEqual(false);
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.multiLine).toEqual(false);
|
|
|
|
|
expect(data.comb).toEqual(false);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-09-13 21:57:11 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set valid text alignment, maximum length and flags", function (done) {
|
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
|
|
|
|
textWidgetDict.set("Q", 1);
|
|
|
|
|
textWidgetDict.set("MaxLen", 20);
|
|
|
|
|
textWidgetDict.set(
|
|
|
|
|
"Ff",
|
|
|
|
|
AnnotationFieldFlag.READONLY + AnnotationFieldFlag.MULTILINE
|
|
|
|
|
);
|
2016-09-13 21:57:11 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const textWidgetRef = Ref.get(84, 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
|
|
|
|
const xref = new XRefMock([{ ref: textWidgetRef, data: textWidgetDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.textAlignment).toEqual(1);
|
|
|
|
|
expect(data.maxLen).toEqual(20);
|
|
|
|
|
expect(data.readOnly).toEqual(true);
|
2020-10-01 03:58:45 +09:00
|
|
|
|
expect(data.hidden).toEqual(false);
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.multiLine).toEqual(true);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-09-13 21:57:11 +09:00
|
|
|
|
});
|
2016-09-20 07:04:11 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should reject comb fields without a maximum length", function (done) {
|
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
|
|
|
|
textWidgetDict.set("Ff", AnnotationFieldFlag.COMB);
|
2016-09-20 07:04:11 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const textWidgetRef = Ref.get(46, 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
|
|
|
|
const xref = new XRefMock([{ ref: textWidgetRef, data: textWidgetDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.comb).toEqual(false);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-09-20 07:04:11 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should accept comb fields with a maximum length", function (done) {
|
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
|
|
|
|
textWidgetDict.set("MaxLen", 20);
|
|
|
|
|
textWidgetDict.set("Ff", AnnotationFieldFlag.COMB);
|
2016-09-20 07:04:11 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const textWidgetRef = Ref.get(46, 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
|
|
|
|
const xref = new XRefMock([{ ref: textWidgetRef, data: textWidgetDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.comb).toEqual(true);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-09-20 07:04:11 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should only accept comb fields when the flags are valid", function (done) {
|
2020-01-24 17:48:21 +09:00
|
|
|
|
const invalidFieldFlags = [
|
2018-03-21 09:43:40 +09:00
|
|
|
|
AnnotationFieldFlag.MULTILINE,
|
|
|
|
|
AnnotationFieldFlag.PASSWORD,
|
|
|
|
|
AnnotationFieldFlag.FILESELECT,
|
2016-09-20 07:04:11 +09:00
|
|
|
|
];
|
|
|
|
|
|
2016-09-22 04:06:44 +09:00
|
|
|
|
// Start with all invalid flags set and remove them one by one.
|
|
|
|
|
// The field may only use combs when all invalid flags are unset.
|
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 flags =
|
|
|
|
|
AnnotationFieldFlag.COMB +
|
|
|
|
|
AnnotationFieldFlag.MULTILINE +
|
|
|
|
|
AnnotationFieldFlag.PASSWORD +
|
|
|
|
|
AnnotationFieldFlag.FILESELECT;
|
2016-09-20 07:04:11 +09:00
|
|
|
|
|
2018-03-21 09:43:40 +09:00
|
|
|
|
let promise = Promise.resolve();
|
|
|
|
|
for (let i = 0, ii = invalidFieldFlags.length; i <= ii; i++) {
|
|
|
|
|
promise = promise.then(() => {
|
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
|
|
|
|
textWidgetDict.set("MaxLen", 20);
|
|
|
|
|
textWidgetDict.set("Ff", flags);
|
2018-03-21 09:43:40 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const textWidgetRef = Ref.get(93, 0);
|
2018-03-21 09:43:40 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: textWidgetRef, data: textWidgetDict },
|
2018-03-21 09:43:40 +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
|
|
|
|
return AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
|
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 valid = invalidFieldFlags.length === 0;
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.comb).toEqual(valid);
|
|
|
|
|
|
|
|
|
|
// Remove the last invalid flag for the next iteration.
|
|
|
|
|
if (!valid) {
|
2018-10-24 20:08:08 +09:00
|
|
|
|
flags -= invalidFieldFlags.pop();
|
2018-03-21 09:43:40 +09:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2016-09-20 07:04:11 +09:00
|
|
|
|
}
|
2018-03-21 09:43:40 +09:00
|
|
|
|
promise.then(done, done.fail);
|
2016-09-20 07:04:11 +09:00
|
|
|
|
});
|
2020-08-05 21:40:31 +09:00
|
|
|
|
|
|
|
|
|
it("should render regular text for printing", function (done) {
|
|
|
|
|
const textWidgetRef = Ref.get(271, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: textWidgetRef, data: textWidgetDict },
|
|
|
|
|
fontRefObj,
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const id = annotation.data.id;
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[id] = { value: "test\\print" };
|
2020-08-05 21:40:31 +09:00
|
|
|
|
return annotation._getAppearance(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(appearance => {
|
|
|
|
|
expect(appearance).toEqual(
|
|
|
|
|
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm" +
|
|
|
|
|
" 2.00 2.00 Td (test\\\\print) Tj ET Q EMC"
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-09-20 00:47:38 +09:00
|
|
|
|
it("should render regular text for printing using normal appearance", function (done) {
|
|
|
|
|
const textWidgetRef = Ref.get(271, 0);
|
|
|
|
|
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
const normalAppearanceDict = new Dict();
|
|
|
|
|
|
|
|
|
|
const normalAppearanceStream = new StringStream("0.1 0.2 0.3 rg");
|
|
|
|
|
normalAppearanceStream.dict = normalAppearanceDict;
|
|
|
|
|
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceStream);
|
|
|
|
|
textWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: textWidgetRef, data: textWidgetDict },
|
|
|
|
|
fontRefObj,
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
|
|
|
|
return annotation.getOperatorList(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
false,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.then(opList => {
|
|
|
|
|
expect(opList.argsArray.length).toEqual(3);
|
|
|
|
|
expect(opList.fnArray).toEqual([
|
|
|
|
|
OPS.beginAnnotation,
|
|
|
|
|
OPS.setFillRGBColor,
|
|
|
|
|
OPS.endAnnotation,
|
|
|
|
|
]);
|
|
|
|
|
expect(opList.argsArray[1]).toEqual(
|
|
|
|
|
new Uint8ClampedArray([26, 51, 76])
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
.catch(done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-08-05 21:40:31 +09:00
|
|
|
|
it("should render auto-sized text for printing", function (done) {
|
|
|
|
|
textWidgetDict.set("DA", "/Helv 0 Tf");
|
|
|
|
|
|
|
|
|
|
const textWidgetRef = Ref.get(271, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: textWidgetRef, data: textWidgetDict },
|
|
|
|
|
fontRefObj,
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const id = annotation.data.id;
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[id] = { value: "test (print)" };
|
2020-08-05 21:40:31 +09:00
|
|
|
|
return annotation._getAppearance(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(appearance => {
|
|
|
|
|
expect(appearance).toEqual(
|
|
|
|
|
"/Tx BMC q BT /Helv 11 Tf 1 0 0 1 0 0 Tm" +
|
|
|
|
|
" 2.00 2.00 Td (test \\(print\\)) Tj ET Q EMC"
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should not render a password for printing", function (done) {
|
|
|
|
|
textWidgetDict.set("Ff", AnnotationFieldFlag.PASSWORD);
|
|
|
|
|
|
|
|
|
|
const textWidgetRef = Ref.get(271, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: textWidgetRef, data: textWidgetDict },
|
|
|
|
|
fontRefObj,
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const id = annotation.data.id;
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[id] = { value: "mypassword" };
|
2020-08-05 21:40:31 +09:00
|
|
|
|
return annotation._getAppearance(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(appearance => {
|
|
|
|
|
expect(appearance).toEqual(null);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2020-08-06 23:07:13 +09:00
|
|
|
|
|
|
|
|
|
it("should render multiline text for printing", function (done) {
|
|
|
|
|
textWidgetDict.set("Ff", AnnotationFieldFlag.MULTILINE);
|
|
|
|
|
|
|
|
|
|
const textWidgetRef = Ref.get(271, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: textWidgetRef, data: textWidgetDict },
|
|
|
|
|
fontRefObj,
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const id = annotation.data.id;
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[id] = {
|
|
|
|
|
value:
|
|
|
|
|
"a aa aaa aaaa aaaaa aaaaaa " +
|
|
|
|
|
"pneumonoultramicroscopicsilicovolcanoconiosis",
|
|
|
|
|
};
|
2020-08-06 23:07:13 +09:00
|
|
|
|
return annotation._getAppearance(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(appearance => {
|
|
|
|
|
expect(appearance).toEqual(
|
|
|
|
|
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 10 Tm " +
|
|
|
|
|
"2.00 -5.00 Td (a aa aaa ) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td (aaaa aaaaa ) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td (aaaaaa ) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td (pneumonoultr) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td (amicroscopi) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td (csilicovolca) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td (noconiosis) Tj ET Q EMC"
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should render multiline text with various EOL for printing", function (done) {
|
|
|
|
|
textWidgetDict.set("Ff", AnnotationFieldFlag.MULTILINE);
|
|
|
|
|
textWidgetDict.set("Rect", [0, 0, 128, 10]);
|
|
|
|
|
|
|
|
|
|
const textWidgetRef = Ref.get(271, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: textWidgetRef, data: textWidgetDict },
|
|
|
|
|
fontRefObj,
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
const expectedAppearance =
|
|
|
|
|
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 10 Tm " +
|
|
|
|
|
"2.00 -5.00 Td " +
|
|
|
|
|
"(Lorem ipsum dolor sit amet, consectetur adipiscing elit.) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td " +
|
|
|
|
|
"(Aliquam vitae felis ac lectus bibendum ultricies quis non) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td " +
|
|
|
|
|
"( diam.) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td " +
|
|
|
|
|
"(Morbi id porttitor quam, a iaculis dui.) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td " +
|
|
|
|
|
"(Pellentesque habitant morbi tristique senectus et netus ) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td " +
|
|
|
|
|
"(et malesuada fames ac turpis egestas.) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td () Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td () Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td " +
|
|
|
|
|
"(Nulla consectetur, ligula in tincidunt placerat, velit ) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td " +
|
|
|
|
|
"(augue consectetur orci, sed mattis libero nunc ut massa.) Tj\n" +
|
|
|
|
|
"0.00 -5.00 Td " +
|
|
|
|
|
"(Etiam facilisis tempus interdum.) Tj ET Q EMC";
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const id = annotation.data.id;
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[id] = {
|
|
|
|
|
value:
|
|
|
|
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r" +
|
|
|
|
|
"Aliquam vitae felis ac lectus bibendum ultricies quis non diam.\n" +
|
|
|
|
|
"Morbi id porttitor quam, a iaculis dui.\r\n" +
|
|
|
|
|
"Pellentesque habitant morbi tristique senectus et " +
|
|
|
|
|
"netus et malesuada fames ac turpis egestas.\n\r\n\r" +
|
|
|
|
|
"Nulla consectetur, ligula in tincidunt placerat, " +
|
|
|
|
|
"velit augue consectetur orci, sed mattis libero nunc ut massa.\r" +
|
|
|
|
|
"Etiam facilisis tempus interdum.",
|
|
|
|
|
};
|
2020-08-06 23:07:13 +09:00
|
|
|
|
return annotation._getAppearance(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(appearance => {
|
|
|
|
|
expect(appearance).toEqual(expectedAppearance);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2020-08-06 23:45:17 +09:00
|
|
|
|
|
|
|
|
|
it("should render comb for printing", function (done) {
|
|
|
|
|
textWidgetDict.set("Ff", AnnotationFieldFlag.COMB);
|
|
|
|
|
textWidgetDict.set("MaxLen", 4);
|
|
|
|
|
|
|
|
|
|
const textWidgetRef = Ref.get(271, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: textWidgetRef, data: textWidgetDict },
|
|
|
|
|
fontRefObj,
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const id = annotation.data.id;
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[id] = { value: "aa(aa)a\\" };
|
2020-08-06 23:45:17 +09:00
|
|
|
|
return annotation._getAppearance(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(appearance => {
|
|
|
|
|
expect(appearance).toEqual(
|
|
|
|
|
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 2 2 Tm" +
|
|
|
|
|
" (a) Tj 8.00 0 Td (a) Tj 8.00 0 Td (\\() Tj" +
|
|
|
|
|
" 8.00 0 Td (a) Tj 8.00 0 Td (a) Tj" +
|
|
|
|
|
" 8.00 0 Td (\\)) Tj 8.00 0 Td (a) Tj" +
|
|
|
|
|
" 8.00 0 Td (\\\\) Tj ET Q EMC"
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2020-08-04 02:44:04 +09:00
|
|
|
|
|
|
|
|
|
it("should save text", function (done) {
|
|
|
|
|
const textWidgetRef = Ref.get(123, 0);
|
|
|
|
|
const xref = new XRefMock([{ ref: textWidgetRef, data: textWidgetDict }]);
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
const task = new WorkerTask("test save");
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: "hello world" };
|
2020-08-04 02:44:04 +09:00
|
|
|
|
return annotation.save(partialEvaluator, task, annotationStorage);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(data => {
|
|
|
|
|
expect(data.length).toEqual(2);
|
|
|
|
|
const [oldData, newData] = data;
|
|
|
|
|
expect(oldData.ref).toEqual(Ref.get(123, 0));
|
|
|
|
|
expect(newData.ref).toEqual(Ref.get(1, 0));
|
|
|
|
|
|
|
|
|
|
oldData.data = oldData.data.replace(/\(D:[0-9]+\)/, "(date)");
|
|
|
|
|
expect(oldData.data).toEqual(
|
|
|
|
|
"123 0 obj\n" +
|
|
|
|
|
"<< /Type /Annot /Subtype /Widget /FT /Tx /DA (/Helv 5 Tf) /DR " +
|
|
|
|
|
"<< /Font << /Helv 314 0 R>>>> /Rect [0 0 32 10] " +
|
|
|
|
|
"/V (hello world) /AP << /N 1 0 R>> /M (date)>>\nendobj\n"
|
|
|
|
|
);
|
|
|
|
|
expect(newData.data).toEqual(
|
|
|
|
|
"1 0 obj\n<< /Length 77 /Subtype /Form /Resources " +
|
|
|
|
|
"<< /Font << /Helv 314 0 R>>>> /BBox [0 0 32 10]>> stream\n" +
|
|
|
|
|
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2.00 2.00 Td (hello world) Tj " +
|
|
|
|
|
"ET Q EMC\nendstream\nendobj\n"
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2020-10-01 03:58:45 +09:00
|
|
|
|
|
|
|
|
|
it("should get field object for usage in JS sandbox", function (done) {
|
|
|
|
|
const textWidgetRef = Ref.get(123, 0);
|
|
|
|
|
const xDictRef = Ref.get(141, 0);
|
|
|
|
|
const dDictRef = Ref.get(262, 0);
|
|
|
|
|
const next0Ref = Ref.get(314, 0);
|
|
|
|
|
const next1Ref = Ref.get(271, 0);
|
|
|
|
|
const next2Ref = Ref.get(577, 0);
|
|
|
|
|
const next00Ref = Ref.get(413, 0);
|
|
|
|
|
const xDict = new Dict();
|
|
|
|
|
const dDict = new Dict();
|
|
|
|
|
const next0Dict = new Dict();
|
|
|
|
|
const next1Dict = new Dict();
|
|
|
|
|
const next2Dict = new Dict();
|
|
|
|
|
const next00Dict = new Dict();
|
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: textWidgetRef, data: textWidgetDict },
|
|
|
|
|
{ ref: xDictRef, data: xDict },
|
|
|
|
|
{ ref: dDictRef, data: dDict },
|
|
|
|
|
{ ref: next0Ref, data: next0Dict },
|
|
|
|
|
{ ref: next00Ref, data: next00Dict },
|
|
|
|
|
{ ref: next1Ref, data: next1Dict },
|
|
|
|
|
{ ref: next2Ref, data: next2Dict },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const JS = Name.get("JavaScript");
|
|
|
|
|
const additionalActionsDict = new Dict();
|
|
|
|
|
const eDict = new Dict();
|
|
|
|
|
eDict.set("JS", "hello()");
|
|
|
|
|
eDict.set("S", JS);
|
|
|
|
|
additionalActionsDict.set("E", eDict);
|
|
|
|
|
|
|
|
|
|
// Test the cycle detection here
|
|
|
|
|
xDict.set("JS", "world()");
|
|
|
|
|
xDict.set("S", JS);
|
|
|
|
|
xDict.set("Next", [next0Ref, next1Ref, next2Ref, xDictRef]);
|
|
|
|
|
|
|
|
|
|
next0Dict.set("JS", "olleh()");
|
|
|
|
|
next0Dict.set("S", JS);
|
|
|
|
|
next0Dict.set("Next", next00Ref);
|
|
|
|
|
|
|
|
|
|
next00Dict.set("JS", "foo()");
|
|
|
|
|
next00Dict.set("S", JS);
|
|
|
|
|
next00Dict.set("Next", next0Ref);
|
|
|
|
|
|
|
|
|
|
next1Dict.set("JS", "dlrow()");
|
|
|
|
|
next1Dict.set("S", JS);
|
|
|
|
|
next1Dict.set("Next", xDictRef);
|
|
|
|
|
|
|
|
|
|
next2Dict.set("JS", "oof()");
|
|
|
|
|
next2Dict.set("S", JS);
|
|
|
|
|
|
|
|
|
|
dDict.set("JS", "bar()");
|
|
|
|
|
dDict.set("S", JS);
|
|
|
|
|
dDict.set("Next", dDictRef);
|
|
|
|
|
additionalActionsDict.set("D", dDictRef);
|
|
|
|
|
|
|
|
|
|
additionalActionsDict.set("X", xDictRef);
|
|
|
|
|
textWidgetDict.set("AA", additionalActionsDict);
|
|
|
|
|
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
textWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
return annotation.getFieldObject();
|
|
|
|
|
})
|
|
|
|
|
.then(object => {
|
|
|
|
|
const actions = object.actions;
|
|
|
|
|
expect(actions.MouseEnter).toEqual(["hello()"]);
|
|
|
|
|
expect(actions.MouseExit).toEqual([
|
|
|
|
|
"world()",
|
|
|
|
|
"olleh()",
|
|
|
|
|
"foo()",
|
|
|
|
|
"dlrow()",
|
|
|
|
|
"oof()",
|
|
|
|
|
]);
|
|
|
|
|
expect(actions.MouseDown).toEqual(["bar()"]);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2016-09-13 21:57:11 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("ButtonWidgetAnnotation", function () {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
let buttonWidgetDict;
|
2016-11-04 21:01:42 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
beforeEach(function (done) {
|
2016-12-16 07:49:46 +09:00
|
|
|
|
buttonWidgetDict = new Dict();
|
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
|
|
|
|
buttonWidgetDict.set("Type", Name.get("Annot"));
|
|
|
|
|
buttonWidgetDict.set("Subtype", Name.get("Widget"));
|
|
|
|
|
buttonWidgetDict.set("FT", Name.get("Btn"));
|
2016-11-04 21:01:42 +09:00
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
afterEach(function () {
|
2016-12-16 07:49:46 +09:00
|
|
|
|
buttonWidgetDict = null;
|
2016-11-04 21:01:42 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle checkboxes with export value", function (done) {
|
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
|
|
|
|
buttonWidgetDict.set("V", Name.get("1"));
|
2020-11-04 00:53:21 +09:00
|
|
|
|
buttonWidgetDict.set("DV", Name.get("2"));
|
2018-07-07 09:51:10 +09:00
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const appearanceStatesDict = new Dict();
|
2020-08-22 22:45:33 +09:00
|
|
|
|
const normalAppearanceDict = new Dict();
|
2018-07-07 09:51:10 +09:00
|
|
|
|
|
2020-08-22 22:45:33 +09:00
|
|
|
|
normalAppearanceDict.set("Off", 0);
|
|
|
|
|
normalAppearanceDict.set("Checked", 1);
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceDict);
|
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
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
2018-07-07 09:51:10 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
2018-07-07 09:51:10 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.checkBox).toEqual(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
|
|
|
|
expect(data.fieldValue).toEqual("1");
|
2020-11-04 00:53:21 +09:00
|
|
|
|
expect(data.defaultFieldValue).toEqual("2");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.radioButton).toEqual(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
|
|
|
|
expect(data.exportValue).toEqual("Checked");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2018-07-07 09:51:10 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle checkboxes without export value", function (done) {
|
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
|
|
|
|
buttonWidgetDict.set("V", Name.get("1"));
|
2020-11-04 00:53:21 +09:00
|
|
|
|
buttonWidgetDict.set("DV", Name.get("2"));
|
2016-11-04 21:01:42 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
2016-12-16 07:49:46 +09:00
|
|
|
|
]);
|
2016-11-04 21:01:42 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.checkBox).toEqual(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
|
|
|
|
expect(data.fieldValue).toEqual("1");
|
2020-11-04 00:53:21 +09:00
|
|
|
|
expect(data.defaultFieldValue).toEqual("2");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.radioButton).toEqual(false);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-11-04 21:01:42 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-08-22 22:45:33 +09:00
|
|
|
|
it("should handle checkboxes without /Off appearance", function (done) {
|
|
|
|
|
buttonWidgetDict.set("V", Name.get("1"));
|
2020-11-04 00:53:21 +09:00
|
|
|
|
buttonWidgetDict.set("DV", Name.get("2"));
|
2020-08-22 22:45:33 +09:00
|
|
|
|
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
const normalAppearanceDict = new Dict();
|
|
|
|
|
|
|
|
|
|
normalAppearanceDict.set("Checked", 1);
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceDict);
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.checkBox).toEqual(true);
|
|
|
|
|
expect(data.fieldValue).toEqual("1");
|
2020-11-04 00:53:21 +09:00
|
|
|
|
expect(data.defaultFieldValue).toEqual("2");
|
2020-08-22 22:45:33 +09:00
|
|
|
|
expect(data.radioButton).toEqual(false);
|
|
|
|
|
expect(data.exportValue).toEqual("Checked");
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-10-22 00:21:33 +09:00
|
|
|
|
it("should render checkbox with fallback font for printing", function (done) {
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
const normalAppearanceDict = new Dict();
|
|
|
|
|
const checkedAppearanceDict = new Dict();
|
|
|
|
|
const uncheckedAppearanceDict = new Dict();
|
|
|
|
|
|
|
|
|
|
const checkedStream = new StringStream("/ 12 Tf (4) Tj");
|
|
|
|
|
checkedStream.dict = checkedAppearanceDict;
|
|
|
|
|
|
|
|
|
|
const uncheckedStream = new StringStream("");
|
|
|
|
|
uncheckedStream.dict = uncheckedAppearanceDict;
|
|
|
|
|
|
|
|
|
|
checkedAppearanceDict.set("BBox", [0, 0, 8, 8]);
|
|
|
|
|
checkedAppearanceDict.set("FormType", 1);
|
|
|
|
|
checkedAppearanceDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
|
|
|
|
|
normalAppearanceDict.set("Checked", checkedStream);
|
|
|
|
|
normalAppearanceDict.set("Off", uncheckedStream);
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceDict);
|
|
|
|
|
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
partialEvaluator.options = { ignoreErrors: true };
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: true };
|
2020-10-22 00:21:33 +09:00
|
|
|
|
return annotation.getOperatorList(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
false,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.then(opList => {
|
|
|
|
|
expect(opList.argsArray.length).toEqual(5);
|
|
|
|
|
expect(opList.fnArray).toEqual([
|
|
|
|
|
OPS.beginAnnotation,
|
|
|
|
|
OPS.dependency,
|
|
|
|
|
OPS.setFont,
|
|
|
|
|
OPS.showText,
|
|
|
|
|
OPS.endAnnotation,
|
|
|
|
|
]);
|
|
|
|
|
expect(opList.argsArray[3][0][0].fontChar).toEqual("✔");
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
.catch(done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-07-23 00:10:59 +09:00
|
|
|
|
it("should render checkboxes for printing", function (done) {
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
const normalAppearanceDict = new Dict();
|
|
|
|
|
const checkedAppearanceDict = new Dict();
|
2020-07-31 21:39:11 +09:00
|
|
|
|
const uncheckedAppearanceDict = new Dict();
|
2020-07-23 00:10:59 +09:00
|
|
|
|
|
2020-07-31 21:39:11 +09:00
|
|
|
|
const checkedStream = new StringStream("0.1 0.2 0.3 rg");
|
|
|
|
|
checkedStream.dict = checkedAppearanceDict;
|
|
|
|
|
|
|
|
|
|
const uncheckedStream = new StringStream("0.3 0.2 0.1 rg");
|
|
|
|
|
uncheckedStream.dict = uncheckedAppearanceDict;
|
2020-07-23 00:10:59 +09:00
|
|
|
|
|
|
|
|
|
checkedAppearanceDict.set("BBox", [0, 0, 8, 8]);
|
|
|
|
|
checkedAppearanceDict.set("FormType", 1);
|
|
|
|
|
checkedAppearanceDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
|
2020-07-31 21:39:11 +09:00
|
|
|
|
normalAppearanceDict.set("Checked", checkedStream);
|
|
|
|
|
normalAppearanceDict.set("Off", uncheckedStream);
|
2020-07-23 00:10:59 +09:00
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceDict);
|
|
|
|
|
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: true };
|
2020-07-31 21:39:11 +09:00
|
|
|
|
return Promise.all([
|
|
|
|
|
annotation,
|
|
|
|
|
annotation.getOperatorList(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
false,
|
|
|
|
|
annotationStorage
|
|
|
|
|
),
|
|
|
|
|
]);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(([annotation, opList]) => {
|
|
|
|
|
expect(opList.argsArray.length).toEqual(3);
|
|
|
|
|
expect(opList.fnArray).toEqual([
|
|
|
|
|
OPS.beginAnnotation,
|
|
|
|
|
OPS.setFillRGBColor,
|
|
|
|
|
OPS.endAnnotation,
|
|
|
|
|
]);
|
|
|
|
|
expect(opList.argsArray[1]).toEqual(
|
|
|
|
|
new Uint8ClampedArray([26, 51, 76])
|
|
|
|
|
);
|
|
|
|
|
return annotation;
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: false };
|
2020-07-23 00:10:59 +09:00
|
|
|
|
return annotation.getOperatorList(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
false,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(opList => {
|
|
|
|
|
expect(opList.argsArray.length).toEqual(3);
|
|
|
|
|
expect(opList.fnArray).toEqual([
|
|
|
|
|
OPS.beginAnnotation,
|
|
|
|
|
OPS.setFillRGBColor,
|
|
|
|
|
OPS.endAnnotation,
|
|
|
|
|
]);
|
|
|
|
|
expect(opList.argsArray[1]).toEqual(
|
2020-07-31 21:39:11 +09:00
|
|
|
|
new Uint8ClampedArray([76, 51, 26])
|
2020-07-23 00:10:59 +09:00
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-09-25 02:13:09 +09:00
|
|
|
|
it("should render checkboxes for printing two times", function (done) {
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
const normalAppearanceDict = new Dict();
|
|
|
|
|
const checkedAppearanceDict = new Dict();
|
|
|
|
|
const uncheckedAppearanceDict = new Dict();
|
|
|
|
|
|
|
|
|
|
const checkedStream = new StringStream("0.1 0.2 0.3 rg");
|
|
|
|
|
checkedStream.dict = checkedAppearanceDict;
|
|
|
|
|
|
|
|
|
|
const uncheckedStream = new StringStream("0.3 0.2 0.1 rg");
|
|
|
|
|
uncheckedStream.dict = uncheckedAppearanceDict;
|
|
|
|
|
|
|
|
|
|
checkedAppearanceDict.set("BBox", [0, 0, 8, 8]);
|
|
|
|
|
checkedAppearanceDict.set("FormType", 1);
|
|
|
|
|
checkedAppearanceDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
|
|
|
|
|
normalAppearanceDict.set("Checked", checkedStream);
|
|
|
|
|
normalAppearanceDict.set("Off", uncheckedStream);
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceDict);
|
|
|
|
|
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
buttonWidgetDict.set("AS", Name.get("Off"));
|
|
|
|
|
|
|
|
|
|
const buttonWidgetRef = Ref.get(1249, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: true };
|
2020-09-25 02:13:09 +09:00
|
|
|
|
return Promise.all([
|
|
|
|
|
annotation,
|
|
|
|
|
annotation.getOperatorList(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
false,
|
|
|
|
|
annotationStorage
|
|
|
|
|
),
|
|
|
|
|
]);
|
|
|
|
|
})
|
|
|
|
|
.then(([annotation, opList]) => {
|
|
|
|
|
expect(opList.argsArray.length).toEqual(3);
|
|
|
|
|
expect(opList.fnArray).toEqual([
|
|
|
|
|
OPS.beginAnnotation,
|
|
|
|
|
OPS.setFillRGBColor,
|
|
|
|
|
OPS.endAnnotation,
|
|
|
|
|
]);
|
|
|
|
|
expect(opList.argsArray[1]).toEqual(
|
|
|
|
|
new Uint8ClampedArray([26, 51, 76])
|
|
|
|
|
);
|
|
|
|
|
return annotation;
|
|
|
|
|
})
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: true };
|
2020-09-25 02:13:09 +09:00
|
|
|
|
return annotation.getOperatorList(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
false,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.then(opList => {
|
|
|
|
|
expect(opList.argsArray.length).toEqual(3);
|
|
|
|
|
expect(opList.fnArray).toEqual([
|
|
|
|
|
OPS.beginAnnotation,
|
|
|
|
|
OPS.setFillRGBColor,
|
|
|
|
|
OPS.endAnnotation,
|
|
|
|
|
]);
|
|
|
|
|
expect(opList.argsArray[1]).toEqual(
|
|
|
|
|
new Uint8ClampedArray([26, 51, 76])
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
.catch(done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-09-20 00:47:38 +09:00
|
|
|
|
it("should render checkboxes for printing using normal appearance", function (done) {
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
const normalAppearanceDict = new Dict();
|
|
|
|
|
const checkedAppearanceDict = new Dict();
|
|
|
|
|
const uncheckedAppearanceDict = new Dict();
|
|
|
|
|
|
|
|
|
|
const checkedStream = new StringStream("0.1 0.2 0.3 rg");
|
|
|
|
|
checkedStream.dict = checkedAppearanceDict;
|
|
|
|
|
|
|
|
|
|
const uncheckedStream = new StringStream("0.3 0.2 0.1 rg");
|
|
|
|
|
uncheckedStream.dict = uncheckedAppearanceDict;
|
|
|
|
|
|
|
|
|
|
checkedAppearanceDict.set("BBox", [0, 0, 8, 8]);
|
|
|
|
|
checkedAppearanceDict.set("FormType", 1);
|
|
|
|
|
checkedAppearanceDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
|
|
|
|
|
normalAppearanceDict.set("Checked", checkedStream);
|
|
|
|
|
normalAppearanceDict.set("Off", uncheckedStream);
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceDict);
|
|
|
|
|
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
buttonWidgetDict.set("AS", Name.get("Checked"));
|
|
|
|
|
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
|
|
|
|
return annotation.getOperatorList(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
false,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.then(opList => {
|
|
|
|
|
expect(opList.argsArray.length).toEqual(3);
|
|
|
|
|
expect(opList.fnArray).toEqual([
|
|
|
|
|
OPS.beginAnnotation,
|
|
|
|
|
OPS.setFillRGBColor,
|
|
|
|
|
OPS.endAnnotation,
|
|
|
|
|
]);
|
|
|
|
|
expect(opList.argsArray[1]).toEqual(
|
|
|
|
|
new Uint8ClampedArray([26, 51, 76])
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
.catch(done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-08-04 02:44:04 +09:00
|
|
|
|
it("should save checkboxes", function (done) {
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
const normalAppearanceDict = new Dict();
|
|
|
|
|
|
|
|
|
|
normalAppearanceDict.set("Checked", Ref.get(314, 0));
|
|
|
|
|
normalAppearanceDict.set("Off", Ref.get(271, 0));
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceDict);
|
|
|
|
|
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
buttonWidgetDict.set("V", Name.get("Off"));
|
|
|
|
|
|
|
|
|
|
const buttonWidgetRef = Ref.get(123, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
const task = new WorkerTask("test save");
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: true };
|
2020-08-04 02:44:04 +09:00
|
|
|
|
return Promise.all([
|
|
|
|
|
annotation,
|
|
|
|
|
annotation.save(partialEvaluator, task, annotationStorage),
|
|
|
|
|
]);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(([annotation, [oldData]]) => {
|
|
|
|
|
oldData.data = oldData.data.replace(/\(D:[0-9]+\)/, "(date)");
|
|
|
|
|
expect(oldData.ref).toEqual(Ref.get(123, 0));
|
|
|
|
|
expect(oldData.data).toEqual(
|
|
|
|
|
"123 0 obj\n" +
|
|
|
|
|
"<< /Type /Annot /Subtype /Widget /FT /Btn " +
|
2020-08-22 22:45:33 +09:00
|
|
|
|
"/AP << /N << /Checked 314 0 R /Off 271 0 R>>>> " +
|
2020-08-04 02:44:04 +09:00
|
|
|
|
"/V /Checked /AS /Checked /M (date)>>\nendobj\n"
|
|
|
|
|
);
|
|
|
|
|
return annotation;
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: false };
|
2020-08-04 02:44:04 +09:00
|
|
|
|
return annotation.save(partialEvaluator, task, annotationStorage);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(data => {
|
|
|
|
|
expect(data).toEqual(null);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-07-23 00:29:35 +09:00
|
|
|
|
it("should handle radio buttons with a field value", function (done) {
|
|
|
|
|
const parentDict = new Dict();
|
|
|
|
|
parentDict.set("V", Name.get("1"));
|
|
|
|
|
|
|
|
|
|
const normalAppearanceStateDict = new Dict();
|
|
|
|
|
normalAppearanceStateDict.set("2", null);
|
|
|
|
|
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceStateDict);
|
|
|
|
|
|
|
|
|
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.RADIO);
|
|
|
|
|
buttonWidgetDict.set("Parent", parentDict);
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.checkBox).toEqual(false);
|
|
|
|
|
expect(data.radioButton).toEqual(true);
|
|
|
|
|
expect(data.fieldValue).toEqual("1");
|
|
|
|
|
expect(data.buttonValue).toEqual("2");
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-09-17 01:47:25 +09:00
|
|
|
|
it("should handle radio buttons with a field value not an ascii string", function (done) {
|
|
|
|
|
const parentDict = new Dict();
|
|
|
|
|
parentDict.set("V", Name.get("\x91I=\x91\xf0\x93\xe0\x97e3"));
|
|
|
|
|
|
|
|
|
|
const normalAppearanceStateDict = new Dict();
|
|
|
|
|
normalAppearanceStateDict.set("\x91I=\x91\xf0\x93\xe0\x97e3", null);
|
|
|
|
|
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceStateDict);
|
|
|
|
|
|
|
|
|
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.RADIO);
|
|
|
|
|
buttonWidgetDict.set("Parent", parentDict);
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.checkBox).toEqual(false);
|
|
|
|
|
expect(data.radioButton).toEqual(true);
|
|
|
|
|
expect(data.fieldValue).toEqual("‚I=‚ðfiàŠe3");
|
|
|
|
|
expect(data.buttonValue).toEqual("‚I=‚ðfiàŠe3");
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle radio buttons without a field value", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const normalAppearanceStateDict = new Dict();
|
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
|
|
|
|
normalAppearanceStateDict.set("2", null);
|
2017-02-08 07:44:31 +09:00
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const appearanceStatesDict = new Dict();
|
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
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceStateDict);
|
2017-02-08 07:44:31 +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
|
|
|
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.RADIO);
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
2017-02-08 07:44:31 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
2017-02-08 07:44:31 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.checkBox).toEqual(false);
|
|
|
|
|
expect(data.radioButton).toEqual(true);
|
|
|
|
|
expect(data.fieldValue).toEqual(null);
|
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
|
|
|
|
expect(data.buttonValue).toEqual("2");
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2017-02-08 07:44:31 +09:00
|
|
|
|
});
|
2020-07-23 00:29:35 +09:00
|
|
|
|
|
|
|
|
|
it("should render radio buttons for printing", function (done) {
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
const normalAppearanceDict = new Dict();
|
|
|
|
|
const checkedAppearanceDict = new Dict();
|
|
|
|
|
const uncheckedAppearanceDict = new Dict();
|
|
|
|
|
|
|
|
|
|
const checkedStream = new StringStream("0.1 0.2 0.3 rg");
|
|
|
|
|
checkedStream.dict = checkedAppearanceDict;
|
|
|
|
|
|
|
|
|
|
const uncheckedStream = new StringStream("0.3 0.2 0.1 rg");
|
|
|
|
|
uncheckedStream.dict = uncheckedAppearanceDict;
|
|
|
|
|
|
|
|
|
|
checkedAppearanceDict.set("BBox", [0, 0, 8, 8]);
|
|
|
|
|
checkedAppearanceDict.set("FormType", 1);
|
|
|
|
|
checkedAppearanceDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
|
|
|
|
|
normalAppearanceDict.set("Checked", checkedStream);
|
|
|
|
|
normalAppearanceDict.set("Off", uncheckedStream);
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceDict);
|
|
|
|
|
|
|
|
|
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.RADIO);
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: true };
|
2020-07-23 00:29:35 +09:00
|
|
|
|
return Promise.all([
|
|
|
|
|
annotation,
|
|
|
|
|
annotation.getOperatorList(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
false,
|
|
|
|
|
annotationStorage
|
|
|
|
|
),
|
|
|
|
|
]);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(([annotation, opList]) => {
|
|
|
|
|
expect(opList.argsArray.length).toEqual(3);
|
|
|
|
|
expect(opList.fnArray).toEqual([
|
|
|
|
|
OPS.beginAnnotation,
|
|
|
|
|
OPS.setFillRGBColor,
|
|
|
|
|
OPS.endAnnotation,
|
|
|
|
|
]);
|
|
|
|
|
expect(opList.argsArray[1]).toEqual(
|
|
|
|
|
new Uint8ClampedArray([26, 51, 76])
|
|
|
|
|
);
|
|
|
|
|
return annotation;
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: false };
|
2020-07-23 00:29:35 +09:00
|
|
|
|
return annotation.getOperatorList(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
false,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(opList => {
|
|
|
|
|
expect(opList.argsArray.length).toEqual(3);
|
|
|
|
|
expect(opList.fnArray).toEqual([
|
|
|
|
|
OPS.beginAnnotation,
|
|
|
|
|
OPS.setFillRGBColor,
|
|
|
|
|
OPS.endAnnotation,
|
|
|
|
|
]);
|
|
|
|
|
expect(opList.argsArray[1]).toEqual(
|
|
|
|
|
new Uint8ClampedArray([76, 51, 26])
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2020-08-04 02:44:04 +09:00
|
|
|
|
|
2020-09-20 00:47:38 +09:00
|
|
|
|
it("should render radio buttons for printing using normal appearance", function (done) {
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
const normalAppearanceDict = new Dict();
|
|
|
|
|
const checkedAppearanceDict = new Dict();
|
|
|
|
|
const uncheckedAppearanceDict = new Dict();
|
|
|
|
|
|
|
|
|
|
const checkedStream = new StringStream("0.1 0.2 0.3 rg");
|
|
|
|
|
checkedStream.dict = checkedAppearanceDict;
|
|
|
|
|
|
|
|
|
|
const uncheckedStream = new StringStream("0.3 0.2 0.1 rg");
|
|
|
|
|
uncheckedStream.dict = uncheckedAppearanceDict;
|
|
|
|
|
|
|
|
|
|
checkedAppearanceDict.set("BBox", [0, 0, 8, 8]);
|
|
|
|
|
checkedAppearanceDict.set("FormType", 1);
|
|
|
|
|
checkedAppearanceDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
|
|
|
|
|
normalAppearanceDict.set("Checked", checkedStream);
|
|
|
|
|
normalAppearanceDict.set("Off", uncheckedStream);
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceDict);
|
|
|
|
|
|
|
|
|
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.RADIO);
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
buttonWidgetDict.set("AS", Name.get("Off"));
|
|
|
|
|
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
|
|
|
|
return annotation.getOperatorList(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
false,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.then(opList => {
|
|
|
|
|
expect(opList.argsArray.length).toEqual(3);
|
|
|
|
|
expect(opList.fnArray).toEqual([
|
|
|
|
|
OPS.beginAnnotation,
|
|
|
|
|
OPS.setFillRGBColor,
|
|
|
|
|
OPS.endAnnotation,
|
|
|
|
|
]);
|
|
|
|
|
expect(opList.argsArray[1]).toEqual(
|
|
|
|
|
new Uint8ClampedArray([76, 51, 26])
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
.catch(done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-08-04 02:44:04 +09:00
|
|
|
|
it("should save radio buttons", function (done) {
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
const normalAppearanceDict = new Dict();
|
|
|
|
|
|
|
|
|
|
normalAppearanceDict.set("Checked", Ref.get(314, 0));
|
|
|
|
|
normalAppearanceDict.set("Off", Ref.get(271, 0));
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceDict);
|
|
|
|
|
|
|
|
|
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.RADIO);
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
|
|
|
|
|
const buttonWidgetRef = Ref.get(123, 0);
|
|
|
|
|
const parentRef = Ref.get(456, 0);
|
|
|
|
|
|
|
|
|
|
const parentDict = new Dict();
|
|
|
|
|
parentDict.set("V", Name.get("Off"));
|
|
|
|
|
parentDict.set("Kids", [buttonWidgetRef]);
|
|
|
|
|
buttonWidgetDict.set("Parent", parentRef);
|
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
{ ref: parentRef, data: parentDict },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
parentDict.xref = xref;
|
|
|
|
|
buttonWidgetDict.xref = xref;
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
const task = new WorkerTask("test save");
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: true };
|
2020-08-04 02:44:04 +09:00
|
|
|
|
return Promise.all([
|
|
|
|
|
annotation,
|
|
|
|
|
annotation.save(partialEvaluator, task, annotationStorage),
|
|
|
|
|
]);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(([annotation, data]) => {
|
|
|
|
|
expect(data.length).toEqual(2);
|
|
|
|
|
const [radioData, parentData] = data;
|
|
|
|
|
radioData.data = radioData.data.replace(/\(D:[0-9]+\)/, "(date)");
|
|
|
|
|
expect(radioData.ref).toEqual(Ref.get(123, 0));
|
|
|
|
|
expect(radioData.data).toEqual(
|
|
|
|
|
"123 0 obj\n" +
|
|
|
|
|
"<< /Type /Annot /Subtype /Widget /FT /Btn /Ff 32768 " +
|
2020-08-22 22:45:33 +09:00
|
|
|
|
"/AP << /N << /Checked 314 0 R /Off 271 0 R>>>> " +
|
2020-08-04 02:44:04 +09:00
|
|
|
|
"/Parent 456 0 R /AS /Checked /M (date)>>\nendobj\n"
|
|
|
|
|
);
|
|
|
|
|
expect(parentData.ref).toEqual(Ref.get(456, 0));
|
|
|
|
|
expect(parentData.data).toEqual(
|
|
|
|
|
"456 0 obj\n<< /V /Checked /Kids [123 0 R]>>\nendobj\n"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return annotation;
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: false };
|
2020-08-04 02:44:04 +09:00
|
|
|
|
return annotation.save(partialEvaluator, task, annotationStorage);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(data => {
|
|
|
|
|
expect(data).toEqual(null);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2020-09-09 02:07:10 +09:00
|
|
|
|
|
2020-09-15 21:23:08 +09:00
|
|
|
|
it("should save radio buttons without a field value", function (done) {
|
|
|
|
|
const appearanceStatesDict = new Dict();
|
|
|
|
|
const normalAppearanceDict = new Dict();
|
|
|
|
|
|
|
|
|
|
normalAppearanceDict.set("Checked", Ref.get(314, 0));
|
|
|
|
|
normalAppearanceDict.set("Off", Ref.get(271, 0));
|
|
|
|
|
appearanceStatesDict.set("N", normalAppearanceDict);
|
|
|
|
|
|
|
|
|
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.RADIO);
|
|
|
|
|
buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
|
|
|
|
|
|
const buttonWidgetRef = Ref.get(123, 0);
|
|
|
|
|
const parentRef = Ref.get(456, 0);
|
|
|
|
|
|
|
|
|
|
const parentDict = new Dict();
|
|
|
|
|
parentDict.set("Kids", [buttonWidgetRef]);
|
|
|
|
|
buttonWidgetDict.set("Parent", parentRef);
|
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
{ ref: parentRef, data: parentDict },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
parentDict.xref = xref;
|
|
|
|
|
buttonWidgetDict.xref = xref;
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
const task = new WorkerTask("test save");
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: true };
|
2020-09-15 21:23:08 +09:00
|
|
|
|
return Promise.all([
|
|
|
|
|
annotation,
|
|
|
|
|
annotation.save(partialEvaluator, task, annotationStorage),
|
|
|
|
|
]);
|
|
|
|
|
})
|
|
|
|
|
.then(([annotation, data]) => {
|
|
|
|
|
expect(data.length).toEqual(2);
|
|
|
|
|
const [radioData, parentData] = data;
|
|
|
|
|
radioData.data = radioData.data.replace(/\(D:[0-9]+\)/, "(date)");
|
|
|
|
|
expect(radioData.ref).toEqual(Ref.get(123, 0));
|
|
|
|
|
expect(radioData.data).toEqual(
|
|
|
|
|
"123 0 obj\n" +
|
|
|
|
|
"<< /Type /Annot /Subtype /Widget /FT /Btn /Ff 32768 " +
|
|
|
|
|
"/AP << /N << /Checked 314 0 R /Off 271 0 R>>>> " +
|
|
|
|
|
"/Parent 456 0 R /AS /Checked /M (date)>>\nendobj\n"
|
|
|
|
|
);
|
|
|
|
|
expect(parentData.ref).toEqual(Ref.get(456, 0));
|
|
|
|
|
expect(parentData.data).toEqual(
|
|
|
|
|
"456 0 obj\n<< /Kids [123 0 R] /V /Checked>>\nendobj\n"
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
.catch(done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-09-09 02:07:10 +09:00
|
|
|
|
it("should save nothing", function (done) {
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test save");
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
return annotation.save(partialEvaluator, task, {});
|
|
|
|
|
})
|
|
|
|
|
.then(data => {
|
|
|
|
|
expect(data).toEqual(null);
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
.catch(done.fail);
|
|
|
|
|
});
|
2020-09-07 00:14:56 +09:00
|
|
|
|
|
|
|
|
|
it("should handle push buttons", function (done) {
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.PUSHBUTTON);
|
2020-10-01 03:58:45 +09:00
|
|
|
|
|
|
|
|
|
const actionDict = new Dict();
|
|
|
|
|
actionDict.set("S", Name.get("JavaScript"));
|
|
|
|
|
actionDict.set("JS", "do_something();");
|
|
|
|
|
buttonWidgetDict.set("A", actionDict);
|
2020-09-07 00:14:56 +09:00
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.pushButton).toEqual(true);
|
2020-10-01 03:58:45 +09:00
|
|
|
|
expect(data.actions.Action).toEqual(["do_something();"]);
|
2020-09-07 00:14:56 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should handle push buttons that act as a tooltip only", function (done) {
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.PUSHBUTTON);
|
|
|
|
|
buttonWidgetDict.set("TU", "An alternative text");
|
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.pushButton).toEqual(true);
|
|
|
|
|
expect(data.alternativeText).toEqual("An alternative text");
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2020-10-16 02:42:36 +09:00
|
|
|
|
|
|
|
|
|
it("should handle URL in A dict in push buttons", function (done) {
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.PUSHBUTTON);
|
|
|
|
|
|
|
|
|
|
const actionDict = new Dict();
|
|
|
|
|
actionDict.set("S", Name.get("JavaScript"));
|
|
|
|
|
actionDict.set(
|
|
|
|
|
"JS",
|
|
|
|
|
"app.launchURL('https://developer.mozilla.org/en-US/', true)"
|
|
|
|
|
);
|
|
|
|
|
buttonWidgetDict.set("A", actionDict);
|
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.url).toEqual("https://developer.mozilla.org/en-US/");
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should handle URL in AA dict in push buttons", function (done) {
|
|
|
|
|
const buttonWidgetRef = Ref.get(124, 0);
|
|
|
|
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.PUSHBUTTON);
|
|
|
|
|
|
|
|
|
|
// D stands for MouseDown
|
|
|
|
|
const dDict = new Dict();
|
|
|
|
|
dDict.set("S", Name.get("JavaScript"));
|
|
|
|
|
dDict.set(
|
|
|
|
|
"JS",
|
|
|
|
|
"app.launchURL('https://developer.mozilla.org/en-US/', true)"
|
|
|
|
|
);
|
|
|
|
|
const actionDict = new Dict();
|
|
|
|
|
actionDict.set("D", dDict);
|
|
|
|
|
buttonWidgetDict.set("AA", actionDict);
|
|
|
|
|
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
buttonWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.url).toEqual("https://developer.mozilla.org/en-US/");
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2016-11-04 21:01:42 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("ChoiceWidgetAnnotation", function () {
|
2020-08-05 21:40:31 +09:00
|
|
|
|
let choiceWidgetDict, fontRefObj;
|
2016-09-26 00:08:17 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
beforeEach(function (done) {
|
2016-09-26 00:08:17 +09:00
|
|
|
|
choiceWidgetDict = new Dict();
|
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
|
|
|
|
choiceWidgetDict.set("Type", Name.get("Annot"));
|
|
|
|
|
choiceWidgetDict.set("Subtype", Name.get("Widget"));
|
|
|
|
|
choiceWidgetDict.set("FT", Name.get("Ch"));
|
2020-08-05 21:40:31 +09:00
|
|
|
|
|
|
|
|
|
const helvDict = new Dict();
|
|
|
|
|
helvDict.set("BaseFont", Name.get("Helvetica"));
|
|
|
|
|
helvDict.set("Type", Name.get("Font"));
|
|
|
|
|
helvDict.set("Subtype", Name.get("Type1"));
|
|
|
|
|
|
|
|
|
|
const fontRef = Ref.get(314, 0);
|
|
|
|
|
fontRefObj = { ref: fontRef, data: helvDict };
|
|
|
|
|
const resourceDict = new Dict();
|
|
|
|
|
const fontDict = new Dict();
|
|
|
|
|
fontDict.set("Helv", fontRef);
|
|
|
|
|
resourceDict.set("Font", fontDict);
|
|
|
|
|
|
|
|
|
|
choiceWidgetDict.set("DA", "/Helv 5 Tf");
|
|
|
|
|
choiceWidgetDict.set("DR", resourceDict);
|
|
|
|
|
choiceWidgetDict.set("Rect", [0, 0, 32, 10]);
|
|
|
|
|
|
2016-09-26 00:08:17 +09:00
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
afterEach(function () {
|
2020-08-05 21:40:31 +09:00
|
|
|
|
choiceWidgetDict = fontRefObj = null;
|
2016-09-26 00:08:17 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle missing option arrays", function (done) {
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const choiceWidgetRef = Ref.get(122, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
2016-09-26 00:08:17 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
choiceWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.options).toEqual([]);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-09-26 00:08:17 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle option arrays with array elements", function (done) {
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const optionBarRef = Ref.get(20, 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
|
|
|
|
const optionBarStr = "Bar";
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const optionOneRef = Ref.get(10, 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
|
|
|
|
const optionOneArr = ["bar_export", optionBarRef];
|
2016-12-17 21:34:18 +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
|
|
|
|
const options = [["foo_export", "Foo"], optionOneRef];
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const expected = [
|
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
|
|
|
|
{ exportValue: "foo_export", displayValue: "Foo" },
|
|
|
|
|
{ exportValue: "bar_export", displayValue: "Bar" },
|
2016-09-26 00:08:17 +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
|
|
|
|
choiceWidgetDict.set("Opt", options);
|
2016-09-26 00:08:17 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const choiceWidgetRef = Ref.get(123, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
|
|
|
|
{ ref: optionBarRef, data: optionBarStr },
|
|
|
|
|
{ ref: optionOneRef, data: optionOneArr },
|
2016-09-26 00:08:17 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
choiceWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.options).toEqual(expected);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-09-26 00:08:17 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle option arrays with string elements", function (done) {
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const optionBarRef = Ref.get(10, 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
|
|
|
|
const optionBarStr = "Bar";
|
2016-12-17 21:34:18 +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
|
|
|
|
const options = ["Foo", optionBarRef];
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const expected = [
|
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
|
|
|
|
{ exportValue: "Foo", displayValue: "Foo" },
|
|
|
|
|
{ exportValue: "Bar", displayValue: "Bar" },
|
2016-09-26 00:08:17 +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
|
|
|
|
choiceWidgetDict.set("Opt", options);
|
2016-09-26 00:08:17 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const choiceWidgetRef = Ref.get(981, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
|
|
|
|
{ ref: optionBarRef, data: optionBarStr },
|
2016-09-26 00:08:17 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
choiceWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.options).toEqual(expected);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-09-26 00:08:17 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle inherited option arrays (issue 8094)", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const options = [
|
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
|
|
|
|
["Value1", "Description1"],
|
|
|
|
|
["Value2", "Description2"],
|
2017-02-26 07:34:26 +09:00
|
|
|
|
];
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const expected = [
|
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
|
|
|
|
{ exportValue: "Value1", displayValue: "Description1" },
|
|
|
|
|
{ exportValue: "Value2", displayValue: "Description2" },
|
2017-02-26 07:34:26 +09:00
|
|
|
|
];
|
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const parentDict = new Dict();
|
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
|
|
|
|
parentDict.set("Opt", options);
|
2017-02-26 07:34:26 +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
|
|
|
|
choiceWidgetDict.set("Parent", parentDict);
|
2017-02-26 07:34:26 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const choiceWidgetRef = Ref.get(123, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
2017-02-26 07:34:26 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
choiceWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.options).toEqual(expected);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2017-11-19 00:47:32 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-08-22 22:02:29 +09:00
|
|
|
|
it("should decode form values", function (done) {
|
|
|
|
|
const encodedString = "\xFE\xFF\x00F\x00o\x00o";
|
|
|
|
|
const decodedString = "Foo";
|
2017-11-19 00:47:32 +09:00
|
|
|
|
|
2020-08-22 22:02:29 +09:00
|
|
|
|
choiceWidgetDict.set("Opt", [encodedString]);
|
|
|
|
|
choiceWidgetDict.set("V", encodedString);
|
2020-11-04 00:53:21 +09:00
|
|
|
|
choiceWidgetDict.set("DV", Name.get("foo"));
|
2017-11-19 00:47:32 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const choiceWidgetRef = Ref.get(984, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
2017-11-19 00:47: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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
choiceWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
2020-08-22 22:02:29 +09:00
|
|
|
|
expect(data.fieldValue).toEqual([decodedString]);
|
2020-11-04 00:53:21 +09:00
|
|
|
|
expect(data.defaultFieldValue).toEqual("foo");
|
2020-08-22 22:02:29 +09:00
|
|
|
|
expect(data.options).toEqual([
|
|
|
|
|
{ exportValue: decodedString, displayValue: decodedString },
|
|
|
|
|
]);
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2017-02-26 07:34:26 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-08-19 05:55:59 +09:00
|
|
|
|
it("should convert the field value to an array", function (done) {
|
2020-08-19 06:04:56 +09:00
|
|
|
|
const inputs = [null, "Foo", ["Foo", "Bar"]];
|
|
|
|
|
const outputs = [[], ["Foo"], ["Foo", "Bar"]];
|
2016-09-26 00:08:17 +09:00
|
|
|
|
|
2020-08-19 05:55:59 +09:00
|
|
|
|
let promise = Promise.resolve();
|
|
|
|
|
for (let i = 0, ii = inputs.length; i < ii; i++) {
|
|
|
|
|
promise = promise.then(() => {
|
|
|
|
|
choiceWidgetDict.set("V", inputs[i]);
|
2016-09-26 00:08:17 +09:00
|
|
|
|
|
2020-08-19 05:55:59 +09:00
|
|
|
|
const choiceWidgetRef = Ref.get(968, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
|
|
|
|
]);
|
2016-09-26 00:08:17 +09:00
|
|
|
|
|
2020-08-19 05:55:59 +09:00
|
|
|
|
return AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
choiceWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.fieldValue).toEqual(outputs[i]);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
promise.then(done, done.fail);
|
2016-09-26 00:08:17 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle unknown flags", function (done) {
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const choiceWidgetRef = Ref.get(166, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
2016-09-26 00:08:17 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
choiceWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.readOnly).toEqual(false);
|
2020-10-01 03:58:45 +09:00
|
|
|
|
expect(data.hidden).toEqual(false);
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.combo).toEqual(false);
|
|
|
|
|
expect(data.multiSelect).toEqual(false);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-09-26 00:08:17 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should not set invalid flags", function (done) {
|
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
|
|
|
|
choiceWidgetDict.set("Ff", "readonly");
|
2016-09-26 00:08:17 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const choiceWidgetRef = Ref.get(165, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
2016-09-26 00:08:17 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
choiceWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.readOnly).toEqual(false);
|
2020-10-01 03:58:45 +09:00
|
|
|
|
expect(data.hidden).toEqual(false);
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.combo).toEqual(false);
|
|
|
|
|
expect(data.multiSelect).toEqual(false);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-09-26 00:08:17 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set valid flags", function (done) {
|
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
|
|
|
|
choiceWidgetDict.set(
|
|
|
|
|
"Ff",
|
|
|
|
|
AnnotationFieldFlag.READONLY +
|
|
|
|
|
AnnotationFieldFlag.COMBO +
|
|
|
|
|
AnnotationFieldFlag.MULTISELECT
|
|
|
|
|
);
|
2016-09-26 00:08:17 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const choiceWidgetRef = Ref.get(512, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
2016-09-26 00:08:17 +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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
choiceWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
|
|
|
|
expect(data.readOnly).toEqual(true);
|
2020-10-01 03:58:45 +09:00
|
|
|
|
expect(data.hidden).toEqual(false);
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.combo).toEqual(true);
|
|
|
|
|
expect(data.multiSelect).toEqual(true);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-09-26 00:08:17 +09:00
|
|
|
|
});
|
2020-08-05 21:40:31 +09:00
|
|
|
|
|
|
|
|
|
it("should render choice for printing", function (done) {
|
|
|
|
|
const choiceWidgetRef = Ref.get(271, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
|
|
|
|
fontRefObj,
|
|
|
|
|
]);
|
|
|
|
|
const task = new WorkerTask("test print");
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
choiceWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const id = annotation.data.id;
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[id] = { value: "a value" };
|
2020-08-05 21:40:31 +09:00
|
|
|
|
return annotation._getAppearance(
|
|
|
|
|
partialEvaluator,
|
|
|
|
|
task,
|
|
|
|
|
annotationStorage
|
|
|
|
|
);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(appearance => {
|
|
|
|
|
expect(appearance).toEqual(
|
|
|
|
|
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm" +
|
|
|
|
|
" 2.00 2.00 Td (a value) Tj ET Q EMC"
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2020-08-04 02:44:04 +09:00
|
|
|
|
|
|
|
|
|
it("should save choice", function (done) {
|
|
|
|
|
choiceWidgetDict.set("Opt", ["A", "B", "C"]);
|
|
|
|
|
choiceWidgetDict.set("V", "A");
|
|
|
|
|
|
|
|
|
|
const choiceWidgetRef = Ref.get(123, 0);
|
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: choiceWidgetRef, data: choiceWidgetDict },
|
|
|
|
|
]);
|
|
|
|
|
partialEvaluator.xref = xref;
|
|
|
|
|
const task = new WorkerTask("test save");
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
choiceWidgetRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
)
|
|
|
|
|
.then(annotation => {
|
|
|
|
|
const annotationStorage = {};
|
2020-11-04 00:04:08 +09:00
|
|
|
|
annotationStorage[annotation.data.id] = { value: "C" };
|
2020-08-04 02:44:04 +09:00
|
|
|
|
return annotation.save(partialEvaluator, task, annotationStorage);
|
|
|
|
|
}, done.fail)
|
|
|
|
|
.then(data => {
|
|
|
|
|
expect(data.length).toEqual(2);
|
|
|
|
|
const [oldData, newData] = data;
|
|
|
|
|
expect(oldData.ref).toEqual(Ref.get(123, 0));
|
|
|
|
|
expect(newData.ref).toEqual(Ref.get(1, 0));
|
|
|
|
|
|
|
|
|
|
oldData.data = oldData.data.replace(/\(D:[0-9]+\)/, "(date)");
|
|
|
|
|
expect(oldData.data).toEqual(
|
|
|
|
|
"123 0 obj\n" +
|
|
|
|
|
"<< /Type /Annot /Subtype /Widget /FT /Ch /DA (/Helv 5 Tf) /DR " +
|
|
|
|
|
"<< /Font << /Helv 314 0 R>>>> " +
|
|
|
|
|
"/Rect [0 0 32 10] /Opt [(A) (B) (C)] /V (C) " +
|
|
|
|
|
"/AP << /N 1 0 R>> /M (date)>>\nendobj\n"
|
|
|
|
|
);
|
|
|
|
|
expect(newData.data).toEqual(
|
|
|
|
|
"1 0 obj\n" +
|
|
|
|
|
"<< /Length 67 /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " +
|
|
|
|
|
"/BBox [0 0 32 10]>> stream\n" +
|
|
|
|
|
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2.00 2.00 Td (C) Tj ET Q EMC\n" +
|
|
|
|
|
"endstream\nendobj\n"
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2016-09-26 00:08:17 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("LineAnnotation", function () {
|
|
|
|
|
it("should set the line coordinates", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const lineDict = new Dict();
|
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
|
|
|
|
lineDict.set("Type", Name.get("Annot"));
|
|
|
|
|
lineDict.set("Subtype", Name.get("Line"));
|
|
|
|
|
lineDict.set("L", [1, 2, 3, 4]);
|
2017-04-03 03:50:17 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const lineRef = Ref.get(122, 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
|
|
|
|
const xref = new XRefMock([{ ref: lineRef, data: lineDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
lineRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINE);
|
|
|
|
|
expect(data.lineCoordinates).toEqual([1, 2, 3, 4]);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2017-04-03 03:50:17 +09:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("FileAttachmentAnnotation", function () {
|
|
|
|
|
it("should correctly parse a file attachment", function (done) {
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const fileStream = new StringStream(
|
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
|
|
|
|
"<<\n" +
|
|
|
|
|
"/Type /EmbeddedFile\n" +
|
|
|
|
|
"/Subtype /text#2Fplain\n" +
|
|
|
|
|
">>\n" +
|
|
|
|
|
"stream\n" +
|
|
|
|
|
"Test attachment" +
|
|
|
|
|
"endstream\n"
|
2017-01-12 22:11:22 +09:00
|
|
|
|
);
|
2019-06-23 23:01:45 +09:00
|
|
|
|
const parser = new Parser({
|
|
|
|
|
lexer: new Lexer(fileStream),
|
|
|
|
|
xref: null,
|
|
|
|
|
allowStreams: true,
|
|
|
|
|
});
|
2016-02-15 05:27:53 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const fileStreamRef = Ref.get(18, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const fileStreamDict = parser.getObj();
|
2016-02-15 05:27:53 +09:00
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const embeddedFileDict = new Dict();
|
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
|
|
|
|
embeddedFileDict.set("F", fileStreamRef);
|
2017-01-12 22:11:22 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const fileSpecRef = Ref.get(19, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const fileSpecDict = new Dict();
|
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
|
|
|
|
fileSpecDict.set("Type", Name.get("Filespec"));
|
|
|
|
|
fileSpecDict.set("Desc", "");
|
|
|
|
|
fileSpecDict.set("EF", embeddedFileDict);
|
|
|
|
|
fileSpecDict.set("UF", "Test.txt");
|
2017-01-12 22:11:22 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const fileAttachmentRef = Ref.get(20, 0);
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const fileAttachmentDict = new Dict();
|
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
|
|
|
|
fileAttachmentDict.set("Type", Name.get("Annot"));
|
|
|
|
|
fileAttachmentDict.set("Subtype", Name.get("FileAttachment"));
|
|
|
|
|
fileAttachmentDict.set("FS", fileSpecRef);
|
|
|
|
|
fileAttachmentDict.set("T", "Topic");
|
|
|
|
|
fileAttachmentDict.set("Contents", "Test.txt");
|
2017-01-12 22:11:22 +09:00
|
|
|
|
|
2018-08-12 01:50:31 +09:00
|
|
|
|
const xref = new XRefMock([
|
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
|
|
|
|
{ ref: fileStreamRef, data: fileStreamDict },
|
|
|
|
|
{ ref: fileSpecRef, data: fileSpecDict },
|
|
|
|
|
{ ref: fileAttachmentRef, data: fileAttachmentDict },
|
2017-01-12 22:11:22 +09:00
|
|
|
|
]);
|
|
|
|
|
embeddedFileDict.assignXref(xref);
|
|
|
|
|
fileSpecDict.assignXref(xref);
|
|
|
|
|
fileAttachmentDict.assignXref(xref);
|
|
|
|
|
|
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
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
fileAttachmentRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-03-21 09:43:40 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.FILEATTACHMENT);
|
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
|
|
|
|
expect(data.file.filename).toEqual("Test.txt");
|
|
|
|
|
expect(data.file.content).toEqual(stringToBytes("Test attachment"));
|
2018-03-21 09:43:40 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
2016-02-15 05:27:53 +09:00
|
|
|
|
});
|
|
|
|
|
});
|
2016-05-25 00:35:45 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("PopupAnnotation", function () {
|
|
|
|
|
it("should inherit properties from its parent", function (done) {
|
2019-04-22 04:21:01 +09:00
|
|
|
|
const parentDict = new Dict();
|
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
|
|
|
|
parentDict.set("Type", Name.get("Annot"));
|
|
|
|
|
parentDict.set("Subtype", Name.get("Text"));
|
|
|
|
|
parentDict.set("M", "D:20190423");
|
|
|
|
|
parentDict.set("C", [0, 0, 1]);
|
2019-04-22 04:21:01 +09:00
|
|
|
|
|
|
|
|
|
const popupDict = new Dict();
|
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
|
|
|
|
popupDict.set("Type", Name.get("Annot"));
|
|
|
|
|
popupDict.set("Subtype", Name.get("Popup"));
|
|
|
|
|
popupDict.set("Parent", parentDict);
|
2019-04-22 04:21:01 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const popupRef = Ref.get(13, 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
|
|
|
|
const xref = new XRefMock([{ ref: popupRef, data: popupDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
popupRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data, viewable }) => {
|
2019-04-22 04:21:01 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.POPUP);
|
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
|
|
|
|
expect(data.modificationDate).toEqual("D:20190423");
|
2019-04-22 04:21:01 +09:00
|
|
|
|
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle missing parent properties", function (done) {
|
2019-04-22 04:21:01 +09:00
|
|
|
|
const parentDict = new Dict();
|
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
|
|
|
|
parentDict.set("Type", Name.get("Annot"));
|
|
|
|
|
parentDict.set("Subtype", Name.get("Text"));
|
2019-04-22 04:21:01 +09:00
|
|
|
|
|
|
|
|
|
const popupDict = new Dict();
|
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
|
|
|
|
popupDict.set("Type", Name.get("Annot"));
|
|
|
|
|
popupDict.set("Subtype", Name.get("Popup"));
|
|
|
|
|
popupDict.set("Parent", parentDict);
|
2019-04-22 04:21:01 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const popupRef = Ref.get(13, 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
|
|
|
|
const xref = new XRefMock([{ ref: popupRef, data: popupDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
popupRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data, viewable }) => {
|
2019-04-22 04:21:01 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.POPUP);
|
|
|
|
|
expect(data.modificationDate).toEqual(null);
|
|
|
|
|
expect(data.color).toEqual(null);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
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
|
|
|
|
it(
|
|
|
|
|
"should inherit the parent flags when the Popup is not viewable, " +
|
|
|
|
|
"but the parent is (PR 7352)",
|
2020-04-14 19:28:14 +09:00
|
|
|
|
function (done) {
|
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 parentDict = new Dict();
|
|
|
|
|
parentDict.set("Type", Name.get("Annot"));
|
|
|
|
|
parentDict.set("Subtype", Name.get("Text"));
|
|
|
|
|
parentDict.set("F", 28); // viewable
|
|
|
|
|
|
|
|
|
|
const popupDict = new Dict();
|
|
|
|
|
popupDict.set("Type", Name.get("Annot"));
|
|
|
|
|
popupDict.set("Subtype", Name.get("Popup"));
|
|
|
|
|
popupDict.set("F", 25); // not viewable
|
|
|
|
|
popupDict.set("Parent", parentDict);
|
|
|
|
|
|
|
|
|
|
const popupRef = Ref.get(13, 0);
|
|
|
|
|
const xref = new XRefMock([{ ref: popupRef, data: popupDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
popupRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data, viewable }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.POPUP);
|
|
|
|
|
// We should not modify the `annotationFlags` returned through
|
|
|
|
|
// e.g., the API.
|
|
|
|
|
expect(data.annotationFlags).toEqual(25);
|
|
|
|
|
// The popup should inherit the `viewable` property of the parent.
|
|
|
|
|
expect(viewable).toEqual(true);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
}
|
|
|
|
|
);
|
2019-05-15 04:14:35 +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
|
|
|
|
it(
|
|
|
|
|
"should correctly inherit Contents from group-master annotation " +
|
|
|
|
|
"if parent has ReplyType == Group",
|
2020-04-14 19:28:14 +09:00
|
|
|
|
function (done) {
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const annotationRef = Ref.get(819, 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
|
|
|
|
const annotationDict = new Dict();
|
|
|
|
|
annotationDict.set("Type", Name.get("Annot"));
|
|
|
|
|
annotationDict.set("Subtype", Name.get("Text"));
|
|
|
|
|
annotationDict.set("T", "Correct Title");
|
|
|
|
|
annotationDict.set("Contents", "Correct Text");
|
|
|
|
|
annotationDict.set("M", "D:20190423");
|
|
|
|
|
annotationDict.set("C", [0, 0, 1]);
|
|
|
|
|
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const replyRef = Ref.get(820, 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
|
|
|
|
const replyDict = new Dict();
|
|
|
|
|
replyDict.set("Type", Name.get("Annot"));
|
|
|
|
|
replyDict.set("Subtype", Name.get("Text"));
|
|
|
|
|
replyDict.set("IRT", annotationRef);
|
|
|
|
|
replyDict.set("RT", Name.get("Group"));
|
|
|
|
|
replyDict.set("T", "Reply Title");
|
|
|
|
|
replyDict.set("Contents", "Reply Text");
|
|
|
|
|
replyDict.set("M", "D:20190523");
|
|
|
|
|
replyDict.set("C", [0.4]);
|
|
|
|
|
|
2020-02-23 04:53:47 +09:00
|
|
|
|
const popupRef = Ref.get(821, 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
|
|
|
|
const popupDict = new Dict();
|
|
|
|
|
popupDict.set("Type", Name.get("Annot"));
|
|
|
|
|
popupDict.set("Subtype", Name.get("Popup"));
|
|
|
|
|
popupDict.set("T", "Wrong Title");
|
|
|
|
|
popupDict.set("Contents", "Wrong Text");
|
|
|
|
|
popupDict.set("Parent", replyRef);
|
|
|
|
|
popupDict.set("M", "D:20190623");
|
|
|
|
|
popupDict.set("C", [0.8]);
|
|
|
|
|
replyDict.set("Popup", popupRef);
|
2019-05-15 04:14:35 +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
|
|
|
|
const xref = new XRefMock([
|
|
|
|
|
{ ref: annotationRef, data: annotationDict },
|
|
|
|
|
{ ref: replyRef, data: replyDict },
|
|
|
|
|
{ ref: popupRef, data: popupDict },
|
|
|
|
|
]);
|
|
|
|
|
annotationDict.assignXref(xref);
|
|
|
|
|
popupDict.assignXref(xref);
|
|
|
|
|
replyDict.assignXref(xref);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
popupRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.title).toEqual("Correct Title");
|
|
|
|
|
expect(data.contents).toEqual("Correct Text");
|
|
|
|
|
expect(data.modificationDate).toEqual("D:20190423");
|
|
|
|
|
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
}
|
|
|
|
|
);
|
2016-05-25 00:35:45 +09:00
|
|
|
|
});
|
2018-09-30 23:29:16 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("InkAnnotation", function () {
|
|
|
|
|
it("should handle a single ink list", function (done) {
|
2018-09-30 23:29:16 +09:00
|
|
|
|
const inkDict = new Dict();
|
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
|
|
|
|
inkDict.set("Type", Name.get("Annot"));
|
|
|
|
|
inkDict.set("Subtype", Name.get("Ink"));
|
|
|
|
|
inkDict.set("InkList", [[1, 1, 1, 2, 2, 2, 3, 3]]);
|
2018-09-30 23:29:16 +09:00
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const inkRef = Ref.get(142, 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
|
|
|
|
const xref = new XRefMock([{ ref: inkRef, data: inkDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
inkRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-09-30 23:29:16 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.INK);
|
|
|
|
|
expect(data.inkLists.length).toEqual(1);
|
|
|
|
|
expect(data.inkLists[0]).toEqual([
|
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
|
|
|
|
{ x: 1, y: 1 },
|
|
|
|
|
{ x: 1, y: 2 },
|
|
|
|
|
{ x: 2, y: 2 },
|
|
|
|
|
{ x: 3, y: 3 },
|
2018-09-30 23:29:16 +09:00
|
|
|
|
]);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should handle multiple ink lists", function (done) {
|
2018-09-30 23:29:16 +09:00
|
|
|
|
const inkDict = new Dict();
|
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
|
|
|
|
inkDict.set("Type", Name.get("Annot"));
|
|
|
|
|
inkDict.set("Subtype", Name.get("Ink"));
|
|
|
|
|
inkDict.set("InkList", [
|
2018-09-30 23:29:16 +09:00
|
|
|
|
[1, 1, 1, 2],
|
|
|
|
|
[3, 3, 4, 5],
|
|
|
|
|
]);
|
|
|
|
|
|
2019-05-26 00:40:14 +09:00
|
|
|
|
const inkRef = Ref.get(143, 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
|
|
|
|
const xref = new XRefMock([{ ref: inkRef, data: inkDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
inkRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2018-09-30 23:29:16 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.INK);
|
|
|
|
|
expect(data.inkLists.length).toEqual(2);
|
|
|
|
|
expect(data.inkLists[0]).toEqual([
|
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
|
|
|
|
{ x: 1, y: 1 },
|
|
|
|
|
{ x: 1, y: 2 },
|
2018-09-30 23:29:16 +09:00
|
|
|
|
]);
|
|
|
|
|
expect(data.inkLists[1]).toEqual([
|
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
|
|
|
|
{ x: 3, y: 3 },
|
|
|
|
|
{ x: 4, y: 5 },
|
2018-09-30 23:29:16 +09:00
|
|
|
|
]);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
});
|
2019-07-28 03:57:52 +09:00
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("HightlightAnnotation", function () {
|
2020-10-21 19:00:34 +09:00
|
|
|
|
it("should set quadpoints to null if not defined", function (done) {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
const highlightDict = new Dict();
|
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
|
|
|
|
highlightDict.set("Type", Name.get("Annot"));
|
|
|
|
|
highlightDict.set("Subtype", Name.get("Highlight"));
|
2019-07-28 03:57:52 +09:00
|
|
|
|
|
|
|
|
|
const highlightRef = Ref.get(121, 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
|
|
|
|
const xref = new XRefMock([{ ref: highlightRef, data: highlightDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
highlightRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.HIGHLIGHT);
|
2020-10-21 19:00:34 +09:00
|
|
|
|
expect(data.quadPoints).toEqual(null);
|
2019-07-28 03:57:52 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set quadpoints if defined", function (done) {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
const highlightDict = new Dict();
|
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
|
|
|
|
highlightDict.set("Type", Name.get("Annot"));
|
|
|
|
|
highlightDict.set("Subtype", Name.get("Highlight"));
|
|
|
|
|
highlightDict.set("Rect", [10, 10, 20, 20]);
|
2020-12-06 05:27:38 +09:00
|
|
|
|
highlightDict.set("QuadPoints", [10, 20, 20, 20, 10, 10, 20, 10]);
|
2019-07-28 03:57:52 +09:00
|
|
|
|
|
|
|
|
|
const highlightRef = Ref.get(121, 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
|
|
|
|
const xref = new XRefMock([{ ref: highlightRef, data: highlightDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
highlightRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.HIGHLIGHT);
|
|
|
|
|
expect(data.quadPoints).toEqual([
|
|
|
|
|
[
|
2020-12-06 05:27:38 +09:00
|
|
|
|
{ x: 10, y: 20 },
|
|
|
|
|
{ x: 20, y: 20 },
|
|
|
|
|
{ x: 10, y: 10 },
|
|
|
|
|
{ x: 20, y: 10 },
|
2019-07-28 03:57:52 +09:00
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2020-10-21 19:00:34 +09:00
|
|
|
|
|
|
|
|
|
it("should set quadpoints to null when empty", function (done) {
|
|
|
|
|
const highlightDict = new Dict();
|
|
|
|
|
highlightDict.set("Type", Name.get("Annot"));
|
|
|
|
|
highlightDict.set("Subtype", Name.get("Highlight"));
|
|
|
|
|
highlightDict.set("Rect", [10, 10, 20, 20]);
|
|
|
|
|
highlightDict.set("QuadPoints", []);
|
|
|
|
|
|
|
|
|
|
const highlightRef = Ref.get(121, 0);
|
|
|
|
|
const xref = new XRefMock([{ ref: highlightRef, data: highlightDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
highlightRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.HIGHLIGHT);
|
|
|
|
|
expect(data.quadPoints).toEqual(null);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
2019-07-28 03:57:52 +09:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("UnderlineAnnotation", function () {
|
2020-10-21 19:00:34 +09:00
|
|
|
|
it("should set quadpoints to null if not defined", function (done) {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
const underlineDict = new Dict();
|
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
|
|
|
|
underlineDict.set("Type", Name.get("Annot"));
|
|
|
|
|
underlineDict.set("Subtype", Name.get("Underline"));
|
2019-07-28 03:57:52 +09:00
|
|
|
|
|
|
|
|
|
const underlineRef = Ref.get(121, 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
|
|
|
|
const xref = new XRefMock([{ ref: underlineRef, data: underlineDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
underlineRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.UNDERLINE);
|
2020-10-21 19:00:34 +09:00
|
|
|
|
expect(data.quadPoints).toEqual(null);
|
2019-07-28 03:57:52 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set quadpoints if defined", function (done) {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
const underlineDict = new Dict();
|
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
|
|
|
|
underlineDict.set("Type", Name.get("Annot"));
|
|
|
|
|
underlineDict.set("Subtype", Name.get("Underline"));
|
|
|
|
|
underlineDict.set("Rect", [10, 10, 20, 20]);
|
2020-12-06 05:27:38 +09:00
|
|
|
|
underlineDict.set("QuadPoints", [10, 20, 20, 20, 10, 10, 20, 10]);
|
2019-07-28 03:57:52 +09:00
|
|
|
|
|
|
|
|
|
const underlineRef = Ref.get(121, 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
|
|
|
|
const xref = new XRefMock([{ ref: underlineRef, data: underlineDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
underlineRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.UNDERLINE);
|
|
|
|
|
expect(data.quadPoints).toEqual([
|
|
|
|
|
[
|
2020-12-06 05:27:38 +09:00
|
|
|
|
{ x: 10, y: 20 },
|
|
|
|
|
{ x: 20, y: 20 },
|
|
|
|
|
{ x: 10, y: 10 },
|
|
|
|
|
{ x: 20, y: 10 },
|
2019-07-28 03:57:52 +09:00
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("SquigglyAnnotation", function () {
|
2020-10-21 19:00:34 +09:00
|
|
|
|
it("should set quadpoints to null if not defined", function (done) {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
const squigglyDict = new Dict();
|
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
|
|
|
|
squigglyDict.set("Type", Name.get("Annot"));
|
|
|
|
|
squigglyDict.set("Subtype", Name.get("Squiggly"));
|
2019-07-28 03:57:52 +09:00
|
|
|
|
|
|
|
|
|
const squigglyRef = Ref.get(121, 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
|
|
|
|
const xref = new XRefMock([{ ref: squigglyRef, data: squigglyDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
squigglyRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.SQUIGGLY);
|
2020-10-21 19:00:34 +09:00
|
|
|
|
expect(data.quadPoints).toEqual(null);
|
2019-07-28 03:57:52 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set quadpoints if defined", function (done) {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
const squigglyDict = new Dict();
|
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
|
|
|
|
squigglyDict.set("Type", Name.get("Annot"));
|
|
|
|
|
squigglyDict.set("Subtype", Name.get("Squiggly"));
|
|
|
|
|
squigglyDict.set("Rect", [10, 10, 20, 20]);
|
2020-12-06 05:27:38 +09:00
|
|
|
|
squigglyDict.set("QuadPoints", [10, 20, 20, 20, 10, 10, 20, 10]);
|
2019-07-28 03:57:52 +09:00
|
|
|
|
|
|
|
|
|
const squigglyRef = Ref.get(121, 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
|
|
|
|
const xref = new XRefMock([{ ref: squigglyRef, data: squigglyDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
squigglyRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.SQUIGGLY);
|
|
|
|
|
expect(data.quadPoints).toEqual([
|
|
|
|
|
[
|
2020-12-06 05:27:38 +09:00
|
|
|
|
{ x: 10, y: 20 },
|
|
|
|
|
{ x: 20, y: 20 },
|
|
|
|
|
{ x: 10, y: 10 },
|
|
|
|
|
{ x: 20, y: 10 },
|
2019-07-28 03:57:52 +09:00
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
describe("StrikeOutAnnotation", function () {
|
2020-10-21 19:00:34 +09:00
|
|
|
|
it("should set quadpoints to null if not defined", function (done) {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
const strikeOutDict = new Dict();
|
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
|
|
|
|
strikeOutDict.set("Type", Name.get("Annot"));
|
|
|
|
|
strikeOutDict.set("Subtype", Name.get("StrikeOut"));
|
2019-07-28 03:57:52 +09:00
|
|
|
|
|
|
|
|
|
const strikeOutRef = Ref.get(121, 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
|
|
|
|
const xref = new XRefMock([{ ref: strikeOutRef, data: strikeOutDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
strikeOutRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.STRIKEOUT);
|
2020-10-21 19:00:34 +09:00
|
|
|
|
expect(data.quadPoints).toEqual(null);
|
2019-07-28 03:57:52 +09:00
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
|
it("should set quadpoints if defined", function (done) {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
const strikeOutDict = new Dict();
|
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
|
|
|
|
strikeOutDict.set("Type", Name.get("Annot"));
|
|
|
|
|
strikeOutDict.set("Subtype", Name.get("StrikeOut"));
|
|
|
|
|
strikeOutDict.set("Rect", [10, 10, 20, 20]);
|
2020-12-06 05:27:38 +09:00
|
|
|
|
strikeOutDict.set("QuadPoints", [10, 20, 20, 20, 10, 10, 20, 10]);
|
2019-07-28 03:57:52 +09:00
|
|
|
|
|
|
|
|
|
const strikeOutRef = Ref.get(121, 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
|
|
|
|
const xref = new XRefMock([{ ref: strikeOutRef, data: strikeOutDict }]);
|
|
|
|
|
|
|
|
|
|
AnnotationFactory.create(
|
|
|
|
|
xref,
|
|
|
|
|
strikeOutRef,
|
|
|
|
|
pdfManagerMock,
|
|
|
|
|
idFactoryMock
|
|
|
|
|
).then(({ data }) => {
|
2019-07-28 03:57:52 +09:00
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.STRIKEOUT);
|
|
|
|
|
expect(data.quadPoints).toEqual([
|
|
|
|
|
[
|
2020-12-06 05:27:38 +09:00
|
|
|
|
{ x: 10, y: 20 },
|
|
|
|
|
{ x: 20, y: 20 },
|
|
|
|
|
{ x: 10, y: 10 },
|
|
|
|
|
{ x: 20, y: 10 },
|
2019-07-28 03:57:52 +09:00
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
done();
|
|
|
|
|
}, done.fail);
|
|
|
|
|
});
|
|
|
|
|
});
|
2014-12-26 05:04:01 +09:00
|
|
|
|
});
|