diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/base/content/test/about/browser_aboutCertError_offlineSupport.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/about/browser_aboutCertError_offlineSupport.js')
-rw-r--r-- | browser/base/content/test/about/browser_aboutCertError_offlineSupport.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/browser/base/content/test/about/browser_aboutCertError_offlineSupport.js b/browser/base/content/test/about/browser_aboutCertError_offlineSupport.js new file mode 100644 index 0000000000..bed9517e34 --- /dev/null +++ b/browser/base/content/test/about/browser_aboutCertError_offlineSupport.js @@ -0,0 +1,52 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const BAD_CERT_PAGE = "https://expired.example.com"; +const DUMMY_SUPPORT_BASE_PATH = "/1/firefox/fxVersion/OSVersion/language/"; +const DUMMY_SUPPORT_URL = BAD_CERT_PAGE + DUMMY_SUPPORT_BASE_PATH; +const OFFLINE_SUPPORT_PAGE = + "chrome://global/content/neterror/supportpages/time-errors.html"; + +add_task(async function testOfflineSupportPage() { + // Cache the original value of app.support.baseURL pref to reset later + let originalBaseURL = Services.prefs.getCharPref("app.support.baseURL"); + + Services.prefs.setCharPref("app.support.baseURL", DUMMY_SUPPORT_URL); + let errorTab = await openErrorPage(BAD_CERT_PAGE); + + let offlineSupportPromise = BrowserTestUtils.waitForNewTab( + gBrowser, + DUMMY_SUPPORT_URL + "time-errors" + ); + await SpecialPowers.spawn( + errorTab.linkedBrowser, + [DUMMY_SUPPORT_URL], + async expectedURL => { + let doc = content.document; + + let learnMoreLink = doc.getElementById("learnMoreLink"); + let supportPageURL = learnMoreLink.getAttribute("href"); + Assert.equal( + supportPageURL, + expectedURL + "time-errors", + "Correct support page URL has been set" + ); + await EventUtils.synthesizeMouseAtCenter(learnMoreLink, {}, content); + } + ); + let offlineSupportTab = await offlineSupportPromise; + await BrowserTestUtils.browserLoaded( + gBrowser.selectedBrowser, + false, + OFFLINE_SUPPORT_PAGE + ); + + // Reset this pref instead of clearing it to maintain globally set + // custom value for testing purposes. + Services.prefs.setCharPref("app.support.baseURL", originalBaseURL); + + await BrowserTestUtils.removeTab(offlineSupportTab); + await BrowserTestUtils.removeTab(errorTab); +}); |