1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
5 "https://example.org/browser/browser/base/content/test/sanitize/dummy_page.html";
7 // We will be removing the ["history"] option once we remove the
8 // old clear history dialog in Bug 1856418 - Remove all old clear data dialog boxes
9 let prefs = [["history"], ["historyAndFormData"]];
11 for (let itemsToClear of prefs) {
12 add_task(async function purgeHistoryTest() {
13 await BrowserTestUtils.withNewTab(
18 async function purgeHistoryTestInner(browser) {
19 let backButton = browser.ownerDocument.getElementById("Browser:Back");
21 browser.ownerDocument.getElementById("Browser:Forward");
24 !browser.webNavigation.canGoBack,
25 "Initial value for webNavigation.canGoBack"
28 !browser.webNavigation.canGoForward,
29 "Initial value for webNavigation.canGoBack"
31 ok(backButton.hasAttribute("disabled"), "Back button is disabled");
33 forwardButton.hasAttribute("disabled"),
34 "Forward button is disabled"
37 await SpecialPowers.spawn(browser, [], async function () {
38 let startHistory = content.history.length;
39 content.history.pushState({}, "");
40 content.history.pushState({}, "");
41 content.history.back();
42 await new Promise(function (r) {
43 content.onpopstate = r;
45 let newHistory = content.history.length;
46 Assert.equal(startHistory, 1, "Initial SHistory size");
47 Assert.equal(newHistory, 3, "New SHistory size");
51 browser.webNavigation.canGoBack,
52 "New value for webNavigation.canGoBack"
55 browser.webNavigation.canGoForward,
56 "New value for webNavigation.canGoForward"
58 ok(!backButton.hasAttribute("disabled"), "Back button was enabled");
60 !forwardButton.hasAttribute("disabled"),
61 "Forward button was enabled"
64 await Sanitizer.sanitize(itemsToClear);
66 await SpecialPowers.spawn(browser, [], async function () {
67 Assert.equal(content.history.length, 1, "SHistory correctly cleared");
71 !browser.webNavigation.canGoBack,
72 "webNavigation.canGoBack correctly cleared"
75 !browser.webNavigation.canGoForward,
76 "webNavigation.canGoForward correctly cleared"
78 ok(backButton.hasAttribute("disabled"), "Back button was disabled");
80 forwardButton.hasAttribute("disabled"),
81 "Forward button was disabled"