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/sanitize/browser_purgehistory_clears_sh.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/sanitize/browser_purgehistory_clears_sh.js | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/browser/base/content/test/sanitize/browser_purgehistory_clears_sh.js b/browser/base/content/test/sanitize/browser_purgehistory_clears_sh.js new file mode 100644 index 0000000000..5ad7b78d69 --- /dev/null +++ b/browser/base/content/test/sanitize/browser_purgehistory_clears_sh.js @@ -0,0 +1,86 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const url = + "https://example.org/browser/browser/base/content/test/sanitize/dummy_page.html"; + +// We will be removing the ["history"] option once we remove the +// old clear history dialog in Bug 1856418 - Remove all old clear data dialog boxes +let prefs = [["history"], ["historyFormDataAndDownloads"]]; + +for (let itemsToClear of prefs) { + add_task(async function purgeHistoryTest() { + await BrowserTestUtils.withNewTab( + { + gBrowser, + url, + }, + async function purgeHistoryTestInner(browser) { + let backButton = browser.ownerDocument.getElementById("Browser:Back"); + let forwardButton = + browser.ownerDocument.getElementById("Browser:Forward"); + + ok( + !browser.webNavigation.canGoBack, + "Initial value for webNavigation.canGoBack" + ); + ok( + !browser.webNavigation.canGoForward, + "Initial value for webNavigation.canGoBack" + ); + ok(backButton.hasAttribute("disabled"), "Back button is disabled"); + ok( + forwardButton.hasAttribute("disabled"), + "Forward button is disabled" + ); + + await SpecialPowers.spawn(browser, [], async function () { + let startHistory = content.history.length; + content.history.pushState({}, ""); + content.history.pushState({}, ""); + content.history.back(); + await new Promise(function (r) { + content.onpopstate = r; + }); + let newHistory = content.history.length; + Assert.equal(startHistory, 1, "Initial SHistory size"); + Assert.equal(newHistory, 3, "New SHistory size"); + }); + + ok( + browser.webNavigation.canGoBack, + "New value for webNavigation.canGoBack" + ); + ok( + browser.webNavigation.canGoForward, + "New value for webNavigation.canGoForward" + ); + ok(!backButton.hasAttribute("disabled"), "Back button was enabled"); + ok( + !forwardButton.hasAttribute("disabled"), + "Forward button was enabled" + ); + + await Sanitizer.sanitize(itemsToClear); + + await SpecialPowers.spawn(browser, [], async function () { + Assert.equal(content.history.length, 1, "SHistory correctly cleared"); + }); + + ok( + !browser.webNavigation.canGoBack, + "webNavigation.canGoBack correctly cleared" + ); + ok( + !browser.webNavigation.canGoForward, + "webNavigation.canGoForward correctly cleared" + ); + ok(backButton.hasAttribute("disabled"), "Back button was disabled"); + ok( + forwardButton.hasAttribute("disabled"), + "Forward button was disabled" + ); + } + ); + }); +} |