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/general/browser_invalid_uri_back_forward_manipulation.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 '')
-rw-r--r-- | browser/base/content/test/general/browser_invalid_uri_back_forward_manipulation.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_invalid_uri_back_forward_manipulation.js b/browser/base/content/test/general/browser_invalid_uri_back_forward_manipulation.js new file mode 100644 index 0000000000..1624a1514d --- /dev/null +++ b/browser/base/content/test/general/browser_invalid_uri_back_forward_manipulation.js @@ -0,0 +1,48 @@ +"use strict"; + +/** + * Verify that loading an invalid URI does not clobber a previously-loaded page's history + * entry, but that the invalid URI gets its own history entry instead. We're checking this + * using nsIWebNavigation's canGoBack, as well as actually going back and then checking + * canGoForward. + */ +add_task(async function checkBackFromInvalidURI() { + await pushPrefs(["keyword.enabled", false]); + let tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + "about:robots", + true + ); + info("Loaded about:robots"); + + gURLBar.value = "::2600"; + + let promiseErrorPageLoaded = BrowserTestUtils.waitForErrorPage( + tab.linkedBrowser + ); + gURLBar.handleCommand(); + await promiseErrorPageLoaded; + + ok(gBrowser.webNavigation.canGoBack, "Should be able to go back"); + if (gBrowser.webNavigation.canGoBack) { + // Can't use DOMContentLoaded here because the page is bfcached. Can't use pageshow for + // the error page because it doesn't seem to fire for those. + let promiseOtherPageLoaded = BrowserTestUtils.waitForEvent( + tab.linkedBrowser, + "pageshow", + false, + // Be paranoid we *are* actually seeing this other page load, not some kind of race + // for if/when we do start firing pageshow for the error page... + function (e) { + return gBrowser.currentURI.spec == "about:robots"; + } + ); + gBrowser.goBack(); + await promiseOtherPageLoaded; + ok( + gBrowser.webNavigation.canGoForward, + "Should be able to go forward from previous page." + ); + } + BrowserTestUtils.removeTab(tab); +}); |