--- a/browser/base/content/moz.build
+++ b/browser/base/content/moz.build
@@ -59,16 +59,20 @@ with Files("test/popupNotifications/**")
BUG_COMPONENT = ("Toolkit", "Notifications and Alerts")
with Files("test/popups/**"):
BUG_COMPONENT = ("Toolkit", "Notifications and Alerts")
with Files("test/referrer/**"):
BUG_COMPONENT = ("Core", "Document Navigation")
+# TODO: Update this after bug 1435528 is resolved.
+with Files("test/sanitize/**"):
+ BUG_COMPONENT = ("Firefox", "General")
+
with Files("test/siteIdentity/**"):
BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels")
with Files("test/sidebar/**"):
BUG_COMPONENT = ("Firefox", "General")
with Files("test/static/**"):
BUG_COMPONENT = ("Firefox", "General")
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -117,18 +117,16 @@ skip-if = true # browser_bug321000.js is
[browser_bug380960.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug386835.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug406216.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug408415.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
-[browser_bug409624.js]
-# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug413915.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug416661.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug417483.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug419612.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
@@ -382,18 +380,16 @@ support-files = test_offline_gzip.html g
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_printpreview.js]
skip-if = os == 'win' # Bug 1384127
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_private_browsing_window.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_private_no_prompt.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
-[browser_purgehistory_clears_sh.js]
-# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_PageMetaData_pushstate.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_refreshBlocker.js]
support-files =
refresh_header.sjs
refresh_meta.sjs
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_relatedTabs.js]
@@ -405,24 +401,16 @@ support-files =
test_remoteTroubleshoot.html
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_remoteWebNavigation_postdata.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_removeTabsToTheEnd.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_restore_isAppTab.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
-[browser_sanitize-passwordDisabledHosts.js]
-# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
-[browser_sanitize-sitepermissions.js]
-# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
-[browser_sanitize-timespans.js]
-# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
-[browser_sanitizeDialog.js]
-# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_save_link-perwindowpb.js]
skip-if = e10s && debug && os == "win" # Bug 1280505
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_save_private_link_perwindowpb.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_save_link_when_window_navigates.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_save_video.js]
--- a/browser/base/content/test/general/head.js
+++ b/browser/base/content/test/general/head.js
@@ -291,32 +291,16 @@ function whenTabLoaded(aTab, aCallback)
}
function promiseTabLoaded(aTab) {
return new Promise(resolve => {
whenTabLoaded(aTab, resolve);
});
}
-/**
- * Ensures that the specified URIs are either cleared or not.
- *
- * @param aURIs
- * Array of page URIs
- * @param aShouldBeCleared
- * True if each visit to the URI should be cleared, false otherwise
- */
-async function promiseHistoryClearedState(aURIs, aShouldBeCleared) {
- for (let uri of aURIs) {
- let visited = await PlacesUtils.history.hasVisits(uri);
- Assert.equal(visited, !aShouldBeCleared,
- `history visit ${uri.spec} should ${aShouldBeCleared ? "no longer" : "still"} exist`);
- }
-}
-
var FullZoomHelper = {
selectTabAndWaitForLocationChange: function selectTabAndWaitForLocationChange(tab) {
if (!tab)
throw new Error("tab must be given.");
if (gBrowser.selectedTab == tab)
return Promise.resolve();
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/sanitize/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+ "extends": [
+ "plugin:mozilla/browser-test"
+ ]
+};
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/sanitize/browser.ini
@@ -0,0 +1,11 @@
+[DEFAULT]
+support-files=
+ head.js
+ dummy_page.html
+
+[browser_purgehistory_clears_sh.js]
+[browser_sanitize-formhistory.js]
+[browser_sanitize-passwordDisabledHosts.js]
+[browser_sanitize-sitepermissions.js]
+[browser_sanitize-timespans.js]
+[browser_sanitizeDialog.js]
rename from browser/base/content/test/general/browser_purgehistory_clears_sh.js
rename to browser/base/content/test/sanitize/browser_purgehistory_clears_sh.js
--- a/browser/base/content/test/general/browser_purgehistory_clears_sh.js
+++ b/browser/base/content/test/sanitize/browser_purgehistory_clears_sh.js
@@ -1,12 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
-const url = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
+const url = "http://example.org/browser/browser/base/content/test/sanitize/dummy_page.html";
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");
@@ -30,24 +30,17 @@ add_task(async function purgeHistoryTest
ok(browser.webNavigation.canGoBack, true,
"New value for webNavigation.canGoBack");
ok(browser.webNavigation.canGoForward, true,
"New value for webNavigation.canGoForward");
ok(!backButton.hasAttribute("disabled"), "Back button was enabled");
ok(!forwardButton.hasAttribute("disabled"), "Forward button was enabled");
-
- let tmp = {};
- Services.scriptloader.loadSubScript("chrome://browser/content/sanitize.js", tmp);
-
- let {Sanitizer} = tmp;
- let sanitizer = new Sanitizer();
-
- await sanitizer.sanitize(["history"]);
+ await Sanitizer.sanitize(["history"]);
await ContentTask.spawn(browser, null, async function() {
Assert.equal(content.history.length, 1, "SHistory correctly cleared");
});
ok(!browser.webNavigation.canGoBack,
"webNavigation.canGoBack correctly cleared");
ok(!browser.webNavigation.canGoForward,
rename from browser/base/content/test/general/browser_bug409624.js
rename to browser/base/content/test/sanitize/browser_sanitize-formhistory.js
--- a/browser/base/content/test/general/browser_bug409624.js
+++ b/browser/base/content/test/sanitize/browser_sanitize-formhistory.js
@@ -1,15 +1,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-ChromeUtils.defineModuleGetter(this, "FormHistory",
- "resource://gre/modules/FormHistory.jsm");
-
add_task(async function test() {
// This test relies on the form history being empty to start with delete
// all the items first.
await new Promise((resolve, reject) => {
FormHistory.update({ op: "remove" },
{ handleError(error) {
reject(error);
},
@@ -18,36 +15,19 @@ add_task(async function test() {
resolve();
} else {
reject();
}
},
});
});
- let tempScope = {};
- Services.scriptloader.loadSubScript("chrome://browser/content/sanitize.js", tempScope);
- let Sanitizer = tempScope.Sanitizer;
- let s = new Sanitizer();
- s.prefDomain = "privacy.cpd.";
- let prefBranch = Services.prefs.getBranch(s.prefDomain);
-
- prefBranch.setBoolPref("cache", false);
- prefBranch.setBoolPref("cookies", false);
- prefBranch.setBoolPref("downloads", false);
- prefBranch.setBoolPref("formdata", true);
- prefBranch.setBoolPref("history", false);
- prefBranch.setBoolPref("offlineApps", false);
- prefBranch.setBoolPref("passwords", false);
- prefBranch.setBoolPref("sessions", false);
- prefBranch.setBoolPref("siteSettings", false);
-
// Sanitize now so we can test the baseline point.
- await s.sanitize();
+ await Sanitizer.sanitize(["formdata"]);
ok(!gFindBar.hasTransactions, "pre-test baseline for sanitizer");
gFindBar.getElement("findbar-textbox").value = "m";
ok(gFindBar.hasTransactions, "formdata can be cleared after input");
- await s.sanitize();
+ await Sanitizer.sanitize(["formdata"]);
is(gFindBar.getElement("findbar-textbox").value, "", "findBar textbox should be empty after sanitize");
ok(!gFindBar.hasTransactions, "No transactions after sanitize");
});
rename from browser/base/content/test/general/browser_sanitize-passwordDisabledHosts.js
rename to browser/base/content/test/sanitize/browser_sanitize-passwordDisabledHosts.js
--- a/browser/base/content/test/general/browser_sanitize-passwordDisabledHosts.js
+++ b/browser/base/content/test/sanitize/browser_sanitize-passwordDisabledHosts.js
@@ -1,41 +1,22 @@
// Bug 474792 - Clear "Never remember passwords for this site" when
// clearing site-specific settings in Clear Recent History dialog
-var tempScope = {};
-Services.scriptloader.loadSubScript("chrome://browser/content/sanitize.js", tempScope);
-var Sanitizer = tempScope.Sanitizer;
-
add_task(async function() {
// getLoginSavingEnabled always returns false if password capture is disabled.
await SpecialPowers.pushPrefEnv({"set": [["signon.rememberSignons", true]]});
// Add a disabled host
Services.logins.setLoginSavingEnabled("http://example.com", false);
// Sanity check
is(Services.logins.getLoginSavingEnabled("http://example.com"), false,
"example.com should be disabled for password saving since we haven't cleared that yet.");
- // Set up the sanitizer to just clear siteSettings
- let s = new Sanitizer();
- s.ignoreTimespan = false;
- s.prefDomain = "privacy.cpd.";
- var itemPrefs = Services.prefs.getBranch(s.prefDomain);
- itemPrefs.setBoolPref("history", false);
- itemPrefs.setBoolPref("downloads", false);
- itemPrefs.setBoolPref("cache", false);
- itemPrefs.setBoolPref("cookies", false);
- itemPrefs.setBoolPref("formdata", false);
- itemPrefs.setBoolPref("offlineApps", false);
- itemPrefs.setBoolPref("passwords", false);
- itemPrefs.setBoolPref("sessions", false);
- itemPrefs.setBoolPref("siteSettings", true);
-
// Clear it
- await s.sanitize();
+ await Sanitizer.sanitize(["siteSettings"], {ignoreTimespan: false});
// Make sure it's gone
is(Services.logins.getLoginSavingEnabled("http://example.com"), true,
"example.com should be enabled for password saving again now that we've cleared.");
await SpecialPowers.popPrefEnv();
});
rename from browser/base/content/test/general/browser_sanitize-sitepermissions.js
rename to browser/base/content/test/sanitize/browser_sanitize-sitepermissions.js
--- a/browser/base/content/test/general/browser_sanitize-sitepermissions.js
+++ b/browser/base/content/test/sanitize/browser_sanitize-sitepermissions.js
@@ -1,51 +1,33 @@
// Bug 380852 - Delete permission manager entries in Clear Recent History
-var tempScope = {};
-Services.scriptloader.loadSubScript("chrome://browser/content/sanitize.js", tempScope);
-var Sanitizer = tempScope.Sanitizer;
-
function countPermissions() {
let result = 0;
let enumerator = Services.perms.enumerator;
while (enumerator.hasMoreElements()) {
result++;
enumerator.getNext();
}
return result;
}
add_task(async function test() {
// sanitize before we start so we have a good baseline.
- // Set up the sanitizer to just clear siteSettings
- let s = new Sanitizer();
- s.ignoreTimespan = false;
- s.prefDomain = "privacy.cpd.";
- var itemPrefs = Services.prefs.getBranch(s.prefDomain);
- itemPrefs.setBoolPref("history", false);
- itemPrefs.setBoolPref("downloads", false);
- itemPrefs.setBoolPref("cache", false);
- itemPrefs.setBoolPref("cookies", false);
- itemPrefs.setBoolPref("formdata", false);
- itemPrefs.setBoolPref("offlineApps", false);
- itemPrefs.setBoolPref("passwords", false);
- itemPrefs.setBoolPref("sessions", false);
- itemPrefs.setBoolPref("siteSettings", true);
- s.sanitize();
+ await Sanitizer.sanitize(["siteSettings"], {ignoreTimespan: false});
// Count how many permissions we start with - some are defaults that
// will not be sanitized.
let numAtStart = countPermissions();
// Add a permission entry
var pm = Services.perms;
- pm.add(makeURI("http://example.com"), "testing", pm.ALLOW_ACTION);
+ pm.add(Services.io.newURI("http://example.com"), "testing", pm.ALLOW_ACTION);
// Sanity check
ok(pm.enumerator.hasMoreElements(), "Permission manager should have elements, since we just added one");
// Clear it
- await s.sanitize();
+ await Sanitizer.sanitize(["siteSettings"], {ignoreTimespan: false});
// Make sure it's gone
is(numAtStart, countPermissions(), "Permission manager should have the same count it started with");
});
rename from browser/base/content/test/general/browser_sanitize-timespans.js
rename to browser/base/content/test/sanitize/browser_sanitize-timespans.js
--- a/browser/base/content/test/general/browser_sanitize-timespans.js
+++ b/browser/base/content/test/sanitize/browser_sanitize-timespans.js
@@ -1,27 +1,17 @@
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
-
requestLongerTimeout(2);
// Bug 453440 - Test the timespan-based logic of the sanitizer code
var now_mSec = Date.now();
var now_uSec = now_mSec * 1000;
const kMsecPerMin = 60 * 1000;
const kUsecPerMin = 60 * 1000000;
-var tempScope = {};
-Services.scriptloader.loadSubScript("chrome://browser/content/sanitize.js", tempScope);
-var Sanitizer = tempScope.Sanitizer;
-
-var FormHistory = (ChromeUtils.import("resource://gre/modules/FormHistory.jsm", {})).FormHistory;
-var Downloads = (ChromeUtils.import("resource://gre/modules/Downloads.jsm", {})).Downloads;
-
function promiseFormHistoryRemoved() {
return new Promise(resolve => {
Services.obs.addObserver(function onfh() {
Services.obs.removeObserver(onfh, "satchel-storage-changed");
resolve();
}, "satchel-storage-changed");
});
}
@@ -74,38 +64,34 @@ function countEntries(name, message, che
async function onHistoryReady() {
var hoursSinceMidnight = new Date().getHours();
var minutesSinceMidnight = hoursSinceMidnight * 60 + new Date().getMinutes();
// Should test cookies here, but nsICookieManager/nsICookieService
// doesn't let us fake creation times. bug 463127
- let s = new Sanitizer();
- s.ignoreTimespan = false;
- s.prefDomain = "privacy.cpd.";
- var itemPrefs = Services.prefs.getBranch(s.prefDomain);
+ var itemPrefs = Services.prefs.getBranch("privacy.cpd.");
itemPrefs.setBoolPref("history", true);
itemPrefs.setBoolPref("downloads", true);
itemPrefs.setBoolPref("cache", false);
itemPrefs.setBoolPref("cookies", false);
itemPrefs.setBoolPref("formdata", true);
itemPrefs.setBoolPref("offlineApps", false);
itemPrefs.setBoolPref("passwords", false);
itemPrefs.setBoolPref("sessions", false);
itemPrefs.setBoolPref("siteSettings", false);
let publicList = await Downloads.getList(Downloads.PUBLIC);
let downloadPromise = promiseDownloadRemoved(publicList);
let formHistoryPromise = promiseFormHistoryRemoved();
// Clear 10 minutes ago
- s.range = [now_uSec - 10 * 60 * 1000000, now_uSec];
- await s.sanitize();
- s.range = null;
+ let range = [now_uSec - 10 * 60 * 1000000, now_uSec];
+ await Sanitizer.sanitize(null, {range, ignoreTimespan: false});
await formHistoryPromise;
await downloadPromise;
ok(!(await PlacesUtils.history.hasVisits("http://10minutes.com")),
"Pretend visit to 10minutes.com should now be deleted");
ok((await PlacesUtils.history.hasVisits("http://1hour.com")),
"Pretend visit to 1hour.com should should still exist");
@@ -151,18 +137,18 @@ async function onHistoryReady() {
if (minutesSinceMidnight > 10)
ok((await downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
downloadPromise = promiseDownloadRemoved(publicList);
formHistoryPromise = promiseFormHistoryRemoved();
// Clear 1 hour
- Sanitizer.prefs.setIntPref("timeSpan", 1);
- await s.sanitize();
+ Services.prefs.setIntPref(Sanitizer.PREF_TIMESPAN, 1);
+ await Sanitizer.sanitize(null, {ignoreTimespan: false});
await formHistoryPromise;
await downloadPromise;
ok(!(await PlacesUtils.history.hasVisits("http://1hour.com")),
"Pretend visit to 1hour.com should now be deleted");
ok((await PlacesUtils.history.hasVisits("http://1hour10minutes.com")),
"Pretend visit to 1hour10minutes.com should should still exist");
@@ -201,19 +187,18 @@ async function onHistoryReady() {
if (hoursSinceMidnight > 1)
ok((await downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
downloadPromise = promiseDownloadRemoved(publicList);
formHistoryPromise = promiseFormHistoryRemoved();
// Clear 1 hour 10 minutes
- s.range = [now_uSec - 70 * 60 * 1000000, now_uSec];
- await s.sanitize();
- s.range = null;
+ range = [now_uSec - 70 * 60 * 1000000, now_uSec];
+ await Sanitizer.sanitize(null, {range, ignoreTimespan: false});
await formHistoryPromise;
await downloadPromise;
ok(!(await PlacesUtils.history.hasVisits("http://1hour10minutes.com")),
"Pretend visit to 1hour10minutes.com should now be deleted");
ok((await PlacesUtils.history.hasVisits("http://2hour.com")),
"Pretend visit to 2hour.com should should still exist");
@@ -247,18 +232,18 @@ async function onHistoryReady() {
ok((await downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present");
if (minutesSinceMidnight > 70)
ok((await downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
downloadPromise = promiseDownloadRemoved(publicList);
formHistoryPromise = promiseFormHistoryRemoved();
// Clear 2 hours
- Sanitizer.prefs.setIntPref("timeSpan", 2);
- await s.sanitize();
+ Services.prefs.setIntPref(Sanitizer.PREF_TIMESPAN, 2);
+ await Sanitizer.sanitize(null, {ignoreTimespan: false});
await formHistoryPromise;
await downloadPromise;
ok(!(await PlacesUtils.history.hasVisits("http://2hour.com")),
"Pretend visit to 2hour.com should now be deleted");
ok((await PlacesUtils.history.hasVisits("http://2hour10minutes.com")),
"Pretend visit to 2hour10minutes.com should should still exist");
@@ -288,19 +273,18 @@ async function onHistoryReady() {
ok((await downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present");
if (hoursSinceMidnight > 2)
ok((await downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
downloadPromise = promiseDownloadRemoved(publicList);
formHistoryPromise = promiseFormHistoryRemoved();
// Clear 2 hours 10 minutes
- s.range = [now_uSec - 130 * 60 * 1000000, now_uSec];
- await s.sanitize();
- s.range = null;
+ range = [now_uSec - 130 * 60 * 1000000, now_uSec];
+ await Sanitizer.sanitize(null, {range, ignoreTimespan: false});
await formHistoryPromise;
await downloadPromise;
ok(!(await PlacesUtils.history.hasVisits("http://2hour10minutes.com")),
"Pretend visit to 2hour10minutes.com should now be deleted");
ok((await PlacesUtils.history.hasVisits("http://4hour.com")),
"Pretend visit to 4hour.com should should still exist");
@@ -326,18 +310,18 @@ async function onHistoryReady() {
ok((await downloadExists(publicList, "fakefile-old")), "Year old download should still be present");
if (minutesSinceMidnight > 130)
ok((await downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
downloadPromise = promiseDownloadRemoved(publicList);
formHistoryPromise = promiseFormHistoryRemoved();
// Clear 4 hours
- Sanitizer.prefs.setIntPref("timeSpan", 3);
- await s.sanitize();
+ Services.prefs.setIntPref(Sanitizer.PREF_TIMESPAN, 3);
+ await Sanitizer.sanitize(null, {ignoreTimespan: false});
await formHistoryPromise;
await downloadPromise;
ok(!(await PlacesUtils.history.hasVisits("http://4hour.com")),
"Pretend visit to 4hour.com should now be deleted");
ok((await PlacesUtils.history.hasVisits("http://4hour10minutes.com")),
"Pretend visit to 4hour10minutes.com should should still exist");
@@ -359,19 +343,18 @@ async function onHistoryReady() {
ok((await downloadExists(publicList, "fakefile-old")), "Year old download should still be present");
if (hoursSinceMidnight > 4)
ok((await downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
downloadPromise = promiseDownloadRemoved(publicList);
formHistoryPromise = promiseFormHistoryRemoved();
// Clear 4 hours 10 minutes
- s.range = [now_uSec - 250 * 60 * 1000000, now_uSec];
- await s.sanitize();
- s.range = null;
+ range = [now_uSec - 250 * 60 * 1000000, now_uSec];
+ await Sanitizer.sanitize(null, {range, ignoreTimespan: false});
await formHistoryPromise;
await downloadPromise;
ok(!(await PlacesUtils.history.hasVisits("http://4hour10minutes.com")),
"Pretend visit to 4hour10minutes.com should now be deleted");
if (minutesSinceMidnight > 250) {
ok((await PlacesUtils.history.hasVisits("http://today.com")),
@@ -395,18 +378,18 @@ async function onHistoryReady() {
if (minutesSinceMidnight > 250) {
downloadPromise = promiseDownloadRemoved(publicList);
formHistoryPromise = promiseFormHistoryRemoved();
} else {
downloadPromise = formHistoryPromise = Promise.resolve();
}
// Clear Today
- Sanitizer.prefs.setIntPref("timeSpan", 4);
- await s.sanitize();
+ Services.prefs.setIntPref(Sanitizer.PREF_TIMESPAN, 4);
+ await Sanitizer.sanitize(null, {ignoreTimespan: false});
await formHistoryPromise;
await downloadPromise;
// Be careful. If we add our objectss just before midnight, and sanitize
// runs immediately after, they won't be expired. This is expected, but
// we should not test in that case. We cannot just test for opposite
// condition because we could cross midnight just one moment after we
@@ -424,18 +407,18 @@ async function onHistoryReady() {
"Pretend visit to before-today.com should still exist");
await countEntries("b4today", "b4today form entry should still exist", checkOne);
ok((await downloadExists(publicList, "fakefile-old")), "Year old download should still be present");
downloadPromise = promiseDownloadRemoved(publicList);
formHistoryPromise = promiseFormHistoryRemoved();
// Choose everything
- Sanitizer.prefs.setIntPref("timeSpan", 0);
- await s.sanitize();
+ Services.prefs.setIntPref(Sanitizer.PREF_TIMESPAN, 0);
+ await Sanitizer.sanitize(null, {ignoreTimespan: false});
await formHistoryPromise;
await downloadPromise;
ok(!(await PlacesUtils.history.hasVisits("http://before-today.com")),
"Pretend visit to before-today.com should now be deleted");
await countEntries("b4today", "b4today form entry should be deleted", checkZero);
rename from browser/base/content/test/general/browser_sanitizeDialog.js
rename to browser/base/content/test/sanitize/browser_sanitizeDialog.js
--- a/browser/base/content/test/general/browser_sanitizeDialog.js
+++ b/browser/base/content/test/sanitize/browser_sanitizeDialog.js
@@ -4,41 +4,49 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Tests the sanitize dialog (a.k.a. the clear recent history dialog).
* See bug 480169.
*
* The purpose of this test is not to fully flex the sanitize timespan code;
- * browser/base/content/test/general/browser_sanitize-timespans.js does that. This
+ * browser/base/content/test/sanitize/browser_sanitize-timespans.js does that. This
* test checks the UI of the dialog and makes sure it's correctly connected to
* the sanitize timespan code.
*
* Some of this code, especially the history creation parts, was taken from
- * browser/base/content/test/general/browser_sanitize-timespans.js.
+ * browser/base/content/test/sanitize/browser_sanitize-timespans.js.
*/
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.defineModuleGetter(this, "FormHistory",
- "resource://gre/modules/FormHistory.jsm");
-ChromeUtils.defineModuleGetter(this, "Downloads",
- "resource://gre/modules/Downloads.jsm");
ChromeUtils.defineModuleGetter(this, "Timer",
"resource://gre/modules/Timer.jsm");
ChromeUtils.defineModuleGetter(this, "PlacesTestUtils",
"resource://testing-common/PlacesTestUtils.jsm");
-var tempScope = {};
-Services.scriptloader.loadSubScript("chrome://browser/content/sanitize.js", tempScope);
-var Sanitizer = tempScope.Sanitizer;
-
const kMsecPerMin = 60 * 1000;
const kUsecPerMin = 60 * 1000000;
+/**
+ * Ensures that the specified URIs are either cleared or not.
+ *
+ * @param aURIs
+ * Array of page URIs
+ * @param aShouldBeCleared
+ * True if each visit to the URI should be cleared, false otherwise
+ */
+async function promiseHistoryClearedState(aURIs, aShouldBeCleared) {
+ for (let uri of aURIs) {
+ let visited = await PlacesUtils.history.hasVisits(uri);
+ Assert.equal(visited, !aShouldBeCleared,
+ `history visit ${uri.spec} should ${aShouldBeCleared ? "no longer" : "still"} exist`);
+ }
+}
+
add_task(async function init() {
requestLongerTimeout(3);
await blankSlate();
registerCleanupFunction(async function() {
await blankSlate();
await PlacesTestUtils.promiseAsyncUpdates();
});
});
@@ -854,17 +862,17 @@ WindowHelper.prototype = {
* Toggles the details progressive disclosure button.
*/
toggleDetails() {
this.getDetailsButton().click();
}
};
function promiseSanitizationComplete() {
- return promiseTopicObserved("sanitizer-sanitization-complete");
+ return TestUtils.topicObserved("sanitizer-sanitization-complete");
}
/**
* Adds a download to history.
*
* @param aMinutesAgo
* The download will be downloaded this many minutes ago
*/
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/sanitize/dummy_page.html
@@ -0,0 +1,9 @@
+<html>
+<head>
+<title>Dummy test page</title>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"></meta>
+</head>
+<body>
+<p>Dummy test page</p>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/sanitize/head.js
@@ -0,0 +1,9 @@
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetters(this, {
+ Downloads: "resource://gre/modules/Downloads.jsm",
+ FormHistory: "resource://gre/modules/FormHistory.jsm",
+ PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
+ Sanitizer: "resource:///modules/Sanitizer.jsm",
+});
+