From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../pdfjs/test/browser_pdfjs_minimum_font_size.js | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 toolkit/components/pdfjs/test/browser_pdfjs_minimum_font_size.js (limited to 'toolkit/components/pdfjs/test/browser_pdfjs_minimum_font_size.js') diff --git a/toolkit/components/pdfjs/test/browser_pdfjs_minimum_font_size.js b/toolkit/components/pdfjs/test/browser_pdfjs_minimum_font_size.js new file mode 100644 index 0000000000..f85e0c3ec6 --- /dev/null +++ b/toolkit/components/pdfjs/test/browser_pdfjs_minimum_font_size.js @@ -0,0 +1,70 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const RELATIVE_DIR = "toolkit/components/pdfjs/test/"; +const TESTROOT = "https://example.com/browser/" + RELATIVE_DIR; + +/** + * Test that the pdf doesn't use the minimum font size. + */ +add_task(async function test() { + let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService); + let handlerInfo = mimeService.getFromTypeAndExtension( + "application/pdf", + "pdf" + ); + + // Make sure pdf.js is the default handler. + is( + handlerInfo.alwaysAskBeforeHandling, + false, + "pdf handler defaults to always-ask is false" + ); + is( + handlerInfo.preferredAction, + Ci.nsIHandlerInfo.handleInternally, + "pdf handler defaults to internal" + ); + + info("Pref action: " + handlerInfo.preferredAction); + + await SpecialPowers.pushPrefEnv({ + set: [["font.minimum-size.x-western", 56]], + }); + + await BrowserTestUtils.withNewTab( + { gBrowser, url: "about:blank" }, + async function (browser) { + // check that PDF is opened with internal viewer + await waitForPdfJSAllLayers( + browser, + `${TESTROOT}file_pdfjs_test.pdf#zoom=10`, + [] + ); + + await SpecialPowers.spawn(browser, [true], () => { + const pageNumberInput = content.document.querySelector("#pageNumber"); + const { style } = pageNumberInput; + const baseHeight = + content.document.defaultView.getComputedStyle(pageNumberInput).height; + + style.fontSize = "1px"; + const height = + content.document.defaultView.getComputedStyle(pageNumberInput).height; + + // Changing the font size should change the height of the input + // element. If the minimum font size is used, the height won't change. + Assert.notEqual( + baseHeight, + height, + "The pdf viewer musn't use the minimum font size." + ); + }); + + await SpecialPowers.spawn(browser, [], async function () { + var viewer = content.wrappedJSObject.PDFViewerApplication; + await viewer.close(); + }); + } + ); +}); -- cgit v1.2.3