browser/base/content/test/newtab/browser_newtab_bug722273.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 const NOW = Date.now() * 1000;
michael@0 5 const URL = "http://fake-site.com/";
michael@0 6
michael@0 7 let tmp = {};
michael@0 8 Cc["@mozilla.org/moz/jssubscript-loader;1"]
michael@0 9 .getService(Ci.mozIJSSubScriptLoader)
michael@0 10 .loadSubScript("chrome://browser/content/sanitize.js", tmp);
michael@0 11
michael@0 12 let {Sanitizer} = tmp;
michael@0 13
michael@0 14 function runTests() {
michael@0 15 sanitizeHistory();
michael@0 16 yield addFakeVisits();
michael@0 17 yield addNewTabPageTab();
michael@0 18
michael@0 19 is(getCell(0).site.url, URL, "first site is our fake site");
michael@0 20
michael@0 21 whenPagesUpdated();
michael@0 22 yield sanitizeHistory();
michael@0 23
michael@0 24 ok(!getCell(0).site, "the fake site is gone");
michael@0 25 }
michael@0 26
michael@0 27 function addFakeVisits() {
michael@0 28 let visits = [];
michael@0 29 for (let i = 59; i > 0; i--) {
michael@0 30 visits.push({
michael@0 31 visitDate: NOW - i * 60 * 1000000,
michael@0 32 transitionType: Ci.nsINavHistoryService.TRANSITION_LINK
michael@0 33 });
michael@0 34 }
michael@0 35 let place = {
michael@0 36 uri: makeURI(URL),
michael@0 37 title: "fake site",
michael@0 38 visits: visits
michael@0 39 };
michael@0 40 PlacesUtils.asyncHistory.updatePlaces(place, {
michael@0 41 handleError: function () ok(false, "couldn't add visit"),
michael@0 42 handleResult: function () {},
michael@0 43 handleCompletion: function () {
michael@0 44 NewTabUtils.links.populateCache(function () {
michael@0 45 NewTabUtils.allPages.update();
michael@0 46 TestRunner.next();
michael@0 47 }, true);
michael@0 48 }
michael@0 49 });
michael@0 50 }
michael@0 51
michael@0 52 function sanitizeHistory() {
michael@0 53 let s = new Sanitizer();
michael@0 54 s.prefDomain = "privacy.cpd.";
michael@0 55
michael@0 56 let prefs = gPrefService.getBranch(s.prefDomain);
michael@0 57 prefs.setBoolPref("history", true);
michael@0 58 prefs.setBoolPref("downloads", false);
michael@0 59 prefs.setBoolPref("cache", false);
michael@0 60 prefs.setBoolPref("cookies", false);
michael@0 61 prefs.setBoolPref("formdata", false);
michael@0 62 prefs.setBoolPref("offlineApps", false);
michael@0 63 prefs.setBoolPref("passwords", false);
michael@0 64 prefs.setBoolPref("sessions", false);
michael@0 65 prefs.setBoolPref("siteSettings", false);
michael@0 66
michael@0 67 s.sanitize();
michael@0 68 }

mercurial