diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/base/content/test/siteIdentity/browser_check_identity_state_pdf.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/base/content/test/siteIdentity/browser_check_identity_state_pdf.js | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/browser/base/content/test/siteIdentity/browser_check_identity_state_pdf.js b/browser/base/content/test/siteIdentity/browser_check_identity_state_pdf.js new file mode 100644 index 0000000000..8180238e84 --- /dev/null +++ b/browser/base/content/test/siteIdentity/browser_check_identity_state_pdf.js @@ -0,0 +1,77 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* + * Tests that sites opened via the PDF viewer have the correct identity state. + */ + +"use strict"; + +function testIdentityMode(uri, expectedState, message) { + return BrowserTestUtils.withNewTab(uri, () => { + is(getIdentityMode(), expectedState, message); + }); +} + +/** + * Test site identity state for PDFs served via file URI. + */ +add_task(async function test_pdf_fileURI() { + let path = getTestFilePath("./file_pdf.pdf"); + info("path:" + path); + + await testIdentityMode( + path, + "localResource", + "Identity should be localResource for a PDF served via file URI" + ); +}); + +/** + * Test site identity state for PDFs served via blob URI. + */ +add_task(async function test_pdf_blobURI() { + let uri = + getRootDirectory(gTestPath).replace( + "chrome://mochitests/content", + "https://example.com" + ) + "file_pdf_blob.html"; + + await BrowserTestUtils.withNewTab(uri, async browser => { + let newTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, null, true); + + await BrowserTestUtils.synthesizeMouseAtCenter("a", {}, browser); + await newTabOpened; + + is( + getIdentityMode(), + "localResource", + "Identity should be localResource for a PDF served via blob URI" + ); + + BrowserTestUtils.removeTab(gBrowser.selectedTab); + }); +}); + +/** + * Test site identity state for PDFs served via HTTP. + */ +add_task(async function test_pdf_http() { + const PDF_URI_NOSCHEME = + getRootDirectory(gTestPath).replace( + "chrome://mochitests/content", + "example.com" + ) + "file_pdf.pdf"; + + await testIdentityMode( + // eslint-disable-next-line @microsoft/sdl/no-insecure-url + "http://" + PDF_URI_NOSCHEME, + "notSecure", + "Identity should be notSecure for a PDF served via HTTP." + ); + await testIdentityMode( + "https://" + PDF_URI_NOSCHEME, + "verifiedDomain", + "Identity should be verifiedDomain for a PDF served via HTTPS." + ); +}); |