Merge pull request #11835 from Snuffleupagus/PageViewport-rotation-validation
[api-minor] Change `PageViewport` to throw when the `rotation` is not a multiple of 90 degrees
This commit is contained in:
commit
c8feea6990
@ -245,13 +245,16 @@ class PageViewport {
|
|||||||
rotateC = -1;
|
rotateC = -1;
|
||||||
rotateD = 0;
|
rotateD = 0;
|
||||||
break;
|
break;
|
||||||
// case 0:
|
case 0:
|
||||||
default:
|
|
||||||
rotateA = 1;
|
rotateA = 1;
|
||||||
rotateB = 0;
|
rotateB = 0;
|
||||||
rotateC = 0;
|
rotateC = 0;
|
||||||
rotateD = -1;
|
rotateD = -1;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(
|
||||||
|
"PageViewport: Invalid rotation, must be a multiple of 90 degrees."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dontFlip) {
|
if (dontFlip) {
|
||||||
|
@ -1427,6 +1427,16 @@ describe("api", function () {
|
|||||||
expect(viewport.transform).toEqual([1, 0, 0, -1, 0, 841.89]);
|
expect(viewport.transform).toEqual([1, 0, 0, -1, 0, 841.89]);
|
||||||
expect(dontFlipViewport.transform).toEqual([1, 0, -0, 1, 0, 0]);
|
expect(dontFlipViewport.transform).toEqual([1, 0, -0, 1, 0, 0]);
|
||||||
});
|
});
|
||||||
|
it("gets viewport with invalid rotation", function () {
|
||||||
|
expect(function () {
|
||||||
|
page.getViewport({ scale: 1, rotation: 45 });
|
||||||
|
}).toThrow(
|
||||||
|
new Error(
|
||||||
|
"PageViewport: Invalid rotation, must be a multiple of 90 degrees."
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("gets annotations", function (done) {
|
it("gets annotations", function (done) {
|
||||||
var defaultPromise = page.getAnnotations().then(function (data) {
|
var defaultPromise = page.getAnnotations().then(function (data) {
|
||||||
expect(data.length).toEqual(4);
|
expect(data.length).toEqual(4);
|
||||||
|
Loading…
Reference in New Issue
Block a user