|
| 1 | +/* Copyright 2026 Mozilla Foundation |
| 2 | + * |
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. |
| 5 | + * You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software |
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | + * See the License for the specific language governing permissions and |
| 13 | + * limitations under the License. |
| 14 | + */ |
| 15 | + |
| 16 | +import { closePages, FSI, loadAndWait, PDI } from "./test_utils.mjs"; |
| 17 | + |
| 18 | +describe("Digital signatures", () => { |
| 19 | + describe("Document without signatures", () => { |
| 20 | + let pages; |
| 21 | + |
| 22 | + beforeEach(async () => { |
| 23 | + pages = await loadAndWait("tracemonkey.pdf", ".textLayer .endOfContent"); |
| 24 | + }); |
| 25 | + |
| 26 | + afterEach(async () => { |
| 27 | + await closePages(pages); |
| 28 | + }); |
| 29 | + |
| 30 | + it("check that the signatureProperties button is hidden", async () => { |
| 31 | + await Promise.all( |
| 32 | + pages.map(async ([browserName, page]) => { |
| 33 | + const buttonHidden = await page.$eval( |
| 34 | + "#signatureProperties", |
| 35 | + el => el.hidden |
| 36 | + ); |
| 37 | + expect(buttonHidden).withContext(`In ${browserName}`).toBeTrue(); |
| 38 | + |
| 39 | + const separatorHidden = await page.$eval( |
| 40 | + "#signaturePropertiesSeparator", |
| 41 | + el => el.hidden |
| 42 | + ); |
| 43 | + expect(separatorHidden).withContext(`In ${browserName}`).toBeTrue(); |
| 44 | + }) |
| 45 | + ); |
| 46 | + }); |
| 47 | + }); |
| 48 | + |
| 49 | + describe("Document with signatures", () => { |
| 50 | + let pages; |
| 51 | + |
| 52 | + beforeEach(async () => { |
| 53 | + pages = await loadAndWait("issue20433.pdf", ".textLayer .endOfContent"); |
| 54 | + }); |
| 55 | + |
| 56 | + afterEach(async () => { |
| 57 | + await closePages(pages); |
| 58 | + }); |
| 59 | + |
| 60 | + it("check that the signatureProperties button is visible", async () => { |
| 61 | + await Promise.all( |
| 62 | + pages.map(async ([browserName, page]) => { |
| 63 | + const buttonHidden = await page.$eval( |
| 64 | + "#signatureProperties", |
| 65 | + el => el.hidden |
| 66 | + ); |
| 67 | + expect(buttonHidden).withContext(`In ${browserName}`).toBeFalse(); |
| 68 | + |
| 69 | + const separatorHidden = await page.$eval( |
| 70 | + "#signaturePropertiesSeparator", |
| 71 | + el => el.hidden |
| 72 | + ); |
| 73 | + expect(separatorHidden).withContext(`In ${browserName}`).toBeFalse(); |
| 74 | + }) |
| 75 | + ); |
| 76 | + }); |
| 77 | + |
| 78 | + it("check that the signatureProperties panel contains two signatures", async () => { |
| 79 | + await Promise.all( |
| 80 | + pages.map(async ([browserName, page]) => { |
| 81 | + await page.click("#signatureProperties"); |
| 82 | + await page.waitForSelector("#signaturePropertiesPanel", { |
| 83 | + hidden: false, |
| 84 | + }); |
| 85 | + |
| 86 | + await page.waitForFunction( |
| 87 | + `document.getElementById("signaturePropertiesBanner").textContent !== ""` |
| 88 | + ); |
| 89 | + const bannerMsg = await page.$eval( |
| 90 | + "#signaturePropertiesBanner", |
| 91 | + el => el.textContent |
| 92 | + ); |
| 93 | + expect(bannerMsg) |
| 94 | + .withContext(`In ${browserName}`) |
| 95 | + .toEqual( |
| 96 | + `Document signed but ${FSI}2${PDI} digital signatures could not be verified` |
| 97 | + ); |
| 98 | + |
| 99 | + await page.keyboard.press("Escape"); |
| 100 | + await page.waitForSelector("#signaturePropertiesPanel", { |
| 101 | + hidden: true, |
| 102 | + }); |
| 103 | + }) |
| 104 | + ); |
| 105 | + }); |
| 106 | + }); |
| 107 | +}); |
0 commit comments