mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Merge backout. a=bustage
This commit is contained in:
commit
8d066e2967
@ -137,54 +137,6 @@ var gTestSteps = [
|
||||
}, true);
|
||||
tab.linkedBrowser.loadURI('about:robots');
|
||||
},
|
||||
function() {
|
||||
info("Running step 9 - enter private browsing mode, without keeping session");
|
||||
let ps = Services.prefs;
|
||||
ps.setBoolPref("browser.privatebrowsing.keep_current_session", false);
|
||||
ps.setBoolPref("browser.tabs.warnOnClose", false);
|
||||
|
||||
Services.obs.addObserver(function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(arguments.callee, "private-browsing-transition-complete");
|
||||
|
||||
for (let i = 0; i < gBrowser.tabs.length; i++)
|
||||
waitForRestoredTab(gBrowser.tabs[i]);
|
||||
}, "private-browsing-transition-complete", false);
|
||||
|
||||
gPrivateBrowsing.privateBrowsingEnabled = true;
|
||||
},
|
||||
function() {
|
||||
info("Running step 10 - open tabs in private browsing mode");
|
||||
for (let i = 0; i < 3; i++) {
|
||||
let tab = gBrowser.addTab();
|
||||
loadTab(tab, TEST_URL_BASES[0] + (++gTabCounter));
|
||||
}
|
||||
},
|
||||
function() {
|
||||
info("Running step 11 - close tabs in private browsing mode");
|
||||
gBrowser.removeCurrentTab();
|
||||
ensure_opentabs_match_db(nextStep);
|
||||
},
|
||||
function() {
|
||||
info("Running step 12 - leave private browsing mode");
|
||||
|
||||
Services.obs.addObserver(function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(arguments.callee, "private-browsing-transition-complete");
|
||||
|
||||
let ps = Services.prefs;
|
||||
try {
|
||||
ps.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
} catch (ex) {}
|
||||
try {
|
||||
ps.clearUserPref("browser.tabs.warnOnClose");
|
||||
} catch (ex) {}
|
||||
|
||||
for (let i = 1; i < gBrowser.tabs.length; i++)
|
||||
waitForRestoredTab(gBrowser.tabs[i]);
|
||||
|
||||
}, "private-browsing-transition-complete", false);
|
||||
|
||||
gPrivateBrowsing.privateBrowsingEnabled = false;
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@ -196,7 +148,7 @@ function test() {
|
||||
|
||||
function loadTab(tab, url) {
|
||||
// Because adding visits is async, we will not be notified immediately.
|
||||
let visited = gPrivateBrowsing.privateBrowsingEnabled;
|
||||
let visited = false;
|
||||
let loaded = false;
|
||||
|
||||
function maybeCheckResults() {
|
||||
@ -211,37 +163,22 @@ function loadTab(tab, url) {
|
||||
maybeCheckResults();
|
||||
}, true);
|
||||
|
||||
if (!visited) {
|
||||
Services.obs.addObserver(
|
||||
function (aSubject, aTopic, aData) {
|
||||
if (url != aSubject.QueryInterface(Ci.nsIURI).spec)
|
||||
return;
|
||||
Services.obs.removeObserver(arguments.callee, aTopic);
|
||||
visited = true;
|
||||
maybeCheckResults();
|
||||
},
|
||||
"uri-visit-saved",
|
||||
false
|
||||
);
|
||||
}
|
||||
Services.obs.addObserver(
|
||||
function (aSubject, aTopic, aData) {
|
||||
if (url != aSubject.QueryInterface(Ci.nsIURI).spec)
|
||||
return;
|
||||
Services.obs.removeObserver(arguments.callee, aTopic);
|
||||
visited = true;
|
||||
maybeCheckResults();
|
||||
},
|
||||
"uri-visit-saved",
|
||||
false
|
||||
);
|
||||
|
||||
gTabWaitCount++;
|
||||
info("Loading page: " + url);
|
||||
tab.linkedBrowser.loadURI(url);
|
||||
}
|
||||
|
||||
function waitForRestoredTab(tab) {
|
||||
gTabWaitCount++;
|
||||
|
||||
tab.linkedBrowser.addEventListener("load", function () {
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
if (--gTabWaitCount == 0) {
|
||||
ensure_opentabs_match_db(nextStep);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
||||
function nextStep() {
|
||||
if (gTestSteps.length == 0) {
|
||||
while (gBrowser.tabs.length > 1) {
|
||||
|
@ -106,6 +106,12 @@ const kTitleTagsSeparator = " \u2013 ";
|
||||
|
||||
const kBrowserUrlbarBranch = "browser.urlbar.";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// Globals and Lazy Getters
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "pb",
|
||||
"@mozilla.org/privatebrowsing;1",
|
||||
"nsIPrivateBrowsingService");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// Helpers
|
||||
@ -147,6 +153,18 @@ function initTempTable(aDatabase)
|
||||
stmt.finalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if private browsing is active, false otherwise.
|
||||
*/
|
||||
function inPrivateBrowsingMode()
|
||||
{
|
||||
try {
|
||||
return pb.privateBrowsingEnabled;
|
||||
}
|
||||
catch (ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// AutoCompleteStatementCallbackWrapper class
|
||||
@ -519,6 +537,13 @@ nsPlacesAutoComplete.prototype = {
|
||||
|
||||
registerOpenPage: function PAC_registerOpenPage(aURI)
|
||||
{
|
||||
// Don't add any pages while in Private Browsing mode, so as to avoid
|
||||
// leaking information about other windows that might otherwise stay hidden
|
||||
// and private.
|
||||
if (inPrivateBrowsingMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let stmt = this._registerOpenPageQuery;
|
||||
stmt.params.page_url = aURI.spec;
|
||||
|
||||
@ -527,6 +552,13 @@ nsPlacesAutoComplete.prototype = {
|
||||
|
||||
unregisterOpenPage: function PAC_unregisterOpenPage(aURI)
|
||||
{
|
||||
// Entering Private Browsing mode will unregister all open pages, therefore
|
||||
// there should not be anything in the moz_openpages_temp table. As a
|
||||
// result, we can stop now without doing any unnecessary work.
|
||||
if (inPrivateBrowsingMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let stmt = this._unregisterOpenPageQuery;
|
||||
stmt.params.page_url = aURI.spec;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user