mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset ad37c208588d (bug 722273)
This commit is contained in:
parent
8a0184cb67
commit
0ff4e9ef3a
@ -20,7 +20,6 @@ _BROWSER_FILES = \
|
||||
browser_newtab_reset.js \
|
||||
browser_newtab_tabsync.js \
|
||||
browser_newtab_unpin.js \
|
||||
browser_newtab_bug722273.js \
|
||||
browser_newtab_bug723102.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
@ -1,62 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const NOW = Date.now() * 1000;
|
||||
const URL = "http://fake-site.com/";
|
||||
|
||||
let tmp = {};
|
||||
Cu.import("resource:///modules/NewTabUtils.jsm", tmp);
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://browser/content/sanitize.js", tmp);
|
||||
|
||||
let {NewTabUtils, Sanitizer} = tmp;
|
||||
|
||||
let bhist = Cc["@mozilla.org/browser/global-history;2"]
|
||||
.getService(Ci.nsIBrowserHistory);
|
||||
|
||||
function runTests() {
|
||||
clearHistory();
|
||||
fillHistory();
|
||||
yield addNewTabPageTab();
|
||||
|
||||
is(cells[0].site.url, URL, "first site is our fake site");
|
||||
|
||||
let page = {
|
||||
update: function () {
|
||||
executeSoon(TestRunner.next);
|
||||
},
|
||||
|
||||
observe: function () {}
|
||||
};
|
||||
|
||||
NewTabUtils.allPages.register(page);
|
||||
yield clearHistory();
|
||||
|
||||
NewTabUtils.allPages.unregister(page);
|
||||
ok(!cells[0].site, "the fake site is gone");
|
||||
}
|
||||
|
||||
function fillHistory() {
|
||||
let uri = makeURI(URL);
|
||||
for (let i = 59; i > 0; i--)
|
||||
bhist.addPageWithDetails(uri, "fake site", NOW - i * 60 * 1000000);
|
||||
}
|
||||
|
||||
function clearHistory() {
|
||||
let s = new Sanitizer();
|
||||
s.prefDomain = "privacy.cpd.";
|
||||
|
||||
let prefs = gPrefService.getBranch(s.prefDomain);
|
||||
prefs.setBoolPref("history", true);
|
||||
prefs.setBoolPref("downloads", false);
|
||||
prefs.setBoolPref("cache", false);
|
||||
prefs.setBoolPref("cookies", false);
|
||||
prefs.setBoolPref("formdata", false);
|
||||
prefs.setBoolPref("offlineApps", false);
|
||||
prefs.setBoolPref("passwords", false);
|
||||
prefs.setBoolPref("sessions", false);
|
||||
prefs.setBoolPref("siteSettings", false);
|
||||
|
||||
s.sanitize();
|
||||
}
|
@ -132,9 +132,7 @@ function addNewTabPageTab() {
|
||||
cells = cw.gGrid.cells;
|
||||
|
||||
// Continue when the link cache has been populated.
|
||||
NewTabUtils.links.populateCache(function () {
|
||||
executeSoon(TestRunner.next);
|
||||
});
|
||||
NewTabUtils.links.populateCache(TestRunner.next);
|
||||
} else {
|
||||
TestRunner.next();
|
||||
}
|
||||
|
@ -121,6 +121,8 @@ let Storage = {
|
||||
// want any data from private browsing to show up.
|
||||
PinnedLinks.resetCache();
|
||||
BlockedLinks.resetCache();
|
||||
|
||||
Pages.update();
|
||||
}
|
||||
},
|
||||
|
||||
@ -185,6 +187,11 @@ let AllPages = {
|
||||
*/
|
||||
_pages: [],
|
||||
|
||||
/**
|
||||
* Tells whether we already added a preference observer.
|
||||
*/
|
||||
_observing: false,
|
||||
|
||||
/**
|
||||
* Cached value that tells whether the New Tab Page feature is enabled.
|
||||
*/
|
||||
@ -196,7 +203,12 @@ let AllPages = {
|
||||
*/
|
||||
register: function AllPages_register(aPage) {
|
||||
this._pages.push(aPage);
|
||||
this._addObserver();
|
||||
|
||||
// Add the preference observer if we haven't already.
|
||||
if (!this._observing) {
|
||||
this._observing = true;
|
||||
Services.prefs.addObserver(PREF_NEWTAB_ENABLED, this, true);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -226,14 +238,6 @@ let AllPages = {
|
||||
Services.prefs.setBoolPref(PREF_NEWTAB_ENABLED, !!aEnabled);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the number of registered New Tab Pages (i.e. the number of open
|
||||
* about:newtab instances).
|
||||
*/
|
||||
get length() {
|
||||
return this._pages.length;
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates all currently active pages but the given one.
|
||||
* @param aExceptPage The page to exclude from updating.
|
||||
@ -260,15 +264,6 @@ let AllPages = {
|
||||
}, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a preference observer and turns itself into a no-op after the first
|
||||
* invokation.
|
||||
*/
|
||||
_addObserver: function AllPages_addObserver() {
|
||||
Services.prefs.addObserver(PREF_NEWTAB_ENABLED, this, true);
|
||||
this._addObserver = function () {};
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference])
|
||||
};
|
||||
@ -517,8 +512,6 @@ let Links = {
|
||||
this._links = aLinks;
|
||||
executeCallbacks();
|
||||
}.bind(this));
|
||||
|
||||
this._addObserver();
|
||||
}
|
||||
},
|
||||
|
||||
@ -550,33 +543,8 @@ let Links = {
|
||||
* Resets the links cache.
|
||||
*/
|
||||
resetCache: function Links_resetCache() {
|
||||
this._links = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Implements the nsIObserver interface to get notified about browser history
|
||||
* sanitization.
|
||||
*/
|
||||
observe: function Storage_observe(aSubject, aTopic, aData) {
|
||||
// Make sure to update open about:newtab instances. If there are no opened
|
||||
// pages we can just wait for the next new tab to populate the cache again.
|
||||
if (AllPages.length && AllPages.enabled)
|
||||
this.populateCache(function () { AllPages.update() }, true);
|
||||
else
|
||||
this._links = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a sanitization observer and turns itself into a no-op after the first
|
||||
* invokation.
|
||||
*/
|
||||
_addObserver: function AllPages_addObserver() {
|
||||
Services.obs.addObserver(this, "browser:purge-session-history", true);
|
||||
this._addObserver = function () {};
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference])
|
||||
this._links = [];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user